summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/statusbar/sb-doppler17
1 files changed, 10 insertions, 7 deletions
diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler
index 26d37b4..b5833a7 100755
--- a/.local/bin/statusbar/sb-doppler
+++ b/.local/bin/statusbar/sb-doppler
@@ -240,18 +240,21 @@ DE: SHH: Schleswig-Holstein
DE: SHH: Hamburg
DE: THU: Thuringia" | dmenu -r -i -l 50 -p "Select a radar to use as default:" | tr "[:lower:]" "[:upper:]")"
+# Ensure user did not escape.
+[ -z "$chosen" ] && exit 1
+
# Set continent code and radar code.
-continentcode=$(echo "$chosen" | sed "s/:.*//")
-radarcode=$(echo "$chosen" | sed "s/..: // ; s/:.*//")
+continentcode=${chosen%%:*}
+radarcode=${chosen#* } radarcode=${radarcode%:*}
-# Sanity check of selection and ensure user did not escape.
-echo "$radarcode" | grep -q "^[A-Z]\+$" && printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;}
+# Print codes to $radarloc file.
+ printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;}
getdoppler() {
- cont="$(sed "s/,.*//" "$radarloc")"
- loc="$(cut -c 4- "$radarloc")"
+ cont=$(cut -c -2 "$radarloc")
+ loc=$(cut -c 4- "$radarloc")
notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc."
- case "$cont" in
+ case "$cont" in
"US") curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;;
"EU") curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;;
"AF") curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;;