-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcat-functions
386 lines (321 loc) · 9.48 KB
/
cat-functions
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#function file for patmenu 2 catalog
#20200430 km4ack
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/./catalog
PATCONFIG=$XDG_CONFIG_HOME/pat/config.json
#get callsign from pat config file
CALLSIGN=$(cat $PATCONFIG | grep -m 1 mycall | sed 's/\"mycall\": \"//' | sed 's/\",//' | sed -e 's/^\s*//' | tr '[:lower:]' '[:upper:]')
#COMPOSE EMAIL Function
COMPOSE () {
echo "${BODY}" | pat compose ${TO} -s "$SUBJECT"
#give user some feedback
echo "Your request has been posted to the outbox of Pat Winlink"
echo "Please go to Pat and initiate a connection to send the request"
yad --no-buttons --timeout=5 --center --timeout-indicator=top --title="POSTED" --text-align=center --width="300" height="300" \
--text="Message Posted\rTo Outbox\r\rPlease go to Winlink and\rmake a connection\rto complete the\rrequest."
$MAIN
exit
}
GATEWAY(){
GATE=$(yad --form --width=420 --text-align=center --center --title="Pat Catalog" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Catalog</b> by KM4ACK" \
--field="Gateway List":CB "ARDOP|PACKET")
BUT=$?
if [ $BUT = 252 ]; then
exit
fi
GATE=$(echo $GATE | awk -F "|" '{print $1}')
if [ -z $GATE ]; then
$MAIN &
exit
fi
if [ "$GATE" = ARDOP ]; then
echo ARDOP
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PUB_ARDOP"
COMPOSE
elif [ "$GATE" = PACKET ]; then
echo PACKET
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PUB_PACKET"
COMPOSE
fi
}
WEATHER(){
WEATHER=$(yad --form --width=420 --text-align=center --center --title="Pat Catalog" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Catalog</b> by KM4ACK" \
--field="Weather Report":CB "GPS Weather|City Weather|GRIB Files")
BUT=$?
if [ $BUT = 252 ]; then
exit
fi
WEATHER=$(echo $WEATHER | awk -F "|" '{print $1}')
if [ -z "$WEATHER" ]; then
$MAIN &
exit
fi
if [ "$WEATHER" = 'GPS Weather' ]; then
TMPFILE=/run/user/$UID/gps-data.txt
gpxlogger > $TMPFILE &
CGPSPID=$(echo $!)
sleep 2
kill $CGPSPID
DATA=$(grep lat= $TMPFILE | head -1)
LAT=$(echo $DATA | awk '{print $2}' | sed 's/"//g;s/lat=//')
LONG=$(echo $DATA | awk '{print $3}' | sed 's/"//g;s/lon=//;s/>//')
TO="SMTP:query@saildocs.com"
SUBJECT="<No Subject>"
BODY="https://forecast.weather.gov/MapClick.php?lat="$LAT"&lon="$LONG"&unit=0&lg=english&FcstType=text&TextType=1"
COMPOSE
elif [ "$WEATHER" = 'City Weather' ]; then
FILE=$MYPATH/weather.txt
PARSER='OFS="\n" {print $1, $2, $3}'
CITY=$(tail -76 $FILE | awk "$PARSER" | \
yad --title="Search Results" --width=500 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --checklist --list \
--column Pick --column ID --column Area \
--button="Choose":2)
CITY=$(echo $CITY | awk -F "|" '{print $2}')
if [ -z "$CITY" ]; then
$MAIN &
exit
fi
TO="INQUIRY"
SUBJECT="REQUEST"
BODY=$CITY
COMPOSE
elif [ "$WEATHER" = 'GRIB Files' ]; then
echo "Need GRIB Files"
FILE=/run/user/$UID
QUESTION(){
DEGREE=$(yad --center --wrap --width=350 --title="Auto Download" --text-align=center \
--text="How many degrees would you like" \
--form --separator="|" --item-separator="|" \
--image $LOGO --window-icon=$LOGO --image-on-top \
--field="Degrees":CB "2|6|10" \
--button="Cancel:1" \
--button="Continue:2")
BUT=$?
if [ $BUT = 1 ] || [ -z "$BUT" ]; then
$MAIN &
exit
elif [ $BUT = 252 ]; then
exit
fi
ANS=$(echo $DEGREE | awk -F "|" '{print $1}')
echo $ANS
if [ $ANS = "10" ]; then
AREA=5
echo "aree=5"
elif [ $ANS = "6" ]; then
AREA=3
elif [ $ANS = "2" ]; then
AREA=1
fi
GPS=$(gpspipe -r -n 10 | grep G\.GGA)
LAT=$(echo $GPS | awk -F "," '{printf "%.0f \n", $3 }' | cut -c1-2)
LATD=$(echo $GPS | awk -F "," '{print $4}')
LON=$(echo $GPS | awk -F "," '{printf "%.0f \n", $5 }' | cut -c1-2)
LOND=$(echo $GPS | awk -F "," '{print $6}')
#do some math
let NEWLATADD=$LAT+$AREA
let NEWLONADD=$LON+$AREA
let NEWLATSUB=$LAT-$AREA
let NEWLONSUB=$LON-$AREA
GRIBFILE=$FILE/gribtemp
GRIBDATA () {
yad --height=600 --width=400 --center --list --checklist --column=Request --column=Product --separator="," \
--text "Select the data to request." --title="GRIB DATA REQUEST" \
--button="Exit:1" --button="Request Selected:2" < $MYPATH/griblist > $GRIBFILE
BUTTON=$?
if [ $BUTTON = "252" ]; then
exit
elif [ $BUTTON = "1" ]; then
$MAIN &
exit
fi
#echo "button = "$BUTTON
};export -f GRIBDATA
GRIBDATA
sed -i 's/TRUE,//' $GRIBFILE
var=$(cat $GRIBFILE)
var1=$(echo $var | sed 's/ //g' | sed 's/,*$//')
rm $GRIBFILE
#example of correct format
# send gfs:40N,60N,140W,120W|2,2|24,48,72|PRESS,WIND
TO=query@saildocs.com
SUBJECT=REQUEST
BODY=$(echo "send gfs:"$NEWLATSUB$LATD","$NEWLATADD$LATD","$NEWLONADD$LOND","$NEWLONSUB$LOND"|2,2|24,48,72|"$var1)
COMPOSE
}
QUESTION
exit
fi
exit
}
POSITION(){
POST=$(yad --form --width=420 --text-align=center --center --title="Position" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Position Reports</b> by KM4ACK" \
--field="Choose":CB "Post Position|Single Station Request|All Nearby Stations|100 Mobile Stations" \
--field="Enter Call Below <b>ONLY</b> for Single Station Requests":LBL \
--field="Call Sign-SSID" \
--field="Comment for Post Position" \
--button="Main Menu":1 \
--button="Continue":2)
QUIT=$?
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
REPORT=$(echo $POST | awk -F "|" '{print $1}')
if [ "$REPORT" = "Post Position" ]; then
echo "posting position"
COMMENT=$(echo $POST | awk -F "|" '{print $4}')
pat position -c "$COMMENT" | yad --center --pulsate --progress --auto-close --text="Getting GPS Data" --no-buttons &
yad --center --timeout=3 --timeout-indicator=top --no-buttons \
--text="Position posted to\rPat Winlink Outbox"
$MAIN &
exit
elif [ "$REPORT" = "Single Station Request" ]; then
CALL=$(echo $POST | awk -F "|" '{print $3}')
TO="QTH"
SUBJECT="POSITION REQUEST"
BODY=$CALL
COMPOSE
elif [ "$REPORT" = "All Nearby Stations" ]; then
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="WL2K_NEARBY"
COMPOSE
elif [ "$REPORT" = "100 Mobile Stations" ]; then
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="WL2K_MOBILES"
COMPOSE
fi
}
PROPAGATION(){
PROP=$(yad --form --width=420 --text-align=center --center --title="Propagation" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Propagation Reports</b> by KM4ACK" \
--field="Choose Report":CB "3 Day Propagation Report|Daily WWV Report" \
--button="Main Menu":1 \
--button="Continue":2)
QUIT=$?
REPORT=$(echo $PROP | awk -F "|" '{print $1}')
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
if [ "$REPORT" = "3 Day Propagation Report" ]; then
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PROP_3DAY"
COMPOSE
elif [ "$REPORT" = "Daily WWV Report" ]; then
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PROP_WWV"
COMPOSE
fi
}
NEWS(){
NEWS=$(yad --form --width=420 --text-align=center --center --title="News Reports" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>News Reports</b> by KM4ACK\r\rNews reports provided by Reuters" \
--field="Choose News Report":CB "Daily|Market|Money|US News" \
--button="Main Menu":1 \
--button="Continue":2)
QUIT=$?
NEWS=$(echo $NEWS | awk -F "|" '{print $1}')
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
if [ "$NEWS" = "Daily" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-Daily-News"
COMPOSE
elif [ "$NEWS" = "Market" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-Market"
COMPOSE
elif [ "$NEWS" = "Money" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-Money"
COMPOSE
elif [ "$NEWS" = "US News" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-US-News"
COMPOSE
fi
}
RADAR(){
RADAR=$(yad --form --width=420 --text-align=center --center --title="Radar Reports" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Radar Requests</b>" \
--field="Choose Radar":CB "Southern Miss Valley|Pacific Northwest|North Rockies|Upper Miss Valley|Central Great Lakes|Northeast|\
Pacific Southwest|Southern Rockies|Southern Plains|Southeast|National|Alaska|Hawaii|Guam|Puerto Rico" \
--button="Main Menu":1 \
--button="Continue":2)
QUIT=$?
RADAR=$(echo $RADAR | awk -F "|" '{print $1}')
TO=INQUIRY
SUBJECT=REQUEST
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
case $RADAR in
"Southern Miss Valley")
BODY=US.RAD.SMVAL;;
"Pacific Northwest")
BODY=US.RAD.PNW;;
"North Rockies")
BODY=US.RAD.NROC;;
"Upper Miss Valley")
BODY=US.RAD.UMVAL;;
"Central Great Lakes")
BODY=US.RAD.GRLAK;;
"Northeast")
BODY=US.RAD.NEAST;;
"Pacific Southwest")
BODY=US.RAD.PACSW;;
"Southern Rockies")
BODY=US.RAD.SROC;;
"Southern Plains")
BODY=US.RAD.SPLA;;
"Southeast")
BODY=US.RAD.SEAST;;
"National")
BODY=US.RAD.CONUS;;
"Alaska")
BODY=US.RAD.ALASK;;
"Hawaii")
BODY=US.RAD.HAWAI;;
"Guam")
BODY=US.RAD.GUAM;;
"Puerto Rico")
BODY=US.RAD.PR;;
esac
COMPOSE
}