Gate bluetooth pairing agent on active bluetooth service

This commit is contained in:
David Heinemeier Hansson
2026-05-25 23:05:00 +02:00
parent 9fb52fa37a
commit 322d1bc30d
3 changed files with 25 additions and 0 deletions
+3
View File
@@ -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
+9
View File
@@ -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
+13
View File
@@ -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"