From 395ec0d4007405cf7c177b369c58b942a7fd0f96 Mon Sep 17 00:00:00 2001 From: Secondarian <101978322+Secondarian@users.noreply.github.com> Date: Fri, 1 Jul 2022 23:26:58 +0200 Subject: [PATCH 1/2] Regions for Germany This lets you choose regions for Germany and get radar gifs from the national weather service instead of Sat24 which are way higher quality. --- .local/bin/statusbar/sb-doppler | 52 +++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler index dabf18b..ca95bdf 100755 --- a/.local/bin/statusbar/sb-doppler +++ b/.local/bin/statusbar/sb-doppler @@ -4,8 +4,29 @@ secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds. radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar" +radarger="${XDG_CACHE_HOME:-$HOME/.cache}/radarger" doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif" +pickger() { chosenger="$(echo "BAW: Baden-Württemberg +BAY: Bavaria +BBB: Berlin +BBB: Brandenburg +HES: Hesse +MVP: Mecklenburg-Western Pomerania +NIB: Lower Saxony +NIB: Bremen +NRW: North Rhine-Westphalia +RPS: Rhineland-Palatinate +RPS: Saarland +SAC: Saxony +SAA: Saxony-Anhalt +SHH: Schleswig-Holstein +SHH: Hamburg +THU: Thuringia" | dmenu -r -i -l 50 -p "Select a radar to use as default:" | sed "s/:.*//" | tr "[:upper:]" "[:lower:]")" + +# Secondary sanity check of selection and ensure user did not escape for Germany. +echo "$chosenger" | grep -q "[a-z]" && echo "$chosenger" > "$radarger" ;} + pickloc() { chosen="$(echo "US: Northeast US: Southeast US: PacNorthWest @@ -229,20 +250,27 @@ continentcode=$(echo "$chosen" | sed "s/:.*//") radarcode=$(echo "$chosen" | sed "s/..: // ; s/:.*//") # Sanity check of selection and ensure user did not escape. -echo "$radarcode" | grep -q "^[A-Z]\+$" && printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;} +echo "$radarcode" | grep -q "^[A-Z]\+$" && printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" -getdoppler() { - cont="$(sed "s/,.*//" "$radarloc")" +# Prompts for choosing region if in Germany. +case $(cut -c 4- "$radarloc") in + DE) pickger ;; + *) ;; +esac ;} + +getdoppler() { cont="$(sed "s/,.*//" "$radarloc")" loc="$(cut -c 4- "$radarloc")" - notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc." - if [ "$cont" = "US" ] ; then - curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ; - elif [ "$cont" = "EU" ] ; then - curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ; - elif [ "$cont" = "AF" ] ; then - curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ; - fi -} + notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc" + case $cont in + US) curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;; + EU) case $loc in + DE) [ ! -f "$radarger" ] && pickger + ger="$(cat "$radarger")" + curl -sL "https://www.dwd.de/DWD/wetter/radar/radfilm_${ger}_akt.gif" > "$doppler" ;; + *) curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;; + esac ;; + AF) curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;; + esac ;} showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;} From f5725a6cd2bed5eec6a3295f626dcf8fcdf25349 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 1 Jul 2022 21:30:08 -0400 Subject: [PATCH 2/2] fix --- .local/bin/statusbar/sb-doppler | 73 +++++++++++++++------------------ 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler index ca95bdf..91ec310 100755 --- a/.local/bin/statusbar/sb-doppler +++ b/.local/bin/statusbar/sb-doppler @@ -4,29 +4,8 @@ secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds. radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar" -radarger="${XDG_CACHE_HOME:-$HOME/.cache}/radarger" doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif" -pickger() { chosenger="$(echo "BAW: Baden-Württemberg -BAY: Bavaria -BBB: Berlin -BBB: Brandenburg -HES: Hesse -MVP: Mecklenburg-Western Pomerania -NIB: Lower Saxony -NIB: Bremen -NRW: North Rhine-Westphalia -RPS: Rhineland-Palatinate -RPS: Saarland -SAC: Saxony -SAA: Saxony-Anhalt -SHH: Schleswig-Holstein -SHH: Hamburg -THU: Thuringia" | dmenu -r -i -l 50 -p "Select a radar to use as default:" | sed "s/:.*//" | tr "[:upper:]" "[:lower:]")" - -# Secondary sanity check of selection and ensure user did not escape for Germany. -echo "$chosenger" | grep -q "[a-z]" && echo "$chosenger" > "$radarger" ;} - pickloc() { chosen="$(echo "US: Northeast US: Southeast US: PacNorthWest @@ -243,34 +222,46 @@ AF: TZ: Tanzania AF: TN: Tunisia AF: ZM: Zambia AF: KE: Kenya -AF: AO: Angola" | dmenu -r -i -l 50 -p "Select a radar to use as default:" | tr "[:lower:]" "[:upper:]")" +AF: AO: Angola +DE: BAW: Baden-Württemberg +DE: BAY: Bavaria +DE: BBB: Berlin +DE: BBB: Brandenburg +DE: HES: Hesse +DE: MVP: Mecklenburg-Western Pomerania +DE: NIB: Lower Saxony +DE: NIB: Bremen +DE: NRW: North Rhine-Westphalia +DE: RPS: Rhineland-Palatinate +DE: RPS: Saarland +DE: SAC: Saxony +DE: SAA: Saxony-Anhalt +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:]")" # Set continent code and radar code. continentcode=$(echo "$chosen" | sed "s/:.*//") radarcode=$(echo "$chosen" | sed "s/..: // ; s/:.*//") # Sanity check of selection and ensure user did not escape. -echo "$radarcode" | grep -q "^[A-Z]\+$" && printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" +echo "$radarcode" | grep -q "^[A-Z]\+$" && printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;} -# Prompts for choosing region if in Germany. -case $(cut -c 4- "$radarloc") in - DE) pickger ;; - *) ;; -esac ;} - -getdoppler() { cont="$(sed "s/,.*//" "$radarloc")" +getdoppler() { + cont="$(sed "s/,.*//" "$radarloc")" loc="$(cut -c 4- "$radarloc")" - notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc" - case $cont in - US) curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;; - EU) case $loc in - DE) [ ! -f "$radarger" ] && pickger - ger="$(cat "$radarger")" - curl -sL "https://www.dwd.de/DWD/wetter/radar/radfilm_${ger}_akt.gif" > "$doppler" ;; - *) curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;; - esac ;; - AF) curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;; - esac ;} + notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc." + if [ "$cont" = "US" ] ; then + curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ; + elif [ "$cont" = "EU" ] ; then + curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ; + elif [ "$cont" = "AF" ] ; then + curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ; + elif [ "$cont" = "DE" ] ; then + loc="$(echo "$loc" | tr "[:upper:]" "[:lower:]")" + curl -sL "https://www.dwd.de/DWD/wetter/radar/radfilm_${loc}_akt.gif" > "$doppler" ; + fi +} showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;}