diff --git a/.getardoplist-cron b/.getardoplist-cron index 3c2f7d8..67692fb 100755 --- a/.getardoplist-cron +++ b/.getardoplist-cron @@ -93,13 +93,11 @@ if [ -f $PACKET ]; then rm $PACKET fi -#put date on top line of each file -echo "List Last Downloaded $(date)" >> $FILE -echo "List Last Downloaded $(date)" >> $FORTY -echo "List Last Downloaded $(date)" >> $EIGHTY -echo "List Last Downloaded $(date)" >> $TWENTY -echo "List Last Downloaded $(date)" >> $THIRTY -echo "List Last Downloaded $(date)" >> $PACKET +#create file that has grid variable used in calculations +touch $HOME/patmenu2/ardop-list/grid.txt +MYGRID=$(grep locator $HOME/.config/pat/config.json | sed 's/.*": //;s/"//g;s/,//') +echo "GRID=$MYGRID" > $HOME/patmenu2/ardop-list/grid.txt +echo "LASTDL=List downloaded `date`" >> $HOME/patmenu2/ardop-list/grid.txt #download list to individual files. DL(){ diff --git a/FA-functions b/FA-functions index a04e76d..6d7fc00 100644 --- a/FA-functions +++ b/FA-functions @@ -296,6 +296,9 @@ xdg-open $MAP #-------------------------------- # Alternate Grid Download #-------------------------------- + +#THIS FUNCTION DEPRECATED BUT LEFT FOR REFERENCE 11MARCH2022 + #make new dir in pat menu dir if needed mkdir -p $HOME/patmenu2/alt-ardop-list @@ -355,6 +358,10 @@ exit #-------------------------------- # Load Alternate Grid List #-------------------------------- + +#THIS FUNCTION DEPRECATED BUT LEFT FOR REFERENCE 11MARCH2022 + + LOADALTGRID(){ OUTFILE=/run/user/$UID/alt-grid.list @@ -411,7 +418,122 @@ $MAIN & exit } - +#-------------------------------- +# Recalculate Distance & Bearings +#-------------------------------- + +NEWCALC(){ +#Function to update the distance and bearing between +#your current grid and the winlink gateways. +#this is necessary because the calculations are initially +#based on the grid in the pat config file at the time the +#list is downloaded. +#10MARCH2022 KM4ACK + +DIR=/run/user/$UID +TMPFILE=$DIR/tempfile +TMPFILE2=$DIR/tempfile2 +TMPFILE3=$DIR/tempfile3 +MYGRID=$(cat /run/user/$UID/gridinfo.txt | cut -c1-6) + +#backup current lists +BKDIR=$MYPATH/ardop-list/bkup-`date +%F.%H%M` +mkdir -p $BKDIR +cp -r $HOME/patmenu2/ardop-list/*.txt $BKDIR/ + +MYGRID=$(yad --form --width=450 --text="Recalculate Distance and Bearings to Gateways\rThis takes 2-3 minutes to complete" \ +--text-align=center --center --title="Recalculate" --text-align=center --separator="|" --item-separator="|" \ +--image=$LOGO --window-icon=$LOGO --image-on-top \ +--field="Current Grid Square" "$MYGRID" \ +--button="Recalculate":2 \ +--button="Cancel":1) +BUT=$? +MYGRID=`echo $MYGRID | awk -F "|" '{print $1}'` + +if [ $BUT = 252 ]; then +exit +elif [ $BUT = 1 ]; then +$MAIN & +exit +fi + +#create file that has grid variable used in calculations +touch $HOME/patmenu2/ardop-list/grid.txt +echo "GRID=$MYGRID" > $HOME/patmenu2/ardop-list/grid.txt +echo "LASTDL=Recalculated `date`" >> $HOME/patmenu2/ardop-list/grid.txt + +MAIN(){ +echo "Recalculating 20M List" +RECALC 20mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 20M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating 30M List" +RECALC 30mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 30M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating 40M List" +RECALC 40mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 40M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating 80M List" +RECALC 80mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 80M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating Packet list" +RECALC packet.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating Packet List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +yad --center --timeout=2 --timeout-indicator=top --no-buttons --text="New Calculations Complete" +} + +RECALC(){ +FILE=$HOME/patmenu2/ardop-list/$1 +#check for and remove existing temp file +if [ -f $TMPFILE3 ]; then +rm $TMPFILE3 +fi + +#create temp list to work with and remove headers/blank lines +cp $FILE $TMPFILE +sed -i 's/.*information...//;s/.*succeeded.//;s/.*url//' $TMPFILE +sed -i '/^$/d' $TMPFILE + + + +#read file, calculate new distance, and update +while read LINE; +do +GRID=`echo $LINE | awk '{print $2}' | sed 's/\[//;s/\]//'` +DISTANCE=`echo $LINE | awk '{print $3 }'` +BEARING=`echo $LINE | awk '{print $4 }'` +CALC=`/usr/bin/wwl $MYGRID $GRID` +NEWDISTANCE=`echo $CALC | awk '{print $2}'` +NEWBEARING=`echo $CALC | awk '{print $5}'` +echo $LINE | sed "s/$DISTANCE/$NEWDISTANCE/;s/$BEARING/$NEWBEARING/" >> $TMPFILE2 +done < $TMPFILE +rm $TMPFILE + +#pad distance with zeros for sorting +while read LINE + do + DISTANCE=$(echo $LINE | awk '{ print $3 }') + NEWDISTANCE=$(echo $LINE | awk '{ print $3 }' | sed -e :a -e 's/^.\{1,4\}$/0&/;ta') + echo $LINE | sed "s/$DISTANCE/$NEWDISTANCE/" >> $TMPFILE3 +done < $TMPFILE2 +rm $TMPFILE2 + +#sort list by distance +sort -k3 -o $TMPFILE3 $TMPFILE3 + +cp $TMPFILE3 $HOME/patmenu2/ardop-list/$1 +} + +#call main function +MAIN +#return to pat menu +$MAIN + +} diff --git a/changelog b/changelog index 31a349c..a7a74b6 100644 --- a/changelog +++ b/changelog @@ -1,7 +1,16 @@ -release=2.7.0 - +release=2.8.0 Changelog +2.8.0 redesign layout of main screen + add new modem menu + add vara modem start (beta) + add vara FM modem start (beta) + deprecate alternate grid list download function + deprecate load alternate grid funtion + add gateway distance/bearing recalculation + add "save as" to current config file see https://github.com/km4ack/patmenu2/issues/48 + add config file name to bottom of main menu + update menu shortcut to support non-pi usernames 2.7.0 add mobi-pair script to assist with pairing mobilinkd devices add mobilinkd wired modem connection (Doesn't work with version 2) improve mobilinkd modem start diff --git a/find2 b/find2 index e9fbb75..59f3130 100755 --- a/find2 +++ b/find2 @@ -4,18 +4,13 @@ #20200425 KM4ACK #side note: written during covid-19 outbreak of 2020 -#######DEV NOTES############# -############################# - - -############################# - MYPATH=$HOME/patmenu2 PATMENU=$MYPATH/patmenu LOGO=$MYPATH/pmlogo.png CURRENT=$(crontab -l | grep getardoplist | awk '{print $2":"$1}') source $MYPATH/.grid -GRID=$GRID +GRID=$(grep GRID $HOME/patmenu2/ardop-list/grid.txt | sed 's/GRID=//') +LASTDOWNLOAD=$(grep LASTDL $HOME/patmenu2/ardop-list/grid.txt | tail -1 | sed 's/LASTDL=//') source $MYPATH/FA-functions @@ -24,12 +19,11 @@ yad --form --width=480 --text="Find Gateways by KM4ACK" --text-align=cent --text="Find Gateways by KM4ACK" \ --field="Search for Gateway":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; GRIDSEARCH"' \ --field="View Grid Map":fbtn 'bash -c "source $MYPATH/FA-functions; MAP"' \ ---field="Download Home Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; DOWNLIST"' \ ---field="Download Alternate Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; ALTGRID"' \ ---field="Load Alternate Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; LOADALTGRID"' \ ---field="Auto Download Home Grid List $CURRENT":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; AUTODOWN"' \ ---field="Home $LASTDL":LBL \ ---field="Grid List Currently Loaded $GRID":LBL \ +--field="Download Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; DOWNLIST"' \ +--field="Auto Download Gateway List $CURRENT":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; AUTODOWN"' \ +--field="Recalculate Distance and Bearings":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; NEWCALC"' \ +--field="$LASTDOWNLOAD":LBL \ +--field="Current calculations based on grid $GRID":LBL \ --button="Main Menu":1 QUIT=$? @@ -39,4 +33,9 @@ $PATMENU & exit elif [ $QUIT = 252 ]; then exit -fi \ No newline at end of file +fi + + +#left for reference +#--field="Download Alternate Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; ALTGRID"' \ +#--field="Load Alternate Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/FA-functions; LOADALTGRID"' \ diff --git a/getardoplist b/getardoplist index 05f4c3f..f24ecd2 100755 --- a/getardoplist +++ b/getardoplist @@ -87,15 +87,13 @@ if [ -f $PACKET ]; then rm $PACKET fi -#put date on top line of each file -echo "List Last Downloaded $(date)" >> $FILE -echo "List Last Downloaded $(date)" >> $FORTY -echo "List Last Downloaded $(date)" >> $EIGHTY -echo "List Last Downloaded $(date)" >> $TWENTY -echo "List Last Downloaded $(date)" >> $THIRTY -echo "List Last Downloaded $(date)" >> $PACKET -#yad --center --progress --pulsate --timeout-indicator=top --auto-close --no-buttons --text="Start Download" +#create file that has grid variable used in calculations +touch $HOME/patmenu2/ardop-list/grid.txt +MYGRID=$(grep locator $HOME/.config/pat/config.json | sed 's/.*": //;s/"//g;s/,//') +echo "GRID=$MYGRID" > $HOME/patmenu2/ardop-list/grid.txt +echo "LASTDL=List downloaded `date`" >> $HOME/patmenu2/ardop-list/grid.txt + #download list to individual files. DL(){ diff --git a/manage-menu-functions b/manage-menu-functions index 484837c..e783026 100644 --- a/manage-menu-functions +++ b/manage-menu-functions @@ -147,6 +147,7 @@ elif [ $BUT = 2 ]; then exit else cp $MYPATH/$NEWCONFIG $MYPATH/config + echo "CONF=$NEWCONFIG" > $MYPATH/.currentconf #write config file name to a file rm $OUTFILE yad --title="Config Loaded" --width=400 --height=200 \ --image $LOGO --window-icon=$LOGO --image-on-top \ @@ -206,9 +207,11 @@ SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu --field="AmRRON":CB "$AMRRON" \ --field="Custom Warning":CB "$WARN" \ --field="Warning Message" "$WARNMSG" \ +--button="Save As":3 \ --button="Update":2 \ --button="Cancel":1) BUT=$? + if [ $BUT = 1 ]; then $MAIN elif [ $BUT = 252 ]; then @@ -253,6 +256,30 @@ cp $CONFIGTMP $CONFIG rm $CONFIGTMP $MAIN & exit +elif [ $BUT = 3 ]; then +NEWNAME=$(yad --form --width=600 --text-align=center --center --title="Name?" --text-align=center \ +--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \ +--text="Pat Menu Settings by KM4ACK" \ +--field="New Config Name") +BUT=$? +if [ $BUT = 1 ]; then +$MAIN & exit +elif [ $BUT = 252 ]; then +exit +fi + +NEWNAME=$(echo $NEWNAME | awk -F "|" '{print $1}') +NEWNAME=$NEWNAME.config #add .config to filename +NEWNAME=$(echo $NEWNAME | sed 's/ /-/g') #remove spaces in file name + +cp $CONFIG $HOME/patmenu2/$NEWNAME + +yad --title="Config Created" --width=400 --height=200 \ +--image $LOGO --window-icon=$LOGO --image-on-top \ +--center --text="$NEWNAME created\r\rDon't forget to load the new config file" \ +--button=gtk-ok +$MAIN & +exit fi } diff --git a/modems b/modems new file mode 100755 index 0000000..4b578ff --- /dev/null +++ b/modems @@ -0,0 +1,33 @@ +#!/bin/bash + +#Pat Modems +#20220309 KM4ACK + + + +export MYPATH=$HOME/patmenu2 +LOGO=$MYPATH/pmlogo.png +MAIN=$MYPATH/./patmenu +VERSION=$(cat $MYPATH/changelog | grep release | head -1 | sed 's/release=//') + +source $MYPATH/config + + + +yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-align=center \ +--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \ +--text="Pat Menu by KM4ACK\rv$VERSION" \ +--field="Start ARDOP Modem":fbtn 'bash -c "$MYPATH/start-pat-ardop"' \ +--field="Start Packet Modem":fbtn 'bash -c "$MYPATH/start-pat2m"' \ +--field="Start Mobilinkd Modem Bluetooth":fbtn 'bash -c "$MYPATH/mobilink"' \ +--field="Start Mobilinkd Modem Wired":fbtn 'bash -c "$MYPATH/mobi-wired"' \ +--field="Start VARA Modem (BETA)":fbtn 'bash -c "$MYPATH/start-vara-hf"' \ +--field="Start VARA FM Modem (BETA)":fbtn 'bash -c "$MYPATH/start-vara-fm"' \ +--field="Stop Modems":fbtn 'bash -c "$MYPATH/stop-modems"' \ +--button="Main Menu":1 +BUT=$? + +if [ $BUT = 1 ]; then +$MAIN & +exit +fi \ No newline at end of file diff --git a/patmenu b/patmenu index e5be81a..0f51b3d 100755 --- a/patmenu +++ b/patmenu @@ -1,6 +1,6 @@ #!/bin/bash -#Pat Catalog +#Pat Menu #20200427 KM4ACK #side note: written during covid-19 outbreak of 2020 @@ -41,14 +41,17 @@ yad --title="N0CALL" --width=400 --height=100 \ --button=gtk-ok fi +#get name of current config file +source $MYPATH/.currentconf +CONFIG=$(echo $CONF | sed 's/.config//') +if [ -z $CONFIG ]; then +CONFIG=default +fi + yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-align=center \ --image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \ --text="Pat Menu by KM4ACK\rv$VERSION" \ ---field="Start ARDOP Modem":fbtn 'bash -c "$MYPATH/start-pat-ardop"' \ ---field="Start Packet Modem":fbtn 'bash -c "$MYPATH/start-pat2m"' \ ---field="Start Mobilinkd Modem Bluetooth":fbtn 'bash -c "$MYPATH/mobilink"' \ ---field="Start Mobilinkd Modem Wired":fbtn 'bash -c "$MYPATH/mobi-wired"' \ ---field="Stop Modems":fbtn 'bash -c "$MYPATH/stop-modems"' \ +--field="Start/Stop Modem":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/modems"' \ --field="Find Winlink Gateways":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/find2"' \ --field="Pat Auto Connect":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/pat-functions; AUTOPAT"' \ --field="Pat Catalog":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/catalog"' \ @@ -58,6 +61,7 @@ yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-al --field="Settings/Config":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/manage-menu"' \ --field="Quick Stats":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/pat-functions; STATS"' \ --field="My Call - $MYCALLSIGN":LBL \ +--field="Config=$CONFIG":LBL \ --button="QUIT":1 BUT=$? diff --git a/setup b/setup index 9c89f5a..d22326a 100644 --- a/setup +++ b/setup @@ -38,8 +38,19 @@ rm -rf $HOME/patmenu fi -#copy new desktop link -sudo cp $MYPATH/patmenu2.desktop /usr/share/applications/patmenu.desktop +#create new desktop link +cat < /run/user/$UID/patmenu.desktop +[Desktop Entry] +Name=Pat Menu +GenericName=Amateur Radio Digital Modem +Comment=Amateur Radio Sound Card Communications +Exec=/home/`whoami`/patmenu2/patmenu +Icon=/home/`whoami`/patmenu2/pmlogo.png +Terminal=false +Type=Application +Categories=Network;HamRadio; +EOF +sudo cp /run/user/$UID/patmenu.desktop /usr/share/applications/patmenu.desktop #download RMS List $MYPATH/getardoplist diff --git a/start-vara-fm b/start-vara-fm new file mode 100755 index 0000000..c6378d4 --- /dev/null +++ b/start-vara-fm @@ -0,0 +1,134 @@ +#!/bin/bash + +#script to start vara fm modem +#10MARCH2022 KM4ACK + +MYPATH=$HOME/patmenu2 +LOGO=$MYPATH/pmlogo.png +source $MYPATH/config + +#Check if FLRIG is running if user has it set in config file +if [ "$RIGCONTROL" = 'yes' ]; then +echo "rig control is on" +FLRIG=$(echo $RIG | grep "\-m 4") + if [ ! -z "$FLRIG" ]; then + FLRIG=$(pidof flrig) + if [ -z "$FLRIG" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="Please start FLRIG and try again" \ + --button=gtk-ok + exit + fi + fi +fi + +#Check if modem is already running +MODEMCHECK=$(ps aux | grep -i box86 | grep -i varafm) + if [ ! -z "$MODEMCHECK" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="Packet Modem is already running" \ + --button=gtk-ok + exit + fi + +#check if piardopc is running +PIDDW=$(pidof piardopc) + if [ ! -z "$PIDDW" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="It looks like the ARDOP modem is running.\rStop all modems and try again" \ + --button=gtk-ok + exit 0 + fi + +#check if direwolf is running +PIDDW=$(pidof direwolf) + if [ ! -z "$PIDDW" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="It looks like direwolf is running.\rStop all modems and try again" \ + --button=gtk-ok + exit 0 + fi + +#give user some feedback +yad --width=350 --height=75 --title="Starting Modem" --timeout=20 --timeout-indicator=top --no-buttons --center \ +--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --text="Modem Starting....standby" & + +#Set Mode +RIGFM=$RIG" M $MODE2M" + +SETRIG () { + +#set radio frequency & mode +$RIGFM + +sleep 1 + +#check rig is in correct mode +MODE=$($RIG m | grep $MODE2M) + +sleep 1 + + MODECHECK() { + #check rig is in correct mode + MODE=$($RIG m | grep $MODE2M) + } + +sleep 1 + + if [ -z $MODE ] + then + $RIGFM + MODECHECK + fi +} + + +#see if rig control is used +if [ $RIGCONTROL == 'yes' ]; then +PIDCTL=$(pidof rigctld) + if [ -z "$PIDCTL" ]; then + CONTROL=$(cat $MYPATH/config | grep '^RIG="' | sed 's/RIG="//' | sed 's/"//' | sed 's/rigctl/rigctld/') + $CONTROL & + rigpid=`echo $!` + fi +SETRIG +fi + +echo "starting VARA-FM" +/usr/local/bin/wine /home/pi/.wine/drive_c/VARA\ FM/VARAFM.exe > /dev/null 2>&1 & +sleep 7 #give vara time to start + +#verify vara has started +PIDVARA=$(ps aux | grep -i box86 | grep -i varafm) +if [ -z "$PIDVARA" ] +then +yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="The VARA Modem FAILED to Start" \ + --button=gtk-ok + +else + +yad --title="VARA MODEM" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \ + --center --form --text="\r\r\r\rThe VARA Modem has Started\rJust a few more seconds" \ + --button=gtk-ok & +fi + +sleep 1 +#restart pat so terminal window correctly reflects rig control +sudo systemctl restart pat@`whoami` + +echo "starting browser" +#open pat inbox in browser +export DISPLAY=:0 && xdg-open http://127.0.0.1:$PORT > /dev/null 2>&1 + +#echo "cleaning up and closing" +#varapid=`ps aux | grep -i box86 | grep -i varafm` +#kill $varapid > /dev/null 2>&1 +#kill $rigpid > /dev/null 2>&1 + diff --git a/start-vara-hf b/start-vara-hf new file mode 100755 index 0000000..937d1b1 --- /dev/null +++ b/start-vara-hf @@ -0,0 +1,134 @@ +#!/bin/bash + +#script to start vara hf modem +#10MARCH2022 KM4ACK + +MYPATH=$HOME/patmenu2 +LOGO=$MYPATH/pmlogo.png +source $MYPATH/config + +#Check if FLRIG is running if user has it set in config file +if [ "$RIGCONTROL" = 'yes' ]; then +echo "rig control is on" +FLRIG=$(echo $RIG | grep "\-m 4") + if [ ! -z "$FLRIG" ]; then + FLRIG=$(pidof flrig) + if [ -z "$FLRIG" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="Please start FLRIG and try again" \ + --button=gtk-ok + exit + fi + fi +fi + +#Check if modem is already running +MODEMCHECK=$(ps aux | grep -i box86 | grep -i varafm) + if [ ! -z "$MODEMCHECK" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="Packet Modem is already running" \ + --button=gtk-ok + exit + fi + +#check if piardopc is running +PIDDW=$(pidof piardopc) + if [ ! -z "$PIDDW" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="It looks like the ARDOP modem is running.\rStop all modems and try again" \ + --button=gtk-ok + exit 0 + fi + +#check if direwolf is running +PIDDW=$(pidof direwolf) + if [ ! -z "$PIDDW" ]; then + yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="It looks like direwolf is running.\rStop all modems and try again" \ + --button=gtk-ok + exit 0 + fi + +#give user some feedback +yad --width=350 --height=75 --title="Starting Modem" --timeout=20 --timeout-indicator=top --no-buttons --center \ +--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --text="Modem Starting....standby" & + +#Set Mode +RIGFM=$RIG" M $MODEHF" + +SETRIG () { + +#set radio frequency & mode +$RIGFM + +sleep 1 + +#check rig is in correct mode +MODE=$($RIG m | grep $MODE2M) + +sleep 1 + + MODECHECK() { + #check rig is in correct mode + MODE=$($RIG m | grep $MODE2M) + } + +sleep 1 + + if [ -z $MODE ] + then + $RIGFM + MODECHECK + fi +} + + +#see if rig control is used +if [ $RIGCONTROL == 'yes' ]; then +PIDCTL=$(pidof rigctld) + if [ -z "$PIDCTL" ]; then + CONTROL=$(cat $MYPATH/config | grep '^RIG="' | sed 's/RIG="//' | sed 's/"//' | sed 's/rigctl/rigctld/') + $CONTROL & + rigpid=`echo $!` + fi +SETRIG +fi + +echo "starting VARA-FM" +/usr/local/bin/wine /home/pi/.wine/drive_c/VARA/VARA.exe > /dev/null 2>&1 & +sleep 7 #give vara time to start + +#verify vara has started +PIDVARA=$(ps aux | grep -i box86 | grep VARA.exe) +if [ -z "$PIDVARA" ] +then +yad --title="FAILED" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ + --center --form --text="The VARA Modem FAILED to Start" \ + --button=gtk-ok + +else + +yad --title="VARA MODEM" --width=400 --height=100 \ + --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \ + --center --form --text="\r\r\r\rThe VARA Modem has Started\rJust a few more seconds" \ + --button=gtk-ok & +fi + +sleep 1 +#restart pat so terminal window correctly reflects rig control +sudo systemctl restart pat@`whoami` + +echo "starting browser" +#open pat inbox in browser +export DISPLAY=:0 && xdg-open http://127.0.0.1:$PORT > /dev/null 2>&1 + +#echo "cleaning up and closing" +#varapid=`ps aux | grep -i box86 | grep VARA.exe` +#kill $varapid > /dev/null 2>&1 +#kill $rigpid > /dev/null 2>&1 +