Compare commits

..

1 Commits

Author SHA1 Message Date
appeasementPolitik
e720437db9
Merge b7dc644e1adf1dd07330c57de052ad95bfb48574 into d8a8970715070f73bcb6333e3fe851b6802ac702 2023-07-25 20:17:53 -06:00
4 changed files with 7 additions and 24 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"; }
getforecast() { curl --retry 5 -sfm 10 "$url/$LOCATION" > "$weatherreport" || exit 1; }
# Forecast should be updated only once a day.
checkforecast() {
@ -48,9 +48,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
checkforecast && showweather ||
{ [ -z "$(pgrep 'sb-forecast' | tail -n +3)" ] &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
getforecast; do sleep 60; done &&
pkill -RTMIN+"${1:-5}" "${STATUSBAR:-dwmblocks}" ) &
echo; }
checkforecast && showweather || { ( getforecast && pkill -RTMIN+"${1:-5}" "${STATUSBAR:-dwmblocks}") & echo; }

View File

@ -8,12 +8,7 @@
ifinstalled "geoip" || exit 1
ipfile="$XDG_RUNTIME_DIR/iplocate"
addr=$(cat "$ipfile" 2>/dev/null) && addr=$(geoiplookup "$addr" 2>/dev/null) && rm "$ipfile" ||
{ [ -z "$(pgrep 'sb-iplocate' | tail -n +3)" ] &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
curl -sf ifconfig.me > "$ipfile"; do sleep 60; done &&
pkill -RTMIN+"${1:-27}" "${STATUSBAR:-dwmblocks}" ) &
echo; exit; }
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,11 +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')" ] ||
{ [ -z "$(pgrep 'sb-moonphase' | tail -n +3)" ] &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
curl -sf "wttr.in/?format=%m" > "$moonfile"; do sleep 60; done &&
pkill -RTMIN+"${1:-17}" "${STATUSBAR:-dwmblocks}" ) &
echo; exit; }
{ ( 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,8 @@ filestat="$(stat -c %x "$pricefile" 2>/dev/null)"
[ -d "$dir" ] || mkdir -p "$dir"
updateprice() { curl -sf --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')" ] &&
updateme="1"
@ -51,11 +52,7 @@ esac
updateprice && notify-send "$icon Update complete." "$name price is now \$$(cat "$pricefile")"
else
[ -n "$4" ] &&
{ [ -z "$(pgrep 'sb-price' | tail -n +3)" ] &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
updateprice; do sleep 60; done &&
pkill -RTMIN+"$4" "${STATUSBAR:-dwmblocks}" ) &
echo; exit; } ||
{ ( updateprice && pkill -RTMIN+"$4" "${STATUSBAR:-dwmblocks}" ) & echo; exit; } ||
updateprice
fi