mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2025-10-07 07:22:36 +02:00
Merge 0afc70a07c69b2a6fb1ab153a7087a0776e5fa8f into c95a16916d5c71288e5e49a78d0621943c89a682
This commit is contained in:
commit
41ca7e2767
@ -7,11 +7,11 @@ url="${WTTRURL:-wttr.in}"
|
|||||||
weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
|
weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
|
||||||
|
|
||||||
# Get a weather report from 'wttr.in' and save it locally.
|
# Get a weather report from 'wttr.in' and save it locally.
|
||||||
getforecast() { timeout --signal=1 2s curl -sf "$url/$LOCATION" > "$weatherreport" || exit 1; }
|
getforecast() { curl -sf "$url/$LOCATION" --output "$weatherreport" && touch "$weatherreport"; }
|
||||||
|
|
||||||
# Forecast should be updated only once a day.
|
# Forecast should be updated only once a day.
|
||||||
checkforecast() {
|
checkforecast() {
|
||||||
[ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null |
|
[ "$(stat -c %y "$weatherreport" 2>/dev/null |
|
||||||
cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
|
cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +48,9 @@ case $BLOCK_BUTTON in
|
|||||||
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
checkforecast || getforecast
|
checkforecast && showweather ||
|
||||||
|
( flock -n 9 &&
|
||||||
showweather
|
( 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 ) 9>"${XDG_RUNTIME_DIR}/sb-forecast.lock"
|
||||||
|
|||||||
@ -5,10 +5,15 @@
|
|||||||
#
|
#
|
||||||
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
||||||
|
|
||||||
set -e
|
ifinstalled "geoip" || exit 1
|
||||||
|
|
||||||
ifinstalled "geoip"
|
ipfile="$XDG_RUNTIME_DIR/iplocate"
|
||||||
addr="$(geoiplookup "$(curl -sfm 1 ifconfig.me 2>/dev/null)")"
|
addr=$(cat "$ipfile" 2>/dev/null) && addr=$(geoiplookup "$addr" 2>/dev/null) && rm "$ipfile" ||
|
||||||
|
( flock -n 9 &&
|
||||||
|
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
|
||||||
|
curl -sf api.ipify.org --output "$ipfile"; do sleep 60; done &&
|
||||||
|
pkill -RTMIN+"${1:-27}" "${STATUSBAR:-dwmblocks}" ) &
|
||||||
|
echo; exit ) 9>"${XDG_RUNTIME_DIR}/sb-iplocate.lock"
|
||||||
name="${addr##*, }"
|
name="${addr##*, }"
|
||||||
flag="$(grep "flag: $name" "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji")"
|
flag="$(grep "flag: $name" "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji")"
|
||||||
flag="${flag%% *}"
|
flag="${flag%% *}"
|
||||||
|
|||||||
@ -4,8 +4,12 @@
|
|||||||
|
|
||||||
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
||||||
|
|
||||||
[ -s "$moonfile" ] && [ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
||||||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
|
( flock -n 9 &&
|
||||||
|
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
|
||||||
|
curl -sf "wttr.in/?format=%m" --output "$moonfile" && touch "$moonfile"; do sleep 60; done &&
|
||||||
|
pkill -RTMIN+"${1:-17}" "${STATUSBAR:-dwmblocks}" ) &
|
||||||
|
echo; exit ) 9>"${XDG_RUNTIME_DIR}/sb-moonphase.lock"
|
||||||
|
|
||||||
icon="$(cat "$moonfile")"
|
icon="$(cat "$moonfile")"
|
||||||
|
|
||||||
|
|||||||
@ -28,8 +28,7 @@ filestat="$(stat -c %x "$pricefile" 2>/dev/null)"
|
|||||||
|
|
||||||
[ -d "$dir" ] || mkdir -p "$dir"
|
[ -d "$dir" ] || mkdir -p "$dir"
|
||||||
|
|
||||||
updateprice() { curl -sf -m 1 --fail-early $denom.$url/{1$target,$target$interval} --output "$pricefile" --output "$chartfile" ||
|
updateprice() { curl -sf --fail-early $denom.$url/{1$target,$target$interval} --output "$pricefile" --output "$chartfile" && touch "$pricefile" "$chartfile"; }
|
||||||
rm -f "$pricefile" "$chartfile" ;}
|
|
||||||
|
|
||||||
[ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] &&
|
[ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] &&
|
||||||
updateme="1"
|
updateme="1"
|
||||||
@ -48,9 +47,16 @@ case $BLOCK_BUTTON in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
[ -n "$updateme" ] &&
|
[ -n "$updateme" ] &&
|
||||||
updateprice "$target" &&
|
if [ -n "$showupdate" ]; then
|
||||||
[ -n "$showupdate" ] &&
|
updateprice && notify-send "$icon Update complete." "$name price is now \$$(cat "$pricefile")"
|
||||||
notify-send "$icon Update complete." "$name price is now
|
else
|
||||||
\$$(cat "$pricefile")"
|
[ -n "$4" ] &&
|
||||||
|
( flock -n 9 &&
|
||||||
|
( 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 ) 9>"${XDG_RUNTIME_DIR}/sb-price.lock" ||
|
||||||
|
updateprice
|
||||||
|
fi
|
||||||
|
|
||||||
[ -f "$pricefile" ] && printf "%s%s%0.2f" "$icon" "$symb" "$(cat "$pricefile")"
|
[ -f "$pricefile" ] && printf "%s%s%0.2f" "$icon" "$symb" "$(cat "$pricefile")"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user