From 322d1bc30d7fa5c61f0a68776cbb525ef9dd344f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 25 May 2026 23:05:00 +0200 Subject: [PATCH] Gate bluetooth pairing agent on active bluetooth service --- config/systemd/user/bt-agent.service | 3 +++ migrations/1779742224.sh | 9 +++++++++ test/shell.d/systemd-test.sh | 13 +++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 migrations/1779742224.sh create mode 100755 test/shell.d/systemd-test.sh diff --git a/config/systemd/user/bt-agent.service b/config/systemd/user/bt-agent.service index d44a441e..57fb661f 100644 --- a/config/systemd/user/bt-agent.service +++ b/config/systemd/user/bt-agent.service @@ -7,6 +7,9 @@ Requires=dbus.socket [Service] Type=simple +# If bluetoothd is unavailable (for example in VMs or machines without a +# usable adapter), skip cleanly instead of entering a restart loop. +ExecCondition=/usr/bin/systemctl is-active --quiet bluetooth.service # NoInputNoOutput auto-accepts pair requests. Safe because the adapter # is only `pairable: true` when the user explicitly opens the omarchy # bluetoothPanel and starts scanning; outside that window bluez refuses diff --git a/migrations/1779742224.sh b/migrations/1779742224.sh new file mode 100644 index 00000000..a606ce28 --- /dev/null +++ b/migrations/1779742224.sh @@ -0,0 +1,9 @@ +echo "Gate bluetooth pairing agent on active bluetooth service" + +mkdir -p "$HOME/.config/systemd/user/" +cp "$OMARCHY_PATH/config/systemd/user/bt-agent.service" "$HOME/.config/systemd/user/" +systemctl --user daemon-reload + +if systemctl --user is-enabled --quiet bt-agent.service; then + systemctl --user reset-failed bt-agent.service 2>/dev/null || true +fi diff --git a/test/shell.d/systemd-test.sh b/test/shell.d/systemd-test.sh new file mode 100755 index 00000000..d254f512 --- /dev/null +++ b/test/shell.d/systemd-test.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +service="$ROOT/config/systemd/user/bt-agent.service" + +grep -Fx 'ExecCondition=/usr/bin/systemctl is-active --quiet bluetooth.service' "$service" >/dev/null +pass "bt-agent skips when bluetooth.service is inactive" + +grep -Fx 'Restart=on-failure' "$service" >/dev/null +pass "bt-agent still restarts after runtime failures"