#!/bin/bash #scirpt to convert WL2K_NEARBY to POS file #that can be imported into YAAC #KM4ACK 01AUGUST2022 MYPATH=$HOME/patmenu2 LOGO=$MYPATH/pmlogo.png MAIN=$MYPATH/./catalog CONFIG=$HOME/.config/pat/config.json PATCALL=$(grep mycall $HOME/.config/pat/config.json | head -1 | sed 's/"mycall": "//;s/",//;s/ //g') LIST=$HOME/.local/share/pat/mailbox/$PATCALL/in MAILBOX=$HOME/.local/share/pat/mailbox/$PATCALL/in TEMP=/run/user/$UID/temp.search.list ############################################### #ask for file to use ############################################### #search inbox for WL2K_Nearby file to work with for file in ${MAILBOX}/*; do NEARBY=$(grep WL2K_NEARBY $file) if [ -n "$NEARBY" ]; then NCK_FILE=${file} NCK="WL2K_Nearby" break fi done #search inbox for WL2K_Mobile file to work with for file in ${MAILBOX}/*; do MOBILE=$(grep WL2K_MOBILE $file) if [ -n "$MOBILE" ]; then MCK_FILE=${file} MCK="WL2K_Mobile" break fi done #Check if a list was found to work with if [ -z "$MCK" ] && [ -z "$NCK" ]; then NCK="No List Found. Pls Download" fi WL2K_LIST=$(yad --form --width=420 --text-align=center --center --title="Available Lists" \ --image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \ --text="List(s) found in inbox" \ --field="List to Use":CB "$NCK|$MCK") BUT=$? if [ ${BUT} = 1 ]; then $MAIN & exit elif [ ${BUT} = 252 ]; then exit fi CK=$(echo $WL2K_LIST | awk -F "|" '{print $1}') if [ "$CK" = 'WL2K_Nearby' ]; then LIST=${NCK_FILE} elif [ "$CK" = 'WL2K_Mobile' ]; then LIST=${MCK_FILE} elif [ "$CK" = 'No List Found. Pls Download' ]; then $MAIN & exit fi ############################################### #get keyword ############################################### KW=$(yad --form --width=420 --text-align=center --center --title="Keyword" --text-align=center \ --image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \ --text="Enter a Keyword or use\r \leave blank\rto convert every station" \ --field="Keyword to Search For" "" \ --button="Search":2 \ --button="Cancel":1) BUT=$? if [ ${BUT} = 1 ]; then $MAIN & exit elif [ ${BUT} = 252 ]; then exit fi KW=$(echo ${KW} | awk -F "|" '{print $1}') #remove temp files if exist if [ -f ${TEMP} ]; then rm ${TEMP} fi #search file for keyword if [ -z "$KW" ]; then cp ${LIST} /run/user/$UID/no.keyword.list #remove everything but the data we need at the top of the file sed -i '1,19d' /run/user/$UID/no.keyword.list while read -r line; do echo $line >> ${TEMP} done < /run/user/$UID/no.keyword.list else while read -r line; do CK=$(echo ${line} | grep -i "${KW}") if [ -n "${CK}" ]; then echo $line >> ${TEMP} fi done < $LIST fi #verify keyword is found if [ ! -f ${TEMP} ]; then yad --form --width=500 --text-align=center --center --title="ERROR" --text-align=center \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text="Nothing Found\rwith the keyword you chose. Try again" \ --button=gtk-ok $MAIN fi ############################################### #begin output ############################################### #remove exiting file if it exist if [ -f $HOME/Desktop/gateways.pos ]; then rm $HOME/Desktop/gateways.pos fi #give user feedback yad --center --timeout=2 --timeout-indicator=top --no-buttons \ --text="Processing File" & #create a copy to work with cp ${TEMP} /run/user/$UID/tempgatelist ###########NOTE############# #APRS symbol lookup table can be found at #https://4.bp.blogspot.com/-ewK-9I_62wk/WIMI_LFpEII/AAAAAAAAWYA/xMso0AANY649LEWvOAjMIsmyPLWBwOszQCLcB/s1600/KWFAPRS_LUTv2.png #In the echo command below I have used "\a" which produces a red diamond on the map. The "\" goes between the $LAT $LONG and the #second character goes between the $LONG and $Comment #########End Note########### #process the file while read -r line; do CALL=$(echo $line | awk '{print $1}') CALL=`printf "%-9s" $CALL` LAT=$(echo $line | awk '{print $5}' | sed 's/-//') LONG=$(echo $line | awk '{print $6}' | sed 's/-//') COMMENT=$(echo $line | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//') TIME=$(date -u +%H%M%S) #echo ";$CALL*$TIME""h""$LAT/$LONG-$COMMENT" >> ~/Desktop/gateways.pos (Produces a house on the map) echo ";$CALL*$TIME""h""$LAT\\$LONG""a""$COMMENT" >> ~/Desktop/gateways.pos #(Produces a red diamond on the map) done < /run/user/$UID/tempgatelist #let user know processing is finished yad --form --width=500 --text-align=center --center --title="WL2K to ARPS Object" --text-align=center \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text="Processing done.\rA gateways.pos file has been created and\r is on your desktop ready to import into YAAC." \ --button=gtk-ok #remove the temp file rm /run/user/$UID/tempgatelist $MAIN & exit