2019-12-18 11:11:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#get freq of radio to display in conky
|
2020-04-28 19:08:36 +00:00
|
|
|
#optional parameter: VFOA VFOB
|
2019-12-18 11:11:58 +00:00
|
|
|
#20191217 km4ack
|
2020-04-28 19:08:36 +00:00
|
|
|
#20200428 modified
|
2019-12-18 11:11:58 +00:00
|
|
|
|
2020-08-09 19:03:55 +00:00
|
|
|
source "$HOME/patmenu2/config"
|
2019-12-18 11:11:58 +00:00
|
|
|
|
|
|
|
MAIN () {
|
|
|
|
|
2020-04-28 19:08:36 +00:00
|
|
|
# If first argument, $1, is empty or unset, use 'VFOA' as its value.
|
|
|
|
VFO=${1:-'VFOA'}
|
|
|
|
|
|
|
|
FREQ=$($RIG -o f "$VFO")
|
|
|
|
FREQCH=$(echo "$FREQ" | grep error)
|
2019-12-18 11:11:58 +00:00
|
|
|
|
|
|
|
if [ -z "$FREQCH" ]
|
|
|
|
then
|
2020-04-28 19:08:36 +00:00
|
|
|
HZ_TO_MHZ "$FREQ"
|
2019-12-18 11:11:58 +00:00
|
|
|
else
|
2020-04-28 19:08:36 +00:00
|
|
|
MAIN "$1"
|
2019-12-18 11:11:58 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-28 19:08:36 +00:00
|
|
|
HZ_TO_MHZ () {
|
|
|
|
|
|
|
|
#Inject decimal into number six places from right.
|
|
|
|
#First, and only, parameter expected to be a string of six or more digits
|
|
|
|
|
|
|
|
DP=.
|
|
|
|
SIX_DIGITS='[0-9][0-9][0-9][0-9][0-9][0-9]'
|
|
|
|
MHZ="${1%%$SIX_DIGITS}"
|
|
|
|
HZ="${1##$MHZ}"
|
|
|
|
printf "%s$DP%s\n" "$MHZ" "$HZ"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MAIN "$1"
|