From 60e61287543dfbbff58bd1ef79d627cf3ca5113d Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 24 Sep 2021 09:50:24 -0400 Subject: [PATCH] no ping and other tweaks --- .local/bin/cron/checkup | 2 -- .local/bin/cron/newsup | 2 -- .local/bin/statusbar/sb-price | 21 +++++++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup index 4cfb856..bd3c634 100755 --- a/.local/bin/cron/checkup +++ b/.local/bin/cron/checkup @@ -2,8 +2,6 @@ # Syncs repositories and downloads updates, meant to be run as a cronjob. -ping -q -c 1 example.org > /dev/null || exit - notify-send "📦 Repository Sync" "Checking for package updates..." sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates. diff --git a/.local/bin/cron/newsup b/.local/bin/cron/newsup index 29f2b3c..cc50e78 100755 --- a/.local/bin/cron/newsup +++ b/.local/bin/cron/newsup @@ -3,8 +3,6 @@ # Set as a cron job to check for new RSS entries for newsboat. # If newsboat is open, sends it an "R" key to refresh. -ping -q -c 1 example.org > /dev/null || exit - /usr/bin/notify-send "📰 Updating RSS feeds..." pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit 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")"