Make dwmblocks modules async

This commit is contained in:
appeasementPolitik 2023-04-02 11:53:46 +00:00 committed by GitHub
parent 5a6c56d565
commit d1054d839e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 10 deletions

View File

@ -48,6 +48,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
checkforecast || getforecast
showweather
checkforecast && showweather || { ( getforecast && pkill -RTMIN+5 "${STATUSBAR:-dwmblocks}") & echo; }

View File

@ -6,5 +6,6 @@
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
ifinstalled "geoip" || exit
addr="$(curl ifconfig.me 2>/dev/null)" || exit
ipfile="$XDG_RUNTIME_DIR/iplocate"
addr=$(cat "$ipfile") && rm "$ipfile" || { ( curl -s ifconfig.me > "$ipfile" && pkill -RTMIN+27 "${STATUSBAR:-dwmblocks}") & echo; exit; }
grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"

View File

@ -5,7 +5,7 @@
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
[ -s "$moonfile" ] && [ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
{ ( curl -sf "wttr.in/?format=%m" > "$moonfile" && pkill -RTMIN+17 "${STATUSBAR:-dwmblocks}" ) & echo; exit; }
icon="$(cat "$moonfile")"

View File

@ -18,7 +18,7 @@ filestat="$(stat -c %x "$pricefile" 2>/dev/null)"
[ -d "$dir" ] || mkdir -p "$dir"
updateprice() { curl -sf -m 1 --fail-early $currency.$url/{1$1,$1$interval} --output "$pricefile" --output "$chartfile" ||
updateprice() { curl -sf $currency.$url/{1$1,$1$interval} --output "$pricefile" --output "$chartfile" ||
rm -f "$pricefile" "$chartfile" ;}
[ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] &&
@ -38,10 +38,21 @@ case $BLOCK_BUTTON in
esac
[ -n "$updateme" ] &&
updateprice "$1" &&
[ -n "$showupdate" ] &&
notify-send "$3 Update complete." "$2 price is now
\$$(cat "$pricefile")"
if [ -n "$showupdate" ]; then
updateprice "$1" && notify-send "$3 Update complete." "$2 price is now \$$(cat "$pricefile")"
else
# get dwmblocks signal numbers corresponding to currency
case "$1" in
lbc) sig="22" ;;
bat) sig="20" ;;
link) sig="25" ;;
xmr) sig="24" ;;
eth) sig="23" ;;
btc) sig="21" ;;
esac
( updateprice "$1" && pkill -RTMIN+"$sig" "${STATUSBAR:-dwmblocks}") & echo; exit
fi
case "$currency" in
usd) symb="$" ;;