Start flrig at login after radio configure --flrig
--flrig adds an autostart entry, ~/.config/autostart/hampack-flrig.desktop, so flrig is running before the programs that reach the radio through rigctld and it. If an autostart entry of yours already runs flrig, none is added: two flrigs would fight over the port. Running it without --flrig removes the entry, since flrig would take the port from rigctld at login, and so does hampackremove. Both remove it only if it carries HamPack's mark (X-HamPack). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
53e748ccb9
commit
357f72583e
@@ -19,9 +19,6 @@ control a radio.
|
||||
points WSJT-X, JS8Call, Pat, fldigi, Dire Wolf, not1mm, QLog, POTACAT
|
||||
and Graywolf at it, or with --flrig, puts flrig in charge of the radio
|
||||
behind rigctld. Still to do:
|
||||
- [ ] With --flrig, nothing starts flrig: rigctld retries until it's
|
||||
running. An autostart entry for flrig, or a user service, would save
|
||||
starting it by hand
|
||||
- [ ] More than one radio at once: a rigctld for each, on its own port
|
||||
- [ ] rigctld retries every 5 seconds while the radio is off or unplugged.
|
||||
Start it when the radio is plugged in instead (see hotplug below)
|
||||
|
||||
@@ -71,7 +71,7 @@ It also gives WSJT-X, JS8Call, fldigi, Dire Wolf, not1mm's voice keyer and POTAC
|
||||
|
||||
`radio configure` only fills in rig and sound settings you haven't set (a sound device of "default" or "pipewire" counts as not set). `radio configure --force` replaces them, and every file it changes is backed up first. With more than one radio plugged in, give the number `radio` lists for it: `radio configure 2`. For a radio it can't tell apart from others, give its Hamlib model number: `radio configure --model 2045`.
|
||||
|
||||
flrig can't reach a radio through rigctld, and the two can't share its port, so `radio configure` leaves flrig alone. If you'd rather flrig controlled the radio, run `radio configure --flrig`: flrig gets the radio, and rigctld passes the other programs through it, using Hamlib's FLRig support. Then start flrig before the other programs, and leave it running. `radio configure` also says which sound card is the radio's.
|
||||
flrig can't reach a radio through rigctld, and the two can't share its port, so `radio configure` leaves flrig alone. If you'd rather flrig controlled the radio, run `radio configure --flrig`: flrig gets the radio, and rigctld passes the other programs through it, using Hamlib's FLRig support. flrig then starts when you log in (unless you have it starting already), so it's there before the other programs; leave it running. `radio configure` without --flrig gives the radio back to rigctld, and stops flrig starting at login. `radio configure` also says which sound card is the radio's.
|
||||
|
||||
The radios it knows are in `radios.conf`. If your radio isn't recognised, or answers with something `radio` doesn't know, please open an issue with what `radio detect --probe` printed.
|
||||
|
||||
|
||||
@@ -111,9 +111,11 @@ Dire Wolf, not1mm, QLog and POTACAT quit:
|
||||
by CAT, and shows the radio's frequency. `rigctl -m 2 -r 127.0.0.1:4532 f`
|
||||
shows the same frequency, through rigctld and flrig. WSJT-X's "Test CAT"
|
||||
and "Test PTT" still work. Quit flrig: rigctld loses the radio, and gets
|
||||
it back within a few seconds of starting flrig again. Then run
|
||||
`radio configure` without --flrig, and check rigctld has the radio's port
|
||||
again. The settings were checked against flrig 2.0.12's source and FLTK
|
||||
it back within a few seconds of starting flrig again. Log out and back
|
||||
in: flrig starts by itself (GNOME's Settings > Apps > flrig shows it set
|
||||
to start at login), and WSJT-X reaches the radio. Then run
|
||||
`radio configure` without --flrig, check rigctld has the radio's port
|
||||
again, and that flrig no longer starts when you log in. The settings were checked against flrig 2.0.12's source and FLTK
|
||||
1.4.5's preferences format.
|
||||
14. With a rig set by hand in WSJT-X, `radio configure` leaves it alone, and
|
||||
`--force` replaces it. The `.bak-` copy has the old settings.
|
||||
|
||||
@@ -266,6 +266,12 @@ if [ -f "$RIGCTLD_UNIT" ]; then
|
||||
systemctl --user daemon-reload 2> /dev/null
|
||||
fi
|
||||
|
||||
# The flrig autostart entry `radio configure --flrig` added, marked as HamPack's
|
||||
FLRIG_AUTOSTART="${XDG_CONFIG_HOME:-$HOME/.config}/autostart/hampack-flrig.desktop"
|
||||
if grep -qx 'X-HamPack=radio configure --flrig' "$FLRIG_AUTOSTART" 2> /dev/null; then
|
||||
rm -f "$FLRIG_AUTOSTART"
|
||||
fi
|
||||
|
||||
# Take you out of the groups update.sh added you to
|
||||
for group in $(recorded_installs added-groups); do
|
||||
echo "Removing you from the $group group..."
|
||||
|
||||
@@ -36,6 +36,8 @@ QLOG_DB="$HOME/.var/app/$QLOG_FLATPAK/data/hamradio/QLog/qlog.db"
|
||||
POTACAT_DIR="$CONFIG_HOME/potacat"
|
||||
GRAYWOLF_DB="$HOME/.local/share/graywolf/graywolf.db"
|
||||
FLRIG_DIR="$HOME/.flrig"
|
||||
AUTOSTART_DIR="$CONFIG_HOME/autostart"
|
||||
FLRIG_AUTOSTART="$AUTOSTART_DIR/hampack-flrig.desktop"
|
||||
# flrig's baud rates; it saves the rate as its place in this list
|
||||
FLRIG_BAUDS=(300 600 1200 2400 4800 9600 19200 38400 57600 115200 230400 460800)
|
||||
DIREWOLF_CONF="$HAMPACK_STATE/conf.d/direwolf.conf"
|
||||
@@ -633,6 +635,43 @@ fltk_set() {
|
||||
' "$1" > "$tmp" && chmod --reference="$1" "$tmp" && mv -f "$tmp" "$1"
|
||||
}
|
||||
|
||||
# Print the autostart entries, other than HamPack's, that start flrig when
|
||||
# you log in
|
||||
other_flrig_autostarts() {
|
||||
local entry exec
|
||||
for entry in "$AUTOSTART_DIR"/*.desktop; do
|
||||
[ -f "$entry" ] && [ "$entry" != "$FLRIG_AUTOSTART" ] || continue
|
||||
grep -qix 'Hidden=true' "$entry" && continue
|
||||
exec="$(sed -n 's/^Exec=//p' "$entry" | head -1)"
|
||||
exec="${exec%% *}"
|
||||
[ "${exec##*/}" = flrig ] && echo "$entry"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
# Start flrig when you log in, so rigctld has it to talk to: an autostart
|
||||
# entry, marked as HamPack's so it's only ever removed by HamPack
|
||||
add_flrig_autostart() {
|
||||
mkdir -p "$AUTOSTART_DIR" && cat > "$FLRIG_AUTOSTART" << 'EOF'
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=flrig
|
||||
Comment=Controls the radio, for rigctld and the programs that use it. Added by HamPack's radio configure --flrig
|
||||
Exec=flrig
|
||||
Icon=flrig
|
||||
Terminal=false
|
||||
X-GNOME-Autostart-enabled=true
|
||||
X-HamPack=radio configure --flrig
|
||||
EOF
|
||||
}
|
||||
|
||||
# Remove HamPack's flrig autostart entry, if that's what it is. Prints
|
||||
# whether it removed one
|
||||
remove_flrig_autostart() {
|
||||
[ -f "$FLRIG_AUTOSTART" ] && grep -qx 'X-HamPack=radio configure --flrig' "$FLRIG_AUTOSTART" || return 1
|
||||
rm -f "$FLRIG_AUTOSTART"
|
||||
}
|
||||
|
||||
# flrig can't reach a radio through rigctld, and the two can't both have its
|
||||
# port open. With --flrig, flrig gets the radio, its port, baud rate and PTT
|
||||
# by CAT, and rigctld (Hamlib's FLRig backend) passes everything to it;
|
||||
@@ -644,9 +683,24 @@ configure_flrig() {
|
||||
return
|
||||
fi
|
||||
if (( ! USE_FLRIG )); then
|
||||
if remove_flrig_autostart; then
|
||||
report flrig "no longer starts when you log in, since rigctld has the radio's port again. \`radio configure --flrig\` puts flrig back in charge"
|
||||
else
|
||||
report flrig "not set up: it and rigctld can't both use the radio's port. \`radio configure --flrig\` puts flrig in charge of the radio, with rigctld passing the other programs through it"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
local autostart="" others
|
||||
others="$(other_flrig_autostarts)"
|
||||
if [ -n "$others" ]; then
|
||||
autostart=" It starts when you log in, from ${others##*/}"
|
||||
elif [ -f "$FLRIG_AUTOSTART" ]; then
|
||||
autostart=" It starts when you log in"
|
||||
elif add_flrig_autostart; then
|
||||
autostart=" It now starts when you log in; start it yourself this time"
|
||||
else
|
||||
autostart=" Couldn't add it to $AUTOSTART_DIR, so start it before the other programs"
|
||||
fi
|
||||
for i in "${!FLRIG_BAUDS[@]}"; do
|
||||
[ "${FLRIG_BAUDS[i]}" = "$3" ] && index="$i"
|
||||
done
|
||||
@@ -655,11 +709,12 @@ configure_flrig() {
|
||||
SAID=() LEFT=()
|
||||
if [ "$current_name" = "$1" ] && [ "$current_port" = "$2" ] && [ "$(fltk_get "$rig" serial_baudrate)" = "$index" ] &&
|
||||
[ "$(fltk_get "$rig" ptt_via_cat)" = 1 ]; then
|
||||
report flrig "already set up. Start it before the other programs, and leave it running"
|
||||
report flrig "already set up.$autostart, and leave it running"
|
||||
return
|
||||
fi
|
||||
if (( ! FORCE )) && { [[ ! "$current_name" =~ ^(|NONE|$1)$ ]] || [[ ! "$current_port" =~ ^(|NONE)$ && "$current_port" != "$2" ]]; }; then
|
||||
[[ "$current_name" =~ ^(|NONE|$1)$ ]] && LEFT+=("its port ($current_port)") || LEFT+=("its radio ($current_name)")
|
||||
SAID+=("${autostart# }")
|
||||
say_changes flrig
|
||||
return
|
||||
fi
|
||||
@@ -674,7 +729,7 @@ configure_flrig() {
|
||||
report flrig "couldn't change its settings in $FLRIG_DIR"
|
||||
return 1
|
||||
fi
|
||||
report flrig "controls the $1 on $2 at $3 baud, PTT by CAT. Start it before the other programs, and leave it running"
|
||||
report flrig "controls the $1 on $2 at $3 baud, PTT by CAT.$autostart, and leave it running"
|
||||
}
|
||||
|
||||
# Pat: add rigctld to its rigs as "hampack", and use it for ARDOP and VARA
|
||||
|
||||
@@ -120,6 +120,16 @@ remove() {
|
||||
[ ! -e "$unit" ]
|
||||
}
|
||||
|
||||
@test "removes the flrig autostart radio configure added, and no other" {
|
||||
mkdir -p "$HOME/.config/autostart"
|
||||
printf '[Desktop Entry]\nExec=flrig\nX-HamPack=radio configure --flrig\n' > "$HOME/.config/autostart/hampack-flrig.desktop"
|
||||
printf '[Desktop Entry]\nExec=flrig\n' > "$HOME/.config/autostart/my-flrig.desktop"
|
||||
remove
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -e "$HOME/.config/autostart/hampack-flrig.desktop" ]
|
||||
[ -e "$HOME/.config/autostart/my-flrig.desktop" ]
|
||||
}
|
||||
|
||||
@test "does nothing unless confirmed" {
|
||||
mark_installed fldigi
|
||||
mkdir -p "$HAMPACK_STATE"
|
||||
|
||||
+35
-2
@@ -1091,7 +1091,7 @@ IC7300_PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Control
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${lines[0]}" == *"at 38400 baud, through flrig" ]]
|
||||
[[ "$output" == *"rigctld: runs as the hampack-rigctld user service, on 127.0.0.1:4532, and passes everything to flrig"* ]]
|
||||
[[ "$output" == *"flrig: controls the IC-7300 on $IC7300_PORT at 38400 baud, PTT by CAT. Start it before the other programs, and leave it running"* ]]
|
||||
[[ "$output" == *"flrig: controls the IC-7300 on $IC7300_PORT at 38400 baud, PTT by CAT. It now starts when you log in; start it yourself this time, and leave it running"* ]]
|
||||
grep -qx "ExecStart=/usr/bin/rigctld -m 4 -r 127.0.0.1:12345 -T 127.0.0.1 -t 4532" "$HOME/.config/systemd/user/hampack-rigctld.service"
|
||||
# As FLTK writes it
|
||||
[ "$(head -5 "$(FLRIG_PREFS)")" = "$(printf '; FLTK preferences file format 1.0\n; vendor: w1hkj.com\n; application: flrig\n\n[.]')" ]
|
||||
@@ -1135,7 +1135,7 @@ IC7300_PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Control
|
||||
mkdir -p "$HOME/.flrig"
|
||||
printf '; FLTK preferences file format 1.0\n; vendor: w1hkj.com\n; application: flrig\n\n[.]\n\nxcvr_name:FT-991A\n' > "$(FLRIG_PREFS)"
|
||||
run bash "$REPO/radio" configure --flrig
|
||||
[[ "$output" == *"flrig: Left its radio (FT-991A) alone: \`radio configure --force\` replaces it"* ]]
|
||||
[[ "$output" == *"flrig: It now starts when you log in; start it yourself this time. Left its radio (FT-991A) alone: \`radio configure --force\` replaces it"* ]]
|
||||
grep -qx "xcvr_name:FT-991A" "$(FLRIG_PREFS)"
|
||||
|
||||
run bash "$REPO/radio" configure --flrig --force
|
||||
@@ -1156,3 +1156,36 @@ IC7300_PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Control
|
||||
[ ! -e "$HOME/.config/systemd/user/hampack-rigctld.service" ]
|
||||
|
||||
}
|
||||
|
||||
FLRIG_AUTOSTART() { echo "$HOME/.config/autostart/hampack-flrig.desktop"; }
|
||||
|
||||
@test "configure --flrig starts flrig when you log in, and stops that when rigctld takes the radio back" {
|
||||
configurable
|
||||
run bash "$REPO/radio" configure --flrig
|
||||
grep -qx "Exec=flrig" "$(FLRIG_AUTOSTART)"
|
||||
grep -qx "X-HamPack=radio configure --flrig" "$(FLRIG_AUTOSTART)"
|
||||
|
||||
run bash "$REPO/radio" configure --flrig
|
||||
[[ "$output" == *"flrig: already set up. It starts when you log in, and leave it running"* ]]
|
||||
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"flrig: no longer starts when you log in, since rigctld has the radio's port again"* ]]
|
||||
[ ! -e "$(FLRIG_AUTOSTART)" ]
|
||||
run bash "$REPO/radio" configure
|
||||
[[ "$output" == *"flrig: not set up: it and rigctld can't both use the radio's port"* ]]
|
||||
}
|
||||
|
||||
@test "configure --flrig doesn't add a second autostart for flrig, or remove one that isn't HamPack's" {
|
||||
configurable
|
||||
mkdir -p "$HOME/.config/autostart"
|
||||
printf '[Desktop Entry]\nType=Application\nName=My flrig\nExec=/usr/bin/flrig --debug-level 2\n' > "$HOME/.config/autostart/my-flrig.desktop"
|
||||
run bash "$REPO/radio" configure --flrig
|
||||
[[ "$output" == *"PTT by CAT. It starts when you log in, from my-flrig.desktop, and leave it running"* ]]
|
||||
[ ! -e "$(FLRIG_AUTOSTART)" ]
|
||||
|
||||
# One of yours, under HamPack's name, without HamPack's mark
|
||||
printf '[Desktop Entry]\nType=Application\nExec=flrig\n' > "$(FLRIG_AUTOSTART)"
|
||||
run bash "$REPO/radio" configure
|
||||
[ -e "$(FLRIG_AUTOSTART)" ]
|
||||
[ -e "$HOME/.config/autostart/my-flrig.desktop" ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user