aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-price
diff options
context:
space:
mode:
authorawy <awy@awy.one>2025-08-24 14:08:03 +0300
committerawy <awy@awy.one>2025-08-24 14:08:03 +0300
commit474006cd2c173d02e4511045f07c04e159010d4e (patch)
treec6d494b835f0a2914493b1511c3af70b7009cff7 /.local/bin/statusbar/sb-price
parent632c51ed3ce26090e5ba67b27075bd1ac5848fca (diff)
downloadhyprdots-474006cd2c173d02e4511045f07c04e159010d4e.tar.gz
cleanup
Diffstat (limited to '.local/bin/statusbar/sb-price')
-rwxr-xr-x.local/bin/statusbar/sb-price59
1 files changed, 0 insertions, 59 deletions
diff --git a/.local/bin/statusbar/sb-price b/.local/bin/statusbar/sb-price
deleted file mode 100755
index d320511..0000000
--- a/.local/bin/statusbar/sb-price
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-
-# Usage:
-# price <currency-base currency> <name of currency> <icon> <signal>
-# price bat-btc "Basic Attention Token" 🦁 24
-# This will give the price of BAT denominated in BTC and will update on
-# signal 24.
-# When the name of the currency is multi-word, put it in quotes.
-
-[ -z "$1" ] && exit 1
-
-url="${CRYPTOURL:-rate.sx}"
-target="${1%%-*}"
-denom="${1##*-}"
-name="${2:-$1}"
-icon="${3:-💰}"
-case "$denom" in
- "$target"|usd) denom="usd"; symb="$" ;;
- gbp) symb="£" ;;
- eur) symb="€" ;;
- rub) symb="₽" ;;
- btc) symb="" ;;
-esac
-interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
-dir="${XDG_CACHE_HOME:-$HOME/.cache}/crypto-prices"
-pricefile="$dir/$target-$denom"
-chartfile="$dir/$target-$denom-chart"
-filestat="$(stat -c %y "$pricefile" 2>/dev/null)"
-
-[ -d "$dir" ] || mkdir -p "$dir"
-
-updateprice() { curl -sf \
- --fail-early "${denom}.${url}/1${target}" "${denom}.${url}/${target}${interval}" \
- --output "$pricefile" --output "$chartfile" ||
- rm -f "$pricefile" "$chartfile" ;}
-
-[ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] &&
- updateme="1"
-
-case $BLOCK_BUTTON in
- 1) setsid -f "$TERMINAL" -e less -Srf "$chartfile" >/dev/null ;;
- 2) notify-send -u low "$icon Updating..." "Updating $name price..." ; updateme="1" ; showupdate="1" ;;
- 3) uptime="$(date -d "$filestat" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
- notify-send "$icon $name module" "\- <b>Exact price: $symb$(bat "$pricefile")</b>
-- Left click for chart of changes.
-- Middle click to update.
-- Shows 🔃 if updating prices.
-- <b>Last updated:
-$uptime</b>" ;;
- 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null ;;
-esac
-
-[ -n "$updateme" ] &&
- updateprice "$target" &&
- [ -n "$showupdate" ] &&
- notify-send "$icon Update complete." "$name price is now
-$symb$(bat "$pricefile")"
-
-[ -f "$pricefile" ] && printf "%s%s%0.2f\n" "$icon" "$symb" "$(bat "$pricefile")"