mirror of
https://github.com/AG7GN/nexus-utilities.git
synced 2025-05-18 23:40:10 -07:00
Added script to edit pat connection aliases
This commit is contained in:
parent
9982371a4d
commit
4b3ad7fff9
@ -1,6 +1,6 @@
|
|||||||
# Hampi Utilities
|
# Hampi Utilities
|
||||||
|
|
||||||
VERSION 2020502
|
VERSION 2020508
|
||||||
|
|
||||||
AUTHOR: Steve Magnuson, AG7GN
|
AUTHOR: Steve Magnuson, AG7GN
|
||||||
|
|
||||||
@ -98,6 +98,10 @@ If `DO_NOT_DELETE_THIS_FILE` is present in the home folder, the script exits wit
|
|||||||
|
|
||||||
`dw_pat_gui.sh` provides a GUI to configure the Direwolf TNC and [pat](https://getpat.io/) to make a functional Winlink email client on Hampi. It also provides a monitor window that shows messages from both Direwolf and pat.
|
`dw_pat_gui.sh` provides a GUI to configure the Direwolf TNC and [pat](https://getpat.io/) to make a functional Winlink email client on Hampi. It also provides a monitor window that shows messages from both Direwolf and pat.
|
||||||
|
|
||||||
|
In the __Configure pat__ tab, there's a button that brings up a window that allows you to search for RMS gateway stations (the output of the `pat rmslist` command) and add them to pat's connection alias list. These aliases are available in a dropdown in the pat web interface __Connection__ dialog.
|
||||||
|
|
||||||
|
pat has a restriction in that if you include a frequency in an connection alias, you must also run `rigctld` while running pat. [Hamlib]((http://hamlib.sourceforge.net/manuals/hamlib.html)), which provides `rigctld`, is already installed in Hampi. If you don't already run rigctl, this configuration gui will configure `rigctld` to use a "dummy" rig to fool pat into thinking it's talking to your radio via `rigctld`. Note that when `rigctld` is used with a "dummy" radio, you must manually set your radio to the desired frequency.
|
||||||
|
|
||||||
## TNC Script
|
## TNC Script
|
||||||
|
|
||||||
`tnc.sh` launches Direwolf and, optionally, other related apps in different modes. The script will look for [tnc.conf](#tnc-left-tnc-right-configuration-files) in the user's home directory. You can optionally override this behavior and specify the name and location of the configuration file using the '-c' parameter.
|
`tnc.sh` launches Direwolf and, optionally, other related apps in different modes. The script will look for [tnc.conf](#tnc-left-tnc-right-configuration-files) in the user's home directory. You can optionally override this behavior and specify the name and location of the configuration file using the '-c' parameter.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#%
|
#%
|
||||||
#% DESCRIPTION
|
#% DESCRIPTION
|
||||||
#% This script provides a GUI to configure and start/stop
|
#% This script provides a GUI to configure and start/stop
|
||||||
#% Direwolf. It is designed to work on the Hampi image.
|
#% Direwolf and pat. It is designed to work on the Hampi image.
|
||||||
#%
|
#%
|
||||||
#% OPTIONS
|
#% OPTIONS
|
||||||
#% -h, --help Print this help
|
#% -h, --help Print this help
|
||||||
@ -15,7 +15,7 @@
|
|||||||
#%
|
#%
|
||||||
#================================================================
|
#================================================================
|
||||||
#- IMPLEMENTATION
|
#- IMPLEMENTATION
|
||||||
#- version ${SCRIPT_NAME} 1.2.0
|
#- version ${SCRIPT_NAME} 1.3.7
|
||||||
#- author Steve Magnuson, AG7GN
|
#- author Steve Magnuson, AG7GN
|
||||||
#- license CC-BY-SA Creative Commons License
|
#- license CC-BY-SA Creative Commons License
|
||||||
#- script_id 0
|
#- script_id 0
|
||||||
@ -23,6 +23,7 @@
|
|||||||
#================================================================
|
#================================================================
|
||||||
# HISTORY
|
# HISTORY
|
||||||
# 20200428 : Steve Magnuson : Script creation.
|
# 20200428 : Steve Magnuson : Script creation.
|
||||||
|
# 20200507 : Steve Magnuson : Bug fixes
|
||||||
#
|
#
|
||||||
#================================================================
|
#================================================================
|
||||||
# DEBUG OPTION
|
# DEBUG OPTION
|
||||||
@ -48,6 +49,7 @@ function TrapCleanup() {
|
|||||||
do
|
do
|
||||||
kill $P >/dev/null 2>&1
|
kill $P >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
kill $RIG_PID >/dev/null 2>&1
|
||||||
sudo pkill kissattach >/dev/null 2>&1
|
sudo pkill kissattach >/dev/null 2>&1
|
||||||
rm -f /tmp/kisstnc
|
rm -f /tmp/kisstnc
|
||||||
rm -f $PIPE
|
rm -f $PIPE
|
||||||
@ -152,7 +154,7 @@ function loadSettings () {
|
|||||||
KISSPORT="${F[_KISSPORT_]}"
|
KISSPORT="${F[_KISSPORT_]}"
|
||||||
|
|
||||||
# Create a Direwolf config file with these settings
|
# Create a Direwolf config file with these settings
|
||||||
cat >> $DW_CONFIG <<EOF
|
cat > $DW_CONFIG <<EOF
|
||||||
ADEVICE ${F[_ADEVICE_CAPTURE_]} ${F[_ADEVICE_PLAY_]}
|
ADEVICE ${F[_ADEVICE_CAPTURE_]} ${F[_ADEVICE_PLAY_]}
|
||||||
ACHANNELS 1
|
ACHANNELS 1
|
||||||
CHANNEL 0
|
CHANNEL 0
|
||||||
@ -285,6 +287,15 @@ do
|
|||||||
done
|
done
|
||||||
shift $((${OPTIND} - 1)) ## shift options
|
shift $((${OPTIND} - 1)) ## shift options
|
||||||
|
|
||||||
|
# Check for required apps.
|
||||||
|
for A in yad pat jq sponge rigctld
|
||||||
|
do
|
||||||
|
command -v $A >/dev/null 2>&1 || Die "$A is required but not installed."
|
||||||
|
done
|
||||||
|
|
||||||
|
# Ensure only one instance of this script is running.
|
||||||
|
pidof -o %PPID -x $(basename "$0") >/dev/null && exit 1
|
||||||
|
|
||||||
#============================
|
#============================
|
||||||
# MAIN SCRIPT
|
# MAIN SCRIPT
|
||||||
#============================
|
#============================
|
||||||
@ -300,6 +311,24 @@ $SYNTAX && set -n
|
|||||||
# Run in debug mode, if set
|
# Run in debug mode, if set
|
||||||
$DEBUG && set -x
|
$DEBUG && set -x
|
||||||
|
|
||||||
|
# Configure /etc/ax25/axports if necessary. This is needed in order to allocate a PTY for pat.
|
||||||
|
if ! grep -q "^$AX25PORT[[:space:]]" $AX25PORTFILE 2>/dev/null
|
||||||
|
then
|
||||||
|
echo "$AX25PORT $MYCALL 0 255 7 Winlink" | sudo tee --append $AX25PORTFILE >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set up a dummy rig for rigctl in pat
|
||||||
|
RIG="$(jq -r .hamlib_rigs $PAT_CONFIG)"
|
||||||
|
if [[ $RIG == "{}" ]]
|
||||||
|
then # No rigs configured. Make a dummy rig
|
||||||
|
cat $PAT_CONFIG | jq \
|
||||||
|
'.hamlib_rigs += {"dummy": {"address": "localhost:4532", "network": "tcp"}}' | sponge $PAT_CONFIG
|
||||||
|
# Add the dummy rig to the ax25 section
|
||||||
|
cat $PAT_CONFIG | jq \
|
||||||
|
--arg R "dummy" \
|
||||||
|
'.ax25.rig = $R' | sponge $PAT_CONFIG
|
||||||
|
fi
|
||||||
|
|
||||||
while [[ $RETURN_CODE == 0 ]]
|
while [[ $RETURN_CODE == 0 ]]
|
||||||
do
|
do
|
||||||
YAD_PIDs=()
|
YAD_PIDs=()
|
||||||
@ -323,8 +352,18 @@ do
|
|||||||
--editable --tail --center <&3 &
|
--editable --tail --center <&3 &
|
||||||
YAD_PIDs+=( $! )
|
YAD_PIDs+=( $! )
|
||||||
|
|
||||||
|
# Start rigctld. Assume should use the dummy rig.
|
||||||
|
if ! pgrep rigctld >/dev/null
|
||||||
|
then
|
||||||
|
echo "Starting rigctld using dummy rig..." >&3
|
||||||
|
$(command -v rigctld) -m 1 >&3 2>&3 &
|
||||||
|
RIG_PID=$!
|
||||||
|
echo "Done." >&3
|
||||||
|
fi
|
||||||
|
|
||||||
# Start Direwolf
|
# Start Direwolf
|
||||||
$DIREWOLF -a ${F[_AUDIOSTATS_]} -c $DW_CONFIG >&3 2>&3 &
|
[[ ${F[_AUDIOSTATS_]} == 0 ]] || DIREWOLF+=" -a ${F[_AUDIOSTATS_]}"
|
||||||
|
$DIREWOLF -c $DW_CONFIG >&3 2>&3 &
|
||||||
|
|
||||||
# Wait for Direwolf to allocate a PTY
|
# Wait for Direwolf to allocate a PTY
|
||||||
COUNTER=0
|
COUNTER=0
|
||||||
@ -353,14 +392,6 @@ do
|
|||||||
# Start pat
|
# Start pat
|
||||||
[[ $PAT_START_HTTP == TRUE ]] && $PAT >&3 2>&3 &
|
[[ $PAT_START_HTTP == TRUE ]] && $PAT >&3 2>&3 &
|
||||||
|
|
||||||
# Configure /etc/ax25/axports if necessary. This is needed in order to allocate a PTY for pat.
|
|
||||||
if ! grep -q "^$AX25PORT[[:space:]]" $AX25PORTFILE 2>/dev/null
|
|
||||||
then
|
|
||||||
echo "File $AX25PORTFILE empty or does not contain $AX25PORT. Adding..." >&3
|
|
||||||
echo "$AX25PORT $MYCALL 0 255 7 Winlink" | sudo tee --append $AX25PORTFILE >&3
|
|
||||||
echo "done." >&3
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up second tab, for configuring Direwolf.
|
# Set up second tab, for configuring Direwolf.
|
||||||
yad --plug="$ID" --tabnum=2 \
|
yad --plug="$ID" --tabnum=2 \
|
||||||
--text="<b><big><big>Direwolf TNC Configuration</big></big></b>\n\n \
|
--text="<b><big><big>Direwolf TNC Configuration</big></big></b>\n\n \
|
||||||
@ -415,6 +446,7 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
--field="TX Tail (ms)":NUM "$TXTAIL!0..200!10!" \
|
--field="TX Tail (ms)":NUM "$TXTAIL!0..200!10!" \
|
||||||
--field="Persist":NUM "$PERSIST!0..255!1!" \
|
--field="Persist":NUM "$PERSIST!0..255!1!" \
|
||||||
--field="Slot Time (ms)":NUM "$SLOTTIME!0..255!10!" \
|
--field="Slot Time (ms)":NUM "$SLOTTIME!0..255!10!" \
|
||||||
|
--field="<b>Edit pat Connection Aliases</b>":FBTN "bash -c edit_pat_aliases.sh &" \
|
||||||
--focus-field 1 > $TMPDIR/CONFIGURE_PAT.txt &
|
--focus-field 1 > $TMPDIR/CONFIGURE_PAT.txt &
|
||||||
YAD_PIDs+=( $! )
|
YAD_PIDs+=( $! )
|
||||||
STOP_BUTTON_TEXT="TNC"
|
STOP_BUTTON_TEXT="TNC"
|
||||||
@ -438,7 +470,7 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
--tab="Configure pat" \
|
--tab="Configure pat" \
|
||||||
--width="800" --height="600" \
|
--width="800" --height="600" \
|
||||||
--button="<b>Stop Direwolf$AND_PAT and Exit</b>":1 \
|
--button="<b>Stop Direwolf$AND_PAT and Exit</b>":1 \
|
||||||
--button="<b>Restart Direwolf TNC$AND_PAT</b>":0
|
--button="<b>Restart Direwolf$AND_PAT</b>":0
|
||||||
RETURN_CODE=$?
|
RETURN_CODE=$?
|
||||||
|
|
||||||
case $RETURN_CODE in
|
case $RETURN_CODE in
|
||||||
|
287
edit_pat_aliases.sh
Executable file
287
edit_pat_aliases.sh
Executable file
@ -0,0 +1,287 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#================================================================
|
||||||
|
# HEADER
|
||||||
|
#================================================================
|
||||||
|
#% SYNOPSIS
|
||||||
|
#+ ${SCRIPT_NAME} [-hv]
|
||||||
|
#%
|
||||||
|
#% DESCRIPTION
|
||||||
|
#% This script provides a GUI to add aliases to pat's config.json
|
||||||
|
#% file by making selections from the output of 'pat rmslist'.
|
||||||
|
#% These aliases are available in pat's web interface.
|
||||||
|
#% This script is designed to work on the Hampi image.
|
||||||
|
#% This script requires these packages: jq moreutils.
|
||||||
|
#%
|
||||||
|
#% OPTIONS
|
||||||
|
#% -h, --help Print this help
|
||||||
|
#% -v, --version Print script information
|
||||||
|
#%
|
||||||
|
#================================================================
|
||||||
|
#- IMPLEMENTATION
|
||||||
|
#- version ${SCRIPT_NAME} 1.3.5
|
||||||
|
#- author Steve Magnuson, AG7GN
|
||||||
|
#- license CC-BY-SA Creative Commons License
|
||||||
|
#- script_id 0
|
||||||
|
#-
|
||||||
|
#================================================================
|
||||||
|
# HISTORY
|
||||||
|
# 20200507 : Steve Magnuson : Script creation.
|
||||||
|
#
|
||||||
|
#================================================================
|
||||||
|
# DEBUG OPTION
|
||||||
|
# set -n # Uncomment to check your syntax, without execution.
|
||||||
|
# set -x # Uncomment to debug this shell script
|
||||||
|
#
|
||||||
|
#================================================================
|
||||||
|
# END_OF_HEADER
|
||||||
|
#================================================================
|
||||||
|
|
||||||
|
SYNTAX=false
|
||||||
|
DEBUG=false
|
||||||
|
Optnum=$#
|
||||||
|
|
||||||
|
#============================
|
||||||
|
# FUNCTIONS
|
||||||
|
#============================
|
||||||
|
|
||||||
|
function TrapCleanup () {
|
||||||
|
for P in ${YAD_PIDs[@]}
|
||||||
|
do
|
||||||
|
kill $P >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
rm -f $fpipe
|
||||||
|
exec 4>&-
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function SafeExit() {
|
||||||
|
TrapCleanup
|
||||||
|
trap - INT TERM EXIT
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function ScriptInfo() {
|
||||||
|
HEAD_FILTER="^#-"
|
||||||
|
[[ "$1" = "usage" ]] && HEAD_FILTER="^#+"
|
||||||
|
[[ "$1" = "full" ]] && HEAD_FILTER="^#[%+]"
|
||||||
|
[[ "$1" = "version" ]] && HEAD_FILTER="^#-"
|
||||||
|
head -${SCRIPT_HEADSIZE:-99} ${0} | grep -e "${HEAD_FILTER}" | \
|
||||||
|
sed -e "s/${HEAD_FILTER}//g" \
|
||||||
|
-e "s/\${SCRIPT_NAME}/${SCRIPT_NAME}/g" \
|
||||||
|
-e "s/\${SPEED}/${SPEED}/g" \
|
||||||
|
-e "s/\${DEFAULT_PORTSTRING}/${DEFAULT_PORTSTRING}/g"
|
||||||
|
}
|
||||||
|
|
||||||
|
function Usage() {
|
||||||
|
printf "Usage: "
|
||||||
|
ScriptInfo usage
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
function Die () {
|
||||||
|
echo "${*}"
|
||||||
|
SafeExit
|
||||||
|
}
|
||||||
|
|
||||||
|
function runFind () {
|
||||||
|
echo "5:@disable@"
|
||||||
|
PAT="pat rmslist"
|
||||||
|
[[ $2 == "Any" ]] || PAT+=" -b $2"
|
||||||
|
[[ $3 == "Any" ]] || PAT+=" -m $3"
|
||||||
|
[[ $4 == TRUE ]] && PAT+=" -s"
|
||||||
|
echo -e '\f' >> "$fpipe"
|
||||||
|
eval $PAT | grep -i "$1" | grep -v VARA | grep -v "^callsign" | grep -v "^$" | tr -s ' ' | \
|
||||||
|
awk '{printf "%s\n%s\n%s\n%s\n%s\n%s %s\n%s\n",$1,$7,$2,$3,$4,$5,$6,$8}' >> "$fpipe"
|
||||||
|
echo "5:$find_cmd"
|
||||||
|
}
|
||||||
|
export -f runFind
|
||||||
|
|
||||||
|
function processAlias () {
|
||||||
|
CALL="$(echo "$1" | sed 's/^ //' | cut -d' ' -f1)"
|
||||||
|
FREQ="$(echo "$1" | sed 's/^ //' | cut -d' ' -f2 | sed -e 's/\.00$//' -e 's/\.//1')"
|
||||||
|
if jq -r .connect_aliases $PAT_CONFIG | grep ":" | tr -d '", ' | grep -q ^$CALL.*$FREQ$
|
||||||
|
then
|
||||||
|
yad --info --center --text-align=center --buttons-layout=center \
|
||||||
|
--text="$CALL @ $FREQ was already in aliases" --borders=20 --button="gtk-ok":0
|
||||||
|
else
|
||||||
|
cat $PAT_CONFIG | jq --arg K "$CALL" --arg V "ax25:///$CALL?freq=$FREQ" \
|
||||||
|
'.connect_aliases += {($K): $V}' | sponge $PAT_CONFIG
|
||||||
|
if [[ $? == 0 ]]
|
||||||
|
then
|
||||||
|
yad --info --center --text-align=center --buttons-layout=center \
|
||||||
|
--text="$CALL @ $FREQ was added to aliases" --borders=20 --button="gtk-ok":0
|
||||||
|
else
|
||||||
|
yad --info --center --text-align=center --buttons-layout=center \
|
||||||
|
--text="ERROR: $CALL @ $FREQ was NOT added to aliases" --borders=20 --button="gtk-ok":0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
export -f processAlias
|
||||||
|
|
||||||
|
function viewDeleteAliases () {
|
||||||
|
# Load existing aliases
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
# Read aliases from $PAT_CONFIG
|
||||||
|
ALIASES="$(jq -r .connect_aliases $PAT_CONFIG | egrep -v "telnet|{|}" | \
|
||||||
|
sed 's/^ /FALSE|/' | tr -d ' ",' | sed 's/:/|/1' | tr '|' '\n')"
|
||||||
|
RESULT="$(yad --title="View/remove pat aliases" --list --mouse --borders=10 \
|
||||||
|
--height=400 --width=400 --text-align=center \
|
||||||
|
--text "<b>Your current pat connection aliases are listed below.</b>\n \
|
||||||
|
Check the ones you want to remove.\n" \
|
||||||
|
--checklist --grid-lines=hor --auto-kill --column="Pick" --column="Call" --column="Connect URI" \
|
||||||
|
<<< "$ALIASES" --buttons-layout=center --button="Exit":1 --button="Refresh list":0 --button="Remove selected aliases":0)"
|
||||||
|
if [[ $? == 0 ]]
|
||||||
|
then # Refresh or removal requested
|
||||||
|
while IFS="|" read -r CHK KEY VALUE REMAINDER
|
||||||
|
do # read each checked alias
|
||||||
|
if [[ $CHK == "TRUE" ]]
|
||||||
|
then # Remove alias
|
||||||
|
cat $PAT_CONFIG | jq --arg K "$KEY" --arg V "$VALUE" \
|
||||||
|
'(.connect_aliases | select(.[$K] == $V)) |= del (.[$K])' | sponge $PAT_CONFIG
|
||||||
|
fi
|
||||||
|
done <<< "$RESULT"
|
||||||
|
else # User cancelled
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
export -f viewDeleteAliases
|
||||||
|
|
||||||
|
#============================
|
||||||
|
# FILES AND VARIABLES
|
||||||
|
#============================
|
||||||
|
|
||||||
|
# Set Temp Directory
|
||||||
|
# -----------------------------------
|
||||||
|
# Create temp directory with three random numbers and the process ID
|
||||||
|
# in the name. This directory is removed automatically at exit.
|
||||||
|
# -----------------------------------
|
||||||
|
TMPDIR="/tmp/${SCRIPT_NAME}.$RANDOM.$RANDOM.$RANDOM.$$"
|
||||||
|
(umask 077 && mkdir "${TMPDIR}") || {
|
||||||
|
Die "Could not create temporary directory! Exiting."
|
||||||
|
}
|
||||||
|
|
||||||
|
#= general variables ==#
|
||||||
|
PAT_CONFIG="$HOME/.wl2k/config.json"
|
||||||
|
export PAT_CONFIG=$PAT_CONFIG
|
||||||
|
export find_cmd='@bash -c "runFind %1 %2 %3 %4"'
|
||||||
|
export view_remove_cmd='bash -c "viewDeleteAliases"'
|
||||||
|
export fpipe=$(mktemp -u --tmpdir find.XXXXXXXX)
|
||||||
|
mkfifo "$fpipe"
|
||||||
|
DEFAULT_SEARCH_STRING="$(jq -r .locator $PAT_CONFIG)"
|
||||||
|
fkey=$(($RANDOM * $$))
|
||||||
|
YAD_PIDs=()
|
||||||
|
|
||||||
|
BANDs="^Any!70cm!1.25m!2m!6m!12m!15m!17m!20m!30m!40m!60m!80m!160m"
|
||||||
|
MODEs="^Any!ARDOP!Packet!Pactor!WINMOR"
|
||||||
|
|
||||||
|
exec 4<> $fpipe
|
||||||
|
|
||||||
|
#============================
|
||||||
|
# PARSE OPTIONS WITH GETOPTS
|
||||||
|
#============================
|
||||||
|
|
||||||
|
#== set short options ==#
|
||||||
|
SCRIPT_OPTS=':hv-:'
|
||||||
|
|
||||||
|
#== set long options associated with short one ==#
|
||||||
|
typeset -A ARRAY_OPTS
|
||||||
|
ARRAY_OPTS=(
|
||||||
|
[help]=h
|
||||||
|
[version]=v
|
||||||
|
)
|
||||||
|
|
||||||
|
LONG_OPTS="^($(echo "${!ARRAY_OPTS[@]}" | tr ' ' '|'))="
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
while getopts ${SCRIPT_OPTS} OPTION
|
||||||
|
do
|
||||||
|
# Translate long options to short
|
||||||
|
if [[ "x$OPTION" == "x-" ]]
|
||||||
|
then
|
||||||
|
LONG_OPTION=$OPTARG
|
||||||
|
LONG_OPTARG=$(echo $LONG_OPTION | egrep "$LONG_OPTS" | cut -d'=' -f2-)
|
||||||
|
LONG_OPTIND=-1
|
||||||
|
[[ "x$LONG_OPTARG" = "x" ]] && LONG_OPTIND=$OPTIND || LONG_OPTION=$(echo $OPTARG | cut -d'=' -f1)
|
||||||
|
[[ $LONG_OPTIND -ne -1 ]] && eval LONG_OPTARG="\$$LONG_OPTIND"
|
||||||
|
OPTION=${ARRAY_OPTS[$LONG_OPTION]}
|
||||||
|
[[ "x$OPTION" = "x" ]] && OPTION="?" OPTARG="-$LONG_OPTION"
|
||||||
|
|
||||||
|
if [[ $( echo "${SCRIPT_OPTS}" | grep -c "${OPTION}:" ) -eq 1 ]]; then
|
||||||
|
if [[ "x${LONG_OPTARG}" = "x" ]] || [[ "${LONG_OPTARG}" = -* ]]; then
|
||||||
|
OPTION=":" OPTARG="-$LONG_OPTION"
|
||||||
|
else
|
||||||
|
OPTARG="$LONG_OPTARG";
|
||||||
|
if [[ $LONG_OPTIND -ne -1 ]]; then
|
||||||
|
[[ $OPTIND -le $Optnum ]] && OPTIND=$(( $OPTIND+1 ))
|
||||||
|
shift $OPTIND
|
||||||
|
OPTIND=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Options followed by another option instead of argument
|
||||||
|
if [[ "x${OPTION}" != "x:" ]] && [[ "x${OPTION}" != "x?" ]] && [[ "${OPTARG}" = -* ]]; then
|
||||||
|
OPTARG="$OPTION" OPTION=":"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Finally, manage options
|
||||||
|
case "$OPTION" in
|
||||||
|
h)
|
||||||
|
ScriptInfo full
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
ScriptInfo version
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
:)
|
||||||
|
Die "${SCRIPT_NAME}: -$OPTARG: option requires an argument"
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
Die "${SCRIPT_NAME}: -$OPTARG: unknown option"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((${OPTIND} - 1)) ## shift options
|
||||||
|
|
||||||
|
# Check for required apps.
|
||||||
|
for A in yad pat jq sponge
|
||||||
|
do
|
||||||
|
command -v $A >/dev/null 2>&1 || Die "$A is required but not installed."
|
||||||
|
done
|
||||||
|
|
||||||
|
# Ensure only one instance of this script is running.
|
||||||
|
pidof -o %PPID -x $(basename "$0") >/dev/null && exit 1
|
||||||
|
|
||||||
|
#============================
|
||||||
|
# MAIN SCRIPT
|
||||||
|
#============================
|
||||||
|
|
||||||
|
trap SafeExit INT TERM EXIT
|
||||||
|
|
||||||
|
yad --plug="$fkey" --tabnum=1 --text-align=center \
|
||||||
|
--text="<b>Search for RMS stations and optionally add them to your pat \
|
||||||
|
connection alias list</b>\n \
|
||||||
|
The station list is generated by running 'pat rmslist' (downloads the list from Winlink).\n \
|
||||||
|
Internet access is required for this to work." \
|
||||||
|
--form --field="Search string" "${DEFAULT_SEARCH_STRING:0:4}" --field="Band":CB "$BANDs" \
|
||||||
|
--field="Mode":CB "$MODEs" --field="Sort by distance (Uncheck to sort by callsign)":CHK TRUE \
|
||||||
|
--field="gtk-find":FBTN "$find_cmd" --field="<b>View/edit current pat connection aliases</b>":FBTN "$view_remove_cmd &" &
|
||||||
|
YAD_PIDs+=( $! )
|
||||||
|
|
||||||
|
yad --plug="$fkey" --tabnum=2 --list --grid-lines=hor --dclick-action="bash -c \"processAlias '%s'\"" \
|
||||||
|
--text "Search results. Double-click a Call to add it to your pat aliases." \
|
||||||
|
--column="Call" --column="Frequency" --column="Location" --column="Distance" --column="Azimuth" \
|
||||||
|
--column="Mode" --column="Units" \
|
||||||
|
--search-column=1 --expand-column=1 <&4 &
|
||||||
|
YAD_PIDs+=( $! )
|
||||||
|
|
||||||
|
yad --paned --key="$fkey" --buttons-layout=center --button="gtk-close":0 --width=700 --height=700 \
|
||||||
|
--title="Find RMS Stations" --window-icon="system-search"
|
||||||
|
|
||||||
|
SafeExit
|
||||||
|
|
@ -1 +1 @@
|
|||||||
VERSION="2.1.24"
|
VERSION="2.1.25"
|
Loading…
x
Reference in New Issue
Block a user