dwmblock-doppler (7253B)
1 #!/bin/sh 2 3 # Show a Doppler RADAR of a user's preferred location. 4 5 secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds. 6 radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar" 7 doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif" 8 9 pickloc() { chosen="$(echo "US: CONUS: Continental United States 10 US: Northeast 11 US: Southeast 12 US: PacNorthWest 13 US: PacSouthWest 14 US: UpperMissVly 15 US: SouthMissVly 16 US: SouthPlains 17 US: NorthRockies 18 US: SouthRockies 19 US: Alaska 20 US: Carib 21 US: Hawaii 22 US: CentGrLakes 23 US: Conus-Large 24 US: KABR: Aberdeen, SD 25 US: KBIS: Bismarck, ND 26 US: KFTG: Denver/Boulder, CO 27 US: KDMX: Des Moines, IA 28 US: KDTX: Detroit, MI 29 US: KDDC: Dodge City, KS 30 US: KDLH: Duluth, MN 31 US: KCYS: Cheyenne, WY 32 US: KLOT: Chicago, IL 33 US: KGLD: Goodland, KS 34 US: KUEX: Hastings, NE 35 US: KGJX: Grand Junction, CO 36 US: KGRR: Grand Rapids, MI 37 US: KMVX: Fargo/Grand Forks, ND 38 US: KGRB: Green Bay, WI 39 US: KIND: Indianapolis, IN 40 US: KJKL: Jackson, KY 41 US: KARX: La Crosse, WI 42 US: KILX: Lincoln/Central Illinois, IL 43 US: KLVX: Louisville, KY 44 US: KMQT: Marquette 45 US: KMKX: Milwaukee, WI 46 US: KMPX: Minneapolis, MN 47 US: KAPX: Gaylord/Alpena, MI 48 US: KLNX: North Platte, NE 49 US: KIWX: N. Webster/Northern, IN 50 US: KOAX: Omaha, NE 51 US: KPAH: Paducah, KY 52 US: KEAX: Pleasant Hill, MO 53 US: KPUX: Pueblo, CO 54 US: KDVN: Quad Cities, IA 55 US: KUDX: Rapid City, SD 56 US: KRIW: Riverton, WY 57 US: KSGF: Springfield, MO 58 US: KLSX: St. LOUIS, MO 59 US: KFSD: Sioux Falls, SD 60 US: KTWX: Topeka, KS 61 US: KICT: Wichita, KS 62 US: KVWX: Paducah, KY 63 US: ICAO: Responsible Wfo 64 US: KLTX: WILMINGTON, NC 65 US: KCCX: State College/Central, PA 66 US: KLWX: Sterling, VA 67 US: KFCX: Blacksburg/Roanoke, VA 68 US: KRAX: Raleigh/Durham, NC 69 US: KGYX: Portland, ME 70 US: KDIX: Mt Holly/Philadelphia, PA 71 US: KPBZ: Pittsburgh, PA 72 US: KAKQ: Wakefield, VA 73 US: KMHX: Morehead City, NC 74 US: KGSP: Greer/Greenville/Sprtbg, SC 75 US: KILN: Wilmington/Cincinnati, OH 76 US: KCLE: Cleveland, OH 77 US: KCAE: Columbia, SC 78 US: KBGM: Binghamton, NY 79 US: KENX: Albany, NY 80 US: KBUF: Buffalo, NY 81 US: KCXX: Burlington, VT 82 US: KCBW: Caribou, ME 83 US: KBOX: Boston /Taunton, MA 84 US: KOKX: New York City, NY 85 US: KCLX: Charleston, SC 86 US: KRLX: Charleston, WV 87 US: ICAO: Responsible WFO 88 US: KBRO: Brownsville, TX 89 US: KABX: Albuquerque, NM 90 US: KAMA: Amarillo, TX 91 US: KFFC: Peachtree City/Atlanta, GA 92 US: KEWX: Austin/Sanantonio, TX 93 US: KBMX: Birmingham, AL 94 US: KCRP: Corpus Christi, TX 95 US: KFWS: Dallas / Ft. Worth, TX 96 US: KEPZ: El Paso, TX 97 US: KHGX: Houston/ Galveston, TX 98 US: KJAX: Jacksonville, FL 99 US: KBYX: Key West, FL 100 US: KMRX: Morristown/knoxville, TN 101 US: KLBB: Lubbock, TX 102 US: KLZK: Little Rock, AR 103 US: KLCH: Lake Charles, LA 104 US: KOHX: Nashville, TN 105 US: KMLB: Melbourne, FL 106 US: KNQA: Memphis, TN 107 US: KAMX: Miami, FL 108 US: KMAF: Midland/odessa, TX 109 US: KTLX: Norman, OK 110 US: KHTX: Huntsville, AL 111 US: KMOB: Mobile, AL 112 US: KTLH: Tallahassee, FL 113 US: KTBW: Tampa Bay Area, FL 114 US: KSJT: San Angelo, TX 115 US: KINX: Tulsa, OK 116 US: KSRX: Tulsa, OK 117 US: KLIX: New Orleans/slidell, LA 118 US: KDGX: Jackson, MS 119 US: KSHV: Shreveport, LA 120 US: ICAO: Responsible WFO 121 US: KLGX: Seattle / Tacoma, WA 122 US: KOTX: Spokane, WA 123 US: KEMX: Tucson, AZ 124 US: KYUX: Phoenix, AZ 125 US: KNKX: San Diego, CA 126 US: KMUX: Monterey/san Francisco, CA 127 US: KHNX: San Joaquin/hanford, CA 128 US: KSOX: San Diego, CA 129 US: KATX: Seattle / Tacoma, WA 130 US: KIWA: Phoenix, AZ 131 US: KRTX: Portland, OR 132 US: KSFX: Pocatello, ID 133 US: KRGX: Reno, NV 134 US: KDAX: Sacramento, CA 135 US: KMTX: Salt Lake City, UT 136 US: KPDT: Pendleton, OR 137 US: KMSX: Missoula, MT 138 US: KESX: Las Vegas, NV 139 US: KVTX: Los Angeles, CA 140 US: KMAX: Medford, OR 141 US: KFSX: Flagstaff, AZ 142 US: KGGW: Glasgow, MT 143 US: KLRX: Elko, NV 144 US: KBHX: Eureka, CA 145 US: KTFX: Great Falls, MT 146 US: KCBX: Boise, ID 147 US: KBLX: Billings, MT 148 US: KICX: Salt Lake City, UT 149 US: ICAO: Responsible Wfo W/ MSCF 150 US: PABC: Anchorage, AK 151 US: PAPD: Fairbanks, AK 152 US: PHKM: Honolulu, HI 153 US: PAHG: Anchorage, AK 154 US: PAKC: Anchorage, AK 155 US: PAIH: Anchorage, AK 156 US: PHMO: Honolulu, HI 157 US: PAEC: Fairbanks, AK 158 US: TJUA: San Juan, PR 159 US: PACG: Juneau, AK 160 US: PHKI: Honolulu, HI 161 US: PHWA: Honolulu, HI 162 US: ICAO: Responsible Wfo W/ MSCF 163 US: KFDR: Norman, OK 164 US: PGUA: Guam 165 US: KBBX: Sacramento, CA 166 US: KFDX: Albuquerque, NM 167 US: KGWX: Jackson, MS 168 US: KDOX: Wakefield, VA 169 US: KDYX: San Angelo, TX 170 US: KEYX: Las Vegas, NV 171 US: KEVX: Mobile, AL 172 US: KHPX: Paducah, KY 173 US: KTYX: Burlington, VT 174 US: KGRK: Dallas / Ft. Worth, TX 175 US: KPOE: Lake Charles, LA 176 US: KEOX: Tallahassee, FL 177 US: KHDX: El Paso, TX 178 US: KDFX: San Antonio, TX 179 US: KMXX: Birmingham, AL 180 US: KMBX: Bismarck, ND 181 US: KVAX: Jacksonville, FL 182 US: KJGX: Peachtree City/atlanta, GA 183 US: KVNX: Norman, OK 184 US: KVBX: Vandenberg Afb: Orcutt, CA 185 EU: Europe 186 EU: GB: Great Brittain 187 EU: SCAN: Scandinavia. Norway, Sweden And Denmark 188 EU: ALPS: The Alps 189 EU: NL: The Netherlands 190 EU: DE: Germany 191 EU: SP: Spain 192 EU: FR: France 193 EU: IT: Italy 194 EU: PL: Poland 195 EU: GR: Greece 196 EU: TU: Turkey 197 EU: RU: Russia 198 EU: BA: Bahrain 199 EU: BC: Botswana 200 EU: SE: Republic of Seychelles 201 EU: HU: Hungary 202 EU: UK: Ukraine 203 AF: AF: Africa 204 AF: WA: West Africa 205 AF: ZA: South Africa 206 AF: DZ: Algeria 207 AF: CE: Canary Islands 208 AF: NG: Nigeria 209 AF: TD: Chad 210 AF: CG: Democratic Republic of Congo 211 AF: EG: Egypt 212 AF: ET: Ethiopia 213 AF: CM: Cameroon 214 AF: IS: Israel 215 AF: LY: Libya 216 AF: MG: Madagascar 217 AF: MO: Morocco 218 AF: BW: Namibia 219 AF: SA: Saudi Arabia 220 AF: SO: Somalia 221 AF: SD: Sudan 222 AF: TZ: Tanzania 223 AF: TN: Tunisia 224 AF: ZM: Zambia 225 AF: KE: Kenya 226 AF: AO: Angola 227 DE: BAW: Baden-Württemberg 228 DE: BAY: Bavaria 229 DE: BBB: Berlin 230 DE: BBB: Brandenburg 231 DE: HES: Hesse 232 DE: MVP: Mecklenburg-Western Pomerania 233 DE: NIB: Lower Saxony 234 DE: NIB: Bremen 235 DE: NRW: North Rhine-Westphalia 236 DE: RPS: Rhineland-Palatinate 237 DE: RPS: Saarland 238 DE: SAC: Saxony 239 DE: SAA: Saxony-Anhalt 240 DE: SHH: Schleswig-Holstein 241 DE: SHH: Hamburg 242 DE: THU: Thuringia" | dmenu -i -l 50 -p "Select a radar to use as default:" | tr "[:lower:]" "[:upper:]")" 243 244 # Ensure user did not escape. 245 [ -z "$chosen" ] && exit 1 246 247 # Set continent code and radar code. 248 continentcode=${chosen%%:*} 249 radarcode=${chosen#* } radarcode=${radarcode%:*} 250 251 # Print codes to $radarloc file. 252 printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;} 253 254 getdoppler() { 255 cont=$(cut -c -2 "$radarloc") 256 loc=$(cut -c 4- "$radarloc") 257 notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc." 258 case "$cont" in 259 "US") curl -sL "https://radar.weather.gov/ridge/standard/${loc}_loop.gif" > "$doppler" ;; 260 "EU") curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;; 261 "AF") curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;; 262 "DE") loc="$(echo "$loc" | tr "[:upper:]" "[:lower:]")" 263 curl -sL "https://www.dwd.de/DWD/wetter/radar/radfilm_${loc}_akt.gif" > "$doppler" ;; 264 esac 265 } 266 267 showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;} 268 case $BUTTON in 269 1) [ ! -f "$radarloc" ] && pickloc && getdoppler 270 [ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler 271 showdoppler ;; 272 2) pickloc && getdoppler && showdoppler ;; 273 3) notify-send "🗺️ Doppler RADAR module" "\- Left click for local Doppler RADAR. 274 - Middle click to update RADAR location. 275 After $secs seconds, new clicks will also automatically update the doppler RADAR." ;; 276 6) "$TERMINAL" -e "$EDITOR" "$0" ;; 277 esac 278 279 echo 🌅