summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/doppler
blob: dc93db08b4911b1c1c3d9f48f0c970a2d7eeb3c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/sh

# Show a Doppler RADAR of an American user's preferred location.

secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds.
radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar"
doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif"

pickloc() { chosen="$(echo "Northeast
Southeast
PacNorthWest
PacSouthWest
UpperMissVly
SouthMissVly
SouthPlains
NorthRockies
SouthRockies
Alaska
Carib
Hawaii
CentGrLakes
Conus-Large
KABR: Aberdeen, SD
KBIS: Bismarck, ND
KFTG: Denver/Boulder, CO
KDMX: Des Moines, IA
KDTX: Detroit, MI
KDDC: Dodge City, KS
KDLH: Duluth, MN
KCYS: Cheyenne, WY
KLOT: Chicago, IL
KGLD: Goodland, KS
KUEX: Hastings, NE
KGJX: Grand Junction, CO
KGRR: Grand Rapids, MI
KMVX: Fargo/Grand Forks, ND
KGRB: Green Bay, WI
KIND: Indianapolis, IN
KJKL: Jackson, KY
KARX: La Crosse, WI
KILX: Lincoln/Central Illinois, IL
KLVX: Louisville, KY
KMQT: Marquette
KMKX: Milwaukee, WI
KMPX: Minneapolis, MN
KAPX: Gaylord/Alpena, MI
KLNX: North Platte, NE
KIWX: N. Webster/Northern, IN
KOAX: Omaha, NE
KPAH: Paducah, KY
KEAX: Pleasant Hill, MO
KPUX: Pueblo, CO
KDVN: Quad Cities, IA
KUDX: Rapid City, SD
KRIW: Riverton, WY
KSGF: Springfield, MO
KLSX: St. LOUIS, MO
KFSD: Sioux Falls, IA
KTWX: Topeka, KS
KICT: Wichita, KS
KVWX: Paducah, KY
ICAO: Responsible Wfo
KLTX: WILMINGTON, NC
KCCX: State College/Central, PA
KLWX: Sterling, VA
KFCX: Blacksburg/Roanoke, VA
KRAX: Raleigh/Durham, NC
KGYX: Portland, ME
KDIX: Mt Holly/Philadelphia, PA
KPBZ: Pittsburgh, PA
KAKQ: Wakefield, VA
KMHX: Morehead City, NC
KGSP: Greer/Greenville/Sprtbg, SC
KILN: Wilmington/Cincinnati, OH
KCLE: Cleveland, OH
KCAE: Columbia, SC
KBGM: Binghamton, NY
KENX: Albany, NY
KBUF: Buffalo, NY
KCXX: Burlington, VT
KCBW: Caribou, ME
KBOX: Boston /Taunton, MA
KOKX: New York City, NY
KCLX: Charleston, SC
KRLX: Charleston, WV
ICAO: Responsible WFO
KBRO: Brownsville, TX
KABX: Albuquerque, NM
KAMA: Amarillo, TX
KFFC: Peachtree City/Atlanta, GA
KEWX: Austin/Sanantonio, TX
KBMX: Birmingham, AL
KCRP: Corpus Christi, TX
KFWS: Dallas / Ft. Worth, TX
KEPZ: El Paso, TX
KHGX: Houston/ Galveston, TX
KJAX: Jacksonville, FL
KBYX: Key West, FL
KMRX: Morristown/knoxville, TN
KLBB: Lubbock, TX
KLZK: Little Rock, AR
KLCH: Lake Charles, LA
KOHX: Nashville, TN
KMLB: Melbourne, FL
KNQA: Memphis, TN
KAMX: Miami, FL
KMAF: Midland/odessa, TX
KTLX: Norman, OK
KHTX: Huntsville, AL
KMOB: Mobile, AL
KTLH: Tallahassee, FL
KTBW: Tampa Bay Area, FL
KSJT: San Angelo, TX
KINX: Tulsa, OK
KSRX: Tulsa, OK
KLIX: New Orleans/slidell, LA
KDGX: Jackson, MS
KSHV: Shreveport, LA
ICAO: Responsible WFO
KLGX: Seattle / Tacoma, WA
KOTX: Spokane, WA
KEMX: Tucson, AZ
KYUX: Phoenix, AZ
KNKX: San Diego, CA
KMUX: Monterey/san Francisco, CA
KHNX: San Joaquin/hanford, CA
KSOX: San Diego, CA
KATX: Seattle / Tacoma, WA
KIWA: Phoenix, AZ
KRTX: Portland, OR
KSFX: Pocatello, ID
KRGX: Reno, NV
KDAX: Sacramento, CA
KMTX: Salt Lake City, UT
KPDT: Pendleton, OR
KMSX: Missoula, MT
KESX: Las Vegas, NV
KVTX: Los Angeles, CA
KMAX: Medford, OR
KFSX: Flagstaff, AZ
KGGW: Glasgow, MT
KLRX: Elko, NV
KBHX: Eureka, CA
KTFX: Great Falls, MT
KCBX: Boise, ID
KBLX: Billings, MT
KICX: Salt Lake City, UT
ICAO: Responsible Wfo W/ MSCF
PABC: Anchorage, AK
PAPD: Fairbanks, AK
PHKM: Honolulu, HI
PAHG: Anchorage, AK
PAKC: Anchorage, AK
PAIH: Anchorage, AK
PHMO: Honolulu, HI
PAEC: Fairbanks, AK
TJUA: San Juan, PR
PACG: Juneau, AK
PHKI: Honolulu, HI
PHWA: Honolulu, HI
ICAO: Responsible Wfo W/ MSCF
KFDR: Norman, OK
PGUA: Guam
KBBX: Sacramento, CA
KFDX: Albuquerque, NM
KGWX: Jackson, MS
KDOX: Wakefield, VA
KDYX: San Angelo, TX
KEYX: Las Vegas, NV
KEVX: Mobile, AL
KHPX: Paducah, KY
KTYX: Burlington, VT
KGRK: Dallas / Ft. Worth, TX
KPOE: Lake Charles, LA
KEOX: Tallahassee, FL
KHDX: El Paso, TX
KDFX: San Antonio, TX
KMXX: Birmingham, AL
KMBX: Bismarck, ND
KVAX: Jacksonville, FL
KJGX: Peachtree City/atlanta, GA
KVNX: Norman, OK
KVBX: Vandenberg Afb: Orcutt, CA" | dmenu -r -i -l 50 -p "Select a National Weather Service radar to use as default:" | sed "s/:.*//" | tr "[:lower:]" "[:upper:]")"

# Sanity check of selection and ensure user did not escape.
echo "$chosen" | grep -q "^[A-Z]\+$" && echo "$chosen" > "$radarloc" ;}

getdoppler() {
	loc="$(cat "$radarloc")"
	notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc."
	curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;}

showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;}

case $BLOCK_BUTTON in
	1) [ ! -f "$radarloc" ] && pickloc && getdoppler
	[ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler
	showdoppler ;;
	2) pickloc && getdoppler && showdoppler ;;
	3) notify-send "🗺️ Doppler RADAR module" "\- Left click for local Doppler RADAR.
- Middle click to update change RADAR location.
After $secs seconds, new clicks will also automatically update the doppler RADAR."  ;;
	6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

echo 🗺️