mirror of
https://github.com/km4ack/patmenu2.git
synced 2025-05-16 14:50:13 -07:00
287 lines
7.5 KiB
Plaintext
287 lines
7.5 KiB
Plaintext
#functions file for find ardop
|
|
#20200425 km4ack
|
|
|
|
MYPATH=$HOME/patmenu2
|
|
MAIN=$MYPATH/./find2
|
|
CONFIG=$HOME/.wl2k/config.json
|
|
TEMP=$HOME/patmenu2/tempconfig.txt
|
|
TODAY=$(date +%Y%m%d-%R)
|
|
WHO=$(whoami)
|
|
LASTDL=$(cat $MYPATH/ardop-list/ardoplist.txt | head -1)
|
|
LOGO=$MYPATH/pmlogo.png
|
|
|
|
source $MYPATH/config
|
|
|
|
|
|
|
|
#--------------------------------
|
|
# MANUAL Download List
|
|
#--------------------------------
|
|
DOWNLIST(){
|
|
$MYPATH/getardoplist
|
|
$MAIN &
|
|
exit
|
|
}
|
|
|
|
|
|
#--------------------------------
|
|
# AUTO Download List
|
|
#--------------------------------
|
|
AUTODOWN(){
|
|
FILE=/run/user/$UID/cronbkup.txt
|
|
crontab -l > $FILE
|
|
HOURS=00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23
|
|
MINS=00,15,30,45
|
|
|
|
TEST=$(yad --center --wrap --width=350 --title="Auto Download" --text-align=center \
|
|
--text="Please choose the time you would like to download the gateway list everyday" \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top \
|
|
--button="Update:2" \
|
|
--button="Cancel:1" \
|
|
--form --separator="," --item-separator="," \
|
|
--field="Choose the hour":CB $HOURS \
|
|
--field="Choose the minutes":CB $MINS \
|
|
)
|
|
|
|
rc=$?
|
|
if [[ $rc -eq 2 ]]; then
|
|
echo "Updating Cron"
|
|
HOUR=$(echo $TEST | awk -F ',' '{print $1}')
|
|
MIN=$(echo $TEST | awk -F ',' '{print $2}')
|
|
sed -i '/getardoplist/d' $FILE
|
|
echo $MIN" "$HOUR" * * * $MYPATH/.getardoplist-cron" >> $FILE
|
|
crontab $FILE
|
|
echo
|
|
echo "Your crontab has been updated. The gateway list"
|
|
echo "will be downloaded daily at "$HOUR":"$MIN" hours"
|
|
yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Auto Download set for $HOUR:$MIN daily" \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top
|
|
$MAIN &
|
|
rm $FILE
|
|
exit
|
|
elif [[ $rc -eq 1 ]]; then
|
|
echo "BYE"
|
|
$MAIN &
|
|
exit
|
|
fi
|
|
}
|
|
|
|
#--------------------------------
|
|
# GRID SEARCH
|
|
#--------------------------------
|
|
GRIDSEARCH(){
|
|
OUTFILE=/run/user/$UID/tempardoplist.txt
|
|
CONFIG=$HOME/.wl2k/config.json
|
|
TEMP=/run/user/$UID/tempconfig.txt
|
|
ARDOPLIST=$MYPATH/ardop-list
|
|
WHO=$(whoami)
|
|
source $MYPATH/config #patmenu config file
|
|
#check to make sure user has downloaded
|
|
if [ ! -d "$MYPATH/ardop-list/" ]; then
|
|
yad --title="No List" --width=400 --height=100 \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
|
|
--center --form --text="\r\rGateway list has NOT been downloaded.\rPlease download now\rRecommend setting auto download time" \
|
|
--button="Download":2
|
|
BUT=$?
|
|
if [ $BUT = 2 ]; then
|
|
$MYPATH/getardoplist
|
|
$MAIN &
|
|
exit
|
|
elif [ $BUT = 252 ]; then
|
|
exit
|
|
fi
|
|
fi
|
|
SEARCHMENU(){
|
|
#MENU
|
|
BANDS="20|30|40|80|2M-70CM"
|
|
SEARCH=$(yad --form --width=400 --text="<b>Find Winlink Gateways</b>" --text-align=center --center --title="Find ARDOP" --text-align=center \
|
|
--separator="|" --item-separator="|" \
|
|
--image=$LOGO --window-icon=$LOGO --image-on-top \
|
|
--field="Grid to Search" "EM" \
|
|
--field="Band to Search":CB "$BANDS" \
|
|
--button="Search":2 \
|
|
--button="Cancel":1)
|
|
QUIT=$?
|
|
GRID=$(echo $SEARCH | awk -F "|" '{print $1}')
|
|
GRID=$(echo "${GRID^^}")
|
|
BAND=$(echo $SEARCH | awk -F "|" '{print $2}')
|
|
|
|
echo "Grid search is $GRID"
|
|
echo "Band is $BAND"
|
|
|
|
if [ $QUIT = 1 ]; then
|
|
$MAIN &
|
|
exit
|
|
elif [ $QUIT = 252 ]; then
|
|
exit
|
|
fi
|
|
|
|
##############PACKET SEARCH######################
|
|
if [ $QUIT = 2 ] && [ "$BAND" = '2M-70CM' ]; then
|
|
|
|
|
|
#########START TEST SECTION######################
|
|
|
|
|
|
FILE=$MYPATH/ardop-list/packet.txt
|
|
TEMP=/run/user/$UID/temppacket.txt
|
|
TEMP1=/run/user/$UID/templist.txt
|
|
TEMP2=/run/user/$UID/tempalias.txt
|
|
|
|
echo "Grid search is $GRID"
|
|
|
|
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$TEMP" > /dev/null 2>&1
|
|
|
|
|
|
INFO=$(PARSER='OFS="\n" {print $1, $2, $3, $4, $5, $6, $7, $9, $11}'
|
|
MYTEMP=$TEMP2
|
|
tail -1000 $TEMP | awk "$PARSER" | \
|
|
yad --title="Search Results" --width=1100 --height=500 \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top --multiple \
|
|
--center --list --text="Search Results" \
|
|
--column Call --column Grid --column Dist \
|
|
--column Azm --column Mode --column Speed \
|
|
--column Dial-Freq \
|
|
--column Center-Freq --column Shortcut \
|
|
--button=gtk-close \
|
|
--button="Add Alias":2 > $MYTEMP)
|
|
BUT=$?
|
|
|
|
if [ "$BUT" = 2 ];then
|
|
CALL=$(echo $INFO | awk -F "|" '{print $1}')
|
|
SC=$(echo $INFO | awk -F "|" '{print $9}')
|
|
FREQ=$(echo $SC | sed 's/.*=//')
|
|
if [ $RIGCONTROL = 'no' ]; then
|
|
SC=$(echo $SC | sed 's/[?].*$//')
|
|
fi
|
|
|
|
while read LINE; do
|
|
CALL=$(echo $LINE | awk -F "|" '{print $1}')
|
|
SC=$(echo $LINE | awk -F "|" '{print $9}')
|
|
FREQ=$(echo $SC | sed 's/.*=//')
|
|
if [ $RIGCONTROL = 'no' ]; then
|
|
SC=$(echo $SC | sed 's/[?].*$//')
|
|
fi
|
|
|
|
SC=$(echo $SC | sed 's/packet/ax25/')
|
|
|
|
jq '.connect_aliases += {'\""$CALL-$BAND"M"-$FREQ"\"' : '\"$SC\"'}' $CONFIG > $TEMP
|
|
cp $TEMP $CONFIG
|
|
rm $TEMP
|
|
done < $TEMP2
|
|
sudo killall pat
|
|
sudo systemctl start pat@$WHO
|
|
|
|
|
|
##############END TEST SECTION################
|
|
|
|
|
|
yad --title="ADDED" --width=300 --height=100 \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top \
|
|
--center --form --text="$CALL-$FREQ added to Pat Winlink\rRefresh Pat Mailbox Window\rto view changes" \
|
|
--button=gtk-ok
|
|
SEARCHMENU
|
|
fi
|
|
SEARCHMENU
|
|
fi
|
|
|
|
#############ARDOP SEARCH####################
|
|
|
|
OUTFILE2=/run/user/$UID/tempardop2.txt
|
|
|
|
if [ $BAND = 20 ];then
|
|
FILE=$ARDOPLIST/20mardoplist.txt
|
|
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
|
|
#cat $OUTFILE | tr -s '[:space:]' | sed 's/ /|/g'| sed 's/[A-Za-z]*$/|/g' > $OUTFILE2
|
|
elif [ $BAND = 30 ];then
|
|
FILE=$ARDOPLIST/30mardoplist.txt
|
|
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
|
|
elif [ $BAND = 40 ];then
|
|
FILE=$ARDOPLIST/40mardoplist.txt
|
|
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
|
|
elif [ $BAND = 80 ];then
|
|
FILE=$ARDOPLIST/80mardoplist.txt
|
|
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
|
|
echo "80 done"
|
|
fi
|
|
|
|
INFO=$(PARSER='OFS="\n" {print $1, $2, $3, $4, $5, $6, $7, $9, $11}'
|
|
MYTEMP=/run/user/$UID/mytemptestardoplist
|
|
tail -50 $OUTFILE | awk "$PARSER" | \
|
|
yad --title="Search Results" --width=1100 --height=500 \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top --multiple \
|
|
--center --list --text="Search Results" \
|
|
--column Call --column Grid --column Dist \
|
|
--column Azm --column Mode --column Speed \
|
|
--column Dial-Freq \
|
|
--column Center-Freq --column Shortcut \
|
|
--button=gtk-close \
|
|
--button="Add Alias":2 > $MYTEMP)
|
|
BUT=$?
|
|
if [ "$BUT" = 2 ];then
|
|
CALL=$(echo $INFO | awk -F "|" '{print $1}')
|
|
SC=$(echo $INFO | awk -F "|" '{print $9}')
|
|
FREQ=$(echo $SC | sed 's/.*=//')
|
|
if [ $RIGCONTROL = 'no' ]; then
|
|
SC=$(echo $SC | sed 's/[?].*$//')
|
|
fi
|
|
|
|
while read LINE; do
|
|
CALL=$(echo $LINE | awk -F "|" '{print $1}')
|
|
SC=$(echo $LINE | awk -F "|" '{print $9}')
|
|
FREQ=$(echo $SC | sed 's/.*=//')
|
|
if [ $RIGCONTROL = 'no' ]; then
|
|
SC=$(echo $SC | sed 's/[?].*$//')
|
|
fi
|
|
jq '.connect_aliases += {'\""$CALL-$BAND"M"-$FREQ"\"' : '\"$SC\"'}' $CONFIG > $TEMP
|
|
cp $TEMP $CONFIG
|
|
rm $TEMP
|
|
done < /run/user/$UID/mytemptestardoplist
|
|
sudo killall pat
|
|
sudo systemctl start pat@$WHO
|
|
|
|
if [ -z "$CALL" ]; then
|
|
yad --title="No Selection" --width=300 --height=100 \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top \
|
|
--center --form --text="No station was selected\r Please try again" \
|
|
--button=gtk-ok
|
|
$MAIN &
|
|
exit
|
|
fi
|
|
|
|
yad --title="ADDED" --width=300 --height=100 \
|
|
--image $LOGO --window-icon=$LOGO --image-on-top \
|
|
--center --form --text="Alias added to Pat Winlink\rRefresh Pat Mailbox Window\rto view changes" \
|
|
--button=gtk-ok
|
|
SEARCHMENU
|
|
fi
|
|
|
|
SEARCHMENU
|
|
}
|
|
SEARCHMENU
|
|
}
|
|
#--------------------------------
|
|
# Open Map
|
|
#--------------------------------
|
|
MAP(){
|
|
|
|
if [ "$MAP" = "usa" ]; then
|
|
MAP=$MYPATH/grid-map.pdf
|
|
elif [ "$MAP" = "world" ]; then
|
|
MAP=$MYPATH/worldgridmap.pdf
|
|
fi
|
|
xdg-open $MAP
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|