Compare commits

...

8 Commits

Author SHA1 Message Date
appeasementPolitik
e720437db9
Merge b7dc644e1adf1dd07330c57de052ad95bfb48574 into d8a8970715070f73bcb6333e3fe851b6802ac702 2023-07-25 20:17:53 -06:00
appeasementPolitik
b7dc644e1a
Re-add fail-early to sb-price 2023-04-23 15:02:32 +00:00
appeasementPolitik
fead6d66ce
Merge branch 'master' into async 2023-04-20 17:16:20 +00:00
appeasementPolitik
b1ddd9548e
Merge latest commits and add retries 2023-04-20 17:11:58 +00:00
appeasementPolitik
e3a5d38200
Become synchronous on manual run and make dwmblocks signal code optional 2023-04-05 08:09:57 +00:00
appeasementPolitik
0e237592d7
Allow dwmblocks signal numbers to be changed 2023-04-04 07:25:19 +00:00
appeasementPolitik
060c093deb
Merge branch 'LukeSmithxyz:master' into async 2023-04-04 07:19:35 +00:00
appeasementPolitik
d1054d839e
Make dwmblocks modules async 2023-04-02 11:53:46 +00:00
4 changed files with 14 additions and 13 deletions

View File

@ -7,7 +7,7 @@ url="${WTTRURL:-wttr.in}"
weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
# Get a weather report from 'wttr.in' and save it locally.
getforecast() { curl -sf "$url/$LOCATION" > "$weatherreport" || exit 1; }
getforecast() { curl --retry 5 -sfm 10 "$url/$LOCATION" > "$weatherreport" || exit 1; }
# Forecast should be updated only once a day.
checkforecast() {
@ -48,6 +48,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
checkforecast || getforecast
showweather
checkforecast && showweather || { ( getforecast && pkill -RTMIN+"${1:-5}" "${STATUSBAR:-dwmblocks}") & echo; }

View File

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

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 --retry 5 -sfm 10 "wttr.in/?format=%m" > "$moonfile" && pkill -RTMIN+"${1:-17}" "${STATUSBAR:-dwmblocks}" ) & echo; exit; }
icon="$(cat "$moonfile")"

View File

@ -28,7 +28,7 @@ filestat="$(stat -c %x "$pricefile" 2>/dev/null)"
[ -d "$dir" ] || mkdir -p "$dir"
updateprice() { curl -sf -m 1 --fail-early $denom.$url/{1$target,$target$interval} --output "$pricefile" --output "$chartfile" ||
updateprice() { curl --retry 5 -sfm 10 --fail-early $denom.$url/{1$target,$target$interval} --output "$pricefile" --output "$chartfile" ||
rm -f "$pricefile" "$chartfile" ;}
[ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] &&
@ -48,9 +48,12 @@ case $BLOCK_BUTTON in
esac
[ -n "$updateme" ] &&
updateprice "$target" &&
[ -n "$showupdate" ] &&
notify-send "$icon Update complete." "$name price is now
\$$(cat "$pricefile")"
if [ -n "$showupdate" ]; then
updateprice && notify-send "$icon Update complete." "$name price is now \$$(cat "$pricefile")"
else
[ -n "$4" ] &&
{ ( updateprice && pkill -RTMIN+"$4" "${STATUSBAR:-dwmblocks}" ) & echo; exit; } ||
updateprice
fi
[ -f "$pricefile" ] && printf "%s%s%0.2f" "$icon" "$symb" "$(cat "$pricefile")"