summaryrefslogtreecommitdiffstats
path: root/.local/bin/statusbar/sb-price
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2021-09-24 09:50:24 -0400
committerLuke Smith <luke@lukesmith.xyz>2021-09-24 09:50:24 -0400
commit60e61287543dfbbff58bd1ef79d627cf3ca5113d (patch)
tree764138aed3a2f163193e022813f7526d88e78b28 /.local/bin/statusbar/sb-price
parent5caaa489ac45e23d1c0160ab6668d12585f6bffe (diff)
downloadeibhear-60e61287543dfbbff58bd1ef79d627cf3ca5113d.tar.gz
eibhear-60e61287543dfbbff58bd1ef79d627cf3ca5113d.tar.zst
eibhear-60e61287543dfbbff58bd1ef79d627cf3ca5113d.zip
no ping and other tweaks
Diffstat (limited to '.local/bin/statusbar/sb-price')
-rwxr-xr-x.local/bin/statusbar/sb-price21
1 files changed, 15 insertions, 6 deletions
diff --git a/.local/bin/statusbar/sb-price b/.local/bin/statusbar/sb-price
index a3fb457..42c84c1 100755
--- a/.local/bin/statusbar/sb-price
+++ b/.local/bin/statusbar/sb-price
@@ -11,12 +11,14 @@
currency="${4:-usd}"
interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
-pricefile="$dir/$1"
-chartfile="$dir/$1-chart"
+pricefile="$dir/$1-$currency"
+chartfile="$dir/$1-$currency-chart"
-updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
- curl -s "$currency.rate.sx/1$1" > "$pricefile" &&
- curl -s "$currency.rate.sx/$1$interval" > "$chartfile" ;}
+updateprice() { temp="$(mktemp)"
+ curl -s "$currency.rate.sx/1$1" > "$temp" &&
+ mv -f "$temp" "$pricefile" &&
+ curl -s "$currency.rate.sx/$1$interval" > "$temp" &&
+ mv -f "$temp" "$chartfile" ;}
[ -d "$dir" ] || mkdir -p "$dir"
@@ -38,4 +40,11 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-printf "$3%0.2f$currency" "$(cat "$pricefile")"
+case "$currency" in
+ usd) symb="$" ;;
+ gbp) symb="£" ;;
+ eur) symb="€" ;;
+ btc) symb="₿" ;;
+esac
+
+printf "$3$symb%0.2f$after" "$(cat "$pricefile")"