Set up a radio radio knows when it's plugged in, with radio configure --auto
check / lint-and-test (push) Successful in 3m57s
check / packages (push) Successful in 24s

A udev rule starts the hampack-radio-plugged user service when a USB serial
port appears, and it runs `radio configure --auto`. That sets up a radio
recognised by its USB serial number, unless the radio set up already is
plugged in, and says what it did in a desktop notification. It never asks a
radio what it is, since that may key the transmitter, and never asks for
sudo, so a running Graywolf is skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-28 16:32:05 -07:00
co-authored by Claude Opus 5.5
parent f2e29ab46d
commit 8d15d2c81e
11 changed files with 309 additions and 18 deletions
+19
View File
@@ -84,6 +84,25 @@ setup() {
grep -q "^sudo install -m 644 .*70-hampack-cm108.rules" "$STUB_LOG"
}
@test "installs the udev rule and user service that set up a radio when it's plugged in" {
run bash "$REPO/update.sh"
[ "$status" -eq 0 ]
grep -qx "sudo install -m 644 $REPO/udev/70-hampack-radio.rules $HAMPACK_UDEV_RULES_DIR/70-hampack-radio.rules" "$STUB_LOG"
local unit="$HOME/.config/systemd/user/hampack-radio-plugged.service"
grep -qx "ExecStart=$REPO/radio configure --auto" "$unit"
grep -qx "systemctl --user daemon-reload" "$STUB_LOG"
# Only the CM108 rule needs applying to devices plugged in already
mkdir -p "$HAMPACK_UDEV_RULES_DIR"
cp "$REPO/udev/70-hampack-cm108.rules" "$HAMPACK_UDEV_RULES_DIR/"
: > "$STUB_LOG"
run bash "$REPO/update.sh"
grep -q "^sudo install -m 644 .*70-hampack-radio.rules" "$STUB_LOG"
grep -qx "udevadm control --reload-rules" "$STUB_LOG"
! grep -q "udevadm trigger" "$STUB_LOG"
! grep -q "daemon-reload" "$STUB_LOG"
}
@test "update leaves alone a radio command that isn't HamPack's" {
echo "theirs" > "$HOME/.local/bin/radio"
run bash "$REPO/update.sh"