1
0
mirror of https://github.com/km4ack/patmenu2.git synced 2025-05-16 14:50:13 -07:00
patmenu2/pat-functions
2021-04-04 06:33:22 -05:00

199 lines
5.5 KiB
Plaintext

MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/./patmenu
AUTOPAT(){
source $MYPATH/config
if [ $RIGCONTROL == 'no' ]
then
yad --title="NO RIG CONTROL" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="\r\r\r\rRig Control is needed for auto pat.\rPlease configure rig control and try again. \
\rRig control can be configured using\r<b>Manage Pat Menu</b>"
--button=gtk-ok
$MAIN &
exit
fi
MIN="50|100|150|200|250|300|350|400|450|500|550|600|650|700|750|800|850|900|950|1000"
MAX="500|550|600|650|700|750|800|850|900|950|1000|1500|2000|2500|3000"
INFO=$(yad --form --width=420 --text-align=center --center --title="Pat Auto" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Auto Connect</b> by KM4ACK" \
--field="Band":CB "20|30|40|80" \
--field="Minimum Distance":CBE "$MIN" \
--field="Maximum Distance":CBE "$MAX" \
--button="Start Connection":2 \
--button="Cancel":1)
BUT=$?
if [ "$BUT" = 1 ]; then
$MAIN
exit
fi
BAND=$(echo $INFO | awk -F "|" '{print $1}')
MIN=$(echo $INFO | awk -F "|" '{print $2}')
MAX=$(echo $INFO | awk -F "|" '{print $3}')
if [ -z "$MIN" ]; then
MIN=0
fi
if [ -z "$MAX" ]; then
MAX=0
fi
if [ "$MIN" -gt "$MAX" ]; then
yad --form --width=420 --text-align=center --center --title="Pat Auto" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Auto Connect</b> by KM4ACK \r\rMinimum distance can't be greater\rthan maximum distance.\rTry again" \
--button=gtk-ok
AUTOPAT
fi
echo "Band = $BAND"
echo "MIN = $MIN"
echo "MAX = $MAX"
lxterminal -e $MYPATH/autopat $MAX $BAND $MIN
$MAIN
}
SETTINGS(){
source $MYPATH/config
CONFIGTMP=$MYPATH/config.temp
CONFIG=$MYPATH/config
SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu Settings" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu Settings</b> by KM4ACK" \
--field="Call Sign" "$MYCALLSIGN" \
--field="MAP":CB "usa|world" \
--field="Rig Control":CB "no|yes" \
--field="ARDOP Command" "$ARDOP" \
--field="ARDOP GUI Command" "$ARDOPGUI" \
--field="Direwolf Command" "$DIREWOLF" \
--field="KISS Command" "$KISS" \
--field="AX25 Port" "$AXP" \
--field="Rig Control Command" "$RIG" \
--field="HF Mode for Radio" "$MODEHF" \
--field="2M Mode for Radio" "$MODE2M" \
--field="Pat Port" "$PORT" \
--field="Log File Location" "$LOG" \
--field="AmRRON":CB "no|yes" \
--button="Update":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 1 ]; then
$MAIN
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
MYCALLSIGN=$(echo $SETTINGS | awk -F "|" '{print $1}')
MAP=$(echo $SETTINGS | awk -F "|" '{print $2}')
RIGCONTROL=$(echo $SETTINGS | awk -F "|" '{print $3}')
ARDOP=$(echo $SETTINGS | awk -F "|" '{print $4}')
ARDOPGUI=$(echo $SETTINGS | awk -F "|" '{print $5}')
DIREWOLF=$(echo $SETTINGS | awk -F "|" '{print $6}')
KISS=$(echo $SETTINGS | awk -F "|" '{print $7}')
AXP=$(echo $SETTINGS | awk -F "|" '{print $8}')
RIG=$(echo $SETTINGS | awk -F "|" '{print $9}')
MODEHF=$(echo $SETTINGS | awk -F "|" '{print $10}')
MODE2M=$(echo $SETTINGS | awk -F "|" '{print $11}')
PORT=$(echo $SETTINGS | awk -F "|" '{print $12}')
LOG=$(echo $SETTINGS | awk -F "|" '{print $13}')
AMRRON=$(echo $SETTINGS | awk -F "|" '{print $14}')
echo "#Config file for Pat Menu" > $CONFIGTMP
echo "#20200429 KM4ACK" >> $CONFIGTMP
echo "MYCALLSIGN=$MYCALLSIGN" >> $CONFIGTMP
echo "MAP=$MAP" >> $CONFIGTMP
echo "RIGCONTROL=$RIGCONTROL" >> $CONFIGTMP
echo "ARDOP=\"$ARDOP\"" >> $CONFIGTMP
echo "ARDOPGUI=\"$ARDOPGUI\"" >> $CONFIGTMP
echo "DIREWOLF=\"$DIREWOLF\"" >> $CONFIGTMP
echo "KISS=\"$KISS\"" >> $CONFIGTMP
echo "AXP=$AXP" >> $CONFIGTMP
echo "RIG=\"$RIG\"" >> $CONFIGTMP
echo "MODEHF=$MODEHF" >> $CONFIGTMP
echo "MODE2M=$MODE2M" >> $CONFIGTMP
echo "PORT=$PORT" >> $CONFIGTMP
echo "LOG=$LOG" >> $CONFIGTMP
echo "AMRRON=$AMRRON" >> $CONFIGTMP
cp $CONFIGTMP $CONFIG
rm $CONFIGTMP
$MAIN &
exit
fi
}
STATS(){
CONFIG=$HOME/.wl2k/config.json
SMD=/lib/systemd/system/pat@.service
CALL=$(grep mycall $CONFIG | head -1 | sed s'/"mycall": //;s/"//g;s/,//;s/ //g')
GRID=$(grep locator $CONFIG | sed 's/"//g;s/locator://;s/,//;s/ //g')
ARDOPMAX=$(grep -i max $CONFIG | sed 's/"Max":\ //;s/ //g')
PTT=$(grep ptt_ctrl $CONFIG | tail -1 | sed 's/"ptt_ctrl":\ //;s/,//;s/ //g')
PORT=$(grep http_addr $CONFIG | sed 's/^.*0://;s/",//')
RIG=$(grep RIGCONTROL $HOME/patmenu2/config | sed 's/RIGCONTROL=//')
TELNET=$(grep telnet, $SMD)
ARDOP=$(grep ardop, $SMD)
AX25=$(grep ax25, $SMD)
PAT=$(pidof pat)
#Set telnet variable
if [ -n "$TELNET" ]; then
TELNET="telnet,"
fi
#set ardop variable
if [ -n "$ARDOP" ]; then
ARDOP="ardop,"
fi
#set ax25 variable
if [ -n "$AX25" ]; then
AX25="ax25,"
fi
if [ -z "$TELNET" ] && [ -z "$ARDOP" ] && [ -z "$AX25" ]; then
LISTEN="Not Listening"
else
LISTEN="$TELNET$ARDOP$AX25"
fi
#set Pat Variable
if [ -z $PAT ]; then
PAT="Not Running"
else
PAT="Running"
fi
yad --form --width=320 --text-align=center --center --title="Quick Stats" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Quick Stats</b>" \
--field="Current User":RO "$CALL" \
--field="Current Grid":RO "$GRID" \
--field="ARDOP Speed":RO "$ARDOPMAX" \
--field="ARDOP PTT is":RO "$PTT" \
--field="Listen Modes":RO "$LISTEN" \
--field="Rig Control":RO "$RIG" \
--field="Pat Port":RO "$PORT" \
--field="Pat Server":RO "$PAT" \
--button=gtk-ok
$MAIN &
exit
}