Set up a radio radio knows when it's plugged in, with radio configure --auto
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:
co-authored by
Claude Opus 5.5
parent
f2e29ab46d
commit
8d15d2c81e
@@ -90,18 +90,38 @@ join_serial_group() {
|
||||
echo " Added you to the uucp group, so programs can control your radio. Log out and back in for it to take effect."
|
||||
}
|
||||
|
||||
# Let you key a radio through a CM108-family sound card's PTT pin (Digirig,
|
||||
# AIOC), which programs reach through its hidraw device. Reinstalled when
|
||||
# udev/70-hampack-cm108.rules changes
|
||||
# Install the rules in udev/, each again when it changes:
|
||||
# 70-hampack-cm108.rules lets you key a radio through a CM108-family sound
|
||||
# card's PTT pin (Digirig, AIOC), which programs reach through its hidraw
|
||||
# device; 70-hampack-radio.rules sets up a radio when it's plugged in
|
||||
install_udev_rules() {
|
||||
local rules="${HAMPACK_UDEV_RULES_DIR:-/etc/udev/rules.d}/70-hampack-cm108.rules"
|
||||
cmp -s "$SELF/udev/70-hampack-cm108.rules" "$rules" && return 0
|
||||
echo "Installing $rules..."
|
||||
sudo install -m 644 "$SELF/udev/70-hampack-cm108.rules" "$rules" &&
|
||||
sudo udevadm control --reload-rules &&
|
||||
local dir="${HAMPACK_UDEV_RULES_DIR:-/etc/udev/rules.d}" rules name changed=()
|
||||
for rules in "$SELF"/udev/*.rules; do
|
||||
name="${rules##*/}"
|
||||
cmp -s "$rules" "$dir/$name" && continue
|
||||
echo "Installing $dir/$name..."
|
||||
sudo install -m 644 "$rules" "$dir/$name" || return 1
|
||||
changed+=("$name")
|
||||
done
|
||||
[ ${#changed[@]} -gt 0 ] || return 0
|
||||
sudo udevadm control --reload-rules || return 1
|
||||
# Apply the CM108 rule to cards plugged in already
|
||||
[[ " ${changed[*]} " != *" 70-hampack-cm108.rules "* ]] ||
|
||||
sudo udevadm trigger --subsystem-match=hidraw --action=change
|
||||
}
|
||||
|
||||
# The user service udev/70-hampack-radio.rules starts when a USB serial port
|
||||
# appears, to run `radio configure --auto`. Reinstalled when it changes
|
||||
install_radio_service() {
|
||||
local dir="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user" rendered
|
||||
local unit="$dir/hampack-radio-plugged.service"
|
||||
rendered="$(sed "s|HAMPACK_DIR|$SELF|g" "$SELF/systemd/user/hampack-radio-plugged.service")"
|
||||
[ "$(cat "$unit" 2> /dev/null)" = "$rendered" ] && return 0
|
||||
mkdir -p "$dir" && printf '%s\n' "$rendered" > "$unit" || return 1
|
||||
systemctl --user daemon-reload 2> /dev/null
|
||||
return 0
|
||||
}
|
||||
|
||||
# Install the packages in packages.conf, and record the ones that weren't
|
||||
# already installed, so hampackremove removes those and nothing the user had before
|
||||
install_hampack_packages() {
|
||||
@@ -175,7 +195,8 @@ fi
|
||||
step "Removing stale HamPack files" remove_stale_files
|
||||
step "Installing HamPack tools" install_tools
|
||||
step "Adding you to the uucp group, for radios' serial ports" join_serial_group
|
||||
step "Installing udev rules, for PTT through a CM108 sound card" install_udev_rules
|
||||
step "Installing udev rules, for PTT through a CM108 sound card and setting up radios when plugged in" install_udev_rules
|
||||
step "Installing the service that sets up a radio when it's plugged in" install_radio_service
|
||||
step "Installing HamPack packages" install_hampack_packages
|
||||
step "Installing Flatpak applications" bash "$SELF/install-flatpaks.sh"
|
||||
step "Installing pre-built binaries" bash "$SELF/install-binaries.sh"
|
||||
|
||||
Reference in New Issue
Block a user