Skip to content

Instantly share code, notes, and snippets.

@tyjak
Created March 7, 2026 12:01
Show Gist options
  • Select an option

  • Save tyjak/21910d755c6222cc3e89bce8071c9bd5 to your computer and use it in GitHub Desktop.

Select an option

Save tyjak/21910d755c6222cc3e89bce8071c9bd5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# GistID: 21910d755c6222cc3e89bce8071c9bd5
STATE_FILE="/tmp/price_prev"
price=$($1)
subject=$2
notify=${3:-'true'}
prev=""
[ -f "$STATE_FILE" ] && prev=$(cat "$STATE_FILE")
color="\033[0m"
if [ -n "$prev" ]; then
if (( $(echo "$price > $prev" | bc -l) )); then
color="\033[31m" # green
[ $notify == "true" ] && notify-send --app-name=notifphone "Prix a changé" "Le prix $subject <b>augmente</b> : $price €"
elif (( $(echo "$price < $prev" | bc -l) )); then
color="\033[32m" # red
[ $notify == "true" ] && notify-send --app-name=notifphone "Prix a changé" "Le prix $subject <b>baisse</b> : $price €"
fi
fi
printf "${color}%s\033[0m\n" "$price"
echo "$price" > "$STATE_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment