summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2023-03-31 09:44:59 -0400
committerLuke Smith <luke@lukesmith.xyz>2023-03-31 09:44:59 -0400
commit5a6c56d565e4e7c20171f5757e12306d9253c52b (patch)
treed08f94b30a6589d119524aecd7eeadd4eb8496a4
parent749f74f84ef1ec1b15c9003c23120dc5c4baaa35 (diff)
downloadeibhear-5a6c56d565e4e7c20171f5757e12306d9253c52b.tar.gz
eibhear-5a6c56d565e4e7c20171f5757e12306d9253c52b.tar.zst
eibhear-5a6c56d565e4e7c20171f5757e12306d9253c52b.zip
efficiency and fail tweaks
-rwxr-xr-x.local/bin/statusbar/sb-price14
1 files changed, 9 insertions, 5 deletions
diff --git a/.local/bin/statusbar/sb-price b/.local/bin/statusbar/sb-price
index 53c5023..9dc2d52 100755
--- a/.local/bin/statusbar/sb-price
+++ b/.local/bin/statusbar/sb-price
@@ -18,17 +18,15 @@ filestat="$(stat -c %x "$pricefile" 2>/dev/null)"
[ -d "$dir" ] || mkdir -p "$dir"
-updateprice() { curl -sf -m 3 $currency.$url/{1$1,$1$interval} --output "$pricefile" --output "$chartfile" ||
+updateprice() { curl -sf -m 1 --fail-early $currency.$url/{1$1,$1$interval} --output "$pricefile" --output "$chartfile" ||
rm -f "$pricefile" "$chartfile" ;}
[ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] &&
- updateprice "$1"
+ updateme="1"
case $BLOCK_BUTTON in
1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;;
- 2) notify-send -u low "$3 Updating..." "Updating $2 price..."
- updateprice "$1" && notify-send "$3 Update complete." "$2 price is now
-\$$(cat "$pricefile")" ;;
+ 2) notify-send -u low "$3 Updating..." "Updating $2 price..." ; updateme="1" ; showupdate="1" ;;
3) uptime="$(date -d "$filestat" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
notify-send "$3 $2 module" "\- <b>Exact price: \$$(cat "$pricefile")</b>
- Left click for chart of changes.
@@ -39,6 +37,12 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
+[ -n "$updateme" ] &&
+ updateprice "$1" &&
+ [ -n "$showupdate" ] &&
+ notify-send "$3 Update complete." "$2 price is now
+\$$(cat "$pricefile")"
+
case "$currency" in
usd) symb="$" ;;
gbp) symb="£" ;;