From 6658680d750027d1d5f781e19a244745e1742fed Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 27 Sep 2026 21:26:46 +0000 Subject: [PATCH 1/4] Retry bt-agent until bluetooth.service is active ExecCondition skipped permanently when it raced bluetoothd at login, leaving the session with no pairing agent (#13247). Co-authored-by: AnPod --- default/systemd/user/bt-agent.service | 9 +++++---- test/shell.d/systemd-test.sh | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/default/systemd/user/bt-agent.service b/default/systemd/user/bt-agent.service index cad87cefd518..1e320716d52f 100644 --- a/default/systemd/user/bt-agent.service +++ b/default/systemd/user/bt-agent.service @@ -3,14 +3,15 @@ Description=Bluetooth pairing agent (auto-accept) Documentation=man:bt-agent(1) ConditionPathIsDirectory=/sys/class/bluetooth # bluez must be reachable on the system bus before we can register. -After=dbus.socket +After=dbus.socket bluetooth.service 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 +# ExecCondition would skip permanently when it races bluetooth.service at +# login (#13247). Fail the start instead so Restart=on-failure retries until +# bluetoothd is up. +ExecStartPre=/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/test/shell.d/systemd-test.sh b/test/shell.d/systemd-test.sh index ce7b79b703ed..395aa0623d6e 100755 --- a/test/shell.d/systemd-test.sh +++ b/test/shell.d/systemd-test.sh @@ -6,8 +6,11 @@ source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" service="$ROOT/default/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 'ExecStartPre=/usr/bin/systemctl is-active --quiet bluetooth.service' "$service" >/dev/null +pass "bt-agent retries when bluetooth.service is not yet active" + +grep -Fx 'After=dbus.socket bluetooth.service' "$service" >/dev/null +pass "bt-agent orders itself after bluetooth.service" grep -Fx 'Restart=on-failure' "$service" >/dev/null pass "bt-agent still restarts after runtime failures" From 41628d2f3221fde2821b458dd4e7347289702b05 Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:05:13 +0200 Subject: [PATCH 2/4] Drop the bluetooth.service ordering from the bt-agent user unit bt-agent is a user unit, and the user manager has no bluetooth.service: it loads as not-found, so After= ordered against nothing and the test asserting the line guarded nothing. The ExecStartPre check plus Restart=on-failure is what waits for the system bluetoothd. Co-Authored-By: Claude Opus 5.5 --- default/systemd/user/bt-agent.service | 2 +- test/shell.d/systemd-test.sh | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/default/systemd/user/bt-agent.service b/default/systemd/user/bt-agent.service index 1e320716d52f..d2c375cdb4eb 100644 --- a/default/systemd/user/bt-agent.service +++ b/default/systemd/user/bt-agent.service @@ -3,7 +3,7 @@ Description=Bluetooth pairing agent (auto-accept) Documentation=man:bt-agent(1) ConditionPathIsDirectory=/sys/class/bluetooth # bluez must be reachable on the system bus before we can register. -After=dbus.socket bluetooth.service +After=dbus.socket Requires=dbus.socket [Service] diff --git a/test/shell.d/systemd-test.sh b/test/shell.d/systemd-test.sh index 395aa0623d6e..f997fd3056bd 100755 --- a/test/shell.d/systemd-test.sh +++ b/test/shell.d/systemd-test.sh @@ -9,9 +9,6 @@ service="$ROOT/default/systemd/user/bt-agent.service" grep -Fx 'ExecStartPre=/usr/bin/systemctl is-active --quiet bluetooth.service' "$service" >/dev/null pass "bt-agent retries when bluetooth.service is not yet active" -grep -Fx 'After=dbus.socket bluetooth.service' "$service" >/dev/null -pass "bt-agent orders itself after bluetooth.service" - grep -Fx 'Restart=on-failure' "$service" >/dev/null pass "bt-agent still restarts after runtime failures" From b719dc0bf77ccc47951cf8b8a163a6a4f8a6109f Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:05:13 +0200 Subject: [PATCH 3/4] Don't fail first-run while bt-agent waits for bluetoothd With the bluetoothd check moved to ExecStartPre, starting bt-agent before bluetoothd is active fails the start job. enable-user-units.sh starts it under set -e, so on a first login racing bluetoothd it exited 1, failing the first-run step and skipping the owe theme-set hook after it. Start bt-agent with --no-block, so its own retries take over, and keep waiting on the other units so their failures still count. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Codex Medium --- install/user/first-run/enable-user-units.sh | 5 ++++- test/shell.d/systemd-test.sh | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/install/user/first-run/enable-user-units.sh b/install/user/first-run/enable-user-units.sh index e08885c9e0dc..d8c05c074788 100755 --- a/install/user/first-run/enable-user-units.sh +++ b/install/user/first-run/enable-user-units.sh @@ -13,7 +13,6 @@ set -euo pipefail systemctl --user daemon-reload systemctl --user enable --now \ - bt-agent.service \ owed.service \ omarchy-recover-internal-monitor.service \ omarchy-sleep-lock.service \ @@ -21,4 +20,8 @@ systemctl --user enable --now \ omarchy-fcitx5.service \ omarchy-crash-watch.service +# bt-agent fails its start until bluetoothd is up and retries on its own, so +# don't wait on it. +systemctl --user enable --now --no-block bt-agent.service + omarchy-hook-install theme-set /usr/share/owe/10-owe-sync diff --git a/test/shell.d/systemd-test.sh b/test/shell.d/systemd-test.sh index f997fd3056bd..8861175af252 100755 --- a/test/shell.d/systemd-test.sh +++ b/test/shell.d/systemd-test.sh @@ -31,6 +31,9 @@ grep -Fx 'systemctl --user daemon-reload' "$first_run_units" >/dev/null grep -F 'omarchy-sleep-lock.service' "$first_run_units" >/dev/null pass "first-run reloads and enables the sleep lock service" +grep -Fx 'systemctl --user enable --now --no-block bt-agent.service' "$first_run_units" >/dev/null +pass "first-run does not fail while bt-agent waits for bluetoothd" + upgrade_to_quattro="$ROOT/bin/omarchy-upgrade-to-quattro" grep -F '6870b232a6c0474b59187882e6d25ae771bba735098bcbedef8a2b73b97e2b6a' "$upgrade_to_quattro" >/dev/null grep -F 'bcd1a76cb5c63514922bc5e11af22ae480fc6d06a99863364e02bdf3c7bdceaf' "$upgrade_to_quattro" >/dev/null From e5805eb724e70bdfd9b3c161e87b05dcc099c1c9 Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Sun, 11 Oct 2026 03:52:28 +0200 Subject: [PATCH 4/4] Test that a missing bt-agent costs first-run only bt-agent bt-agent is enabled on its own line with --no-block ahead of --now, so the per-unit loop, which reads units after "--user enable --now", never covers it. Check it explicitly: first-run must report it and still enable everything else. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Codex Medium --- test/shell.d/first-run-test.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/shell.d/first-run-test.sh b/test/shell.d/first-run-test.sh index 16bc861b0f36..43c548041bf0 100644 --- a/test/shell.d/first-run-test.sh +++ b/test/shell.d/first-run-test.sh @@ -66,5 +66,10 @@ for unit in "${units[@]}"; do [[ $(<"$test_tmp/calls") == "$(grep -Fvx -- "--user enable --now $unit" <<<"$clean_run")" ]] || fail "a unit missing from the build costs first-run only that unit" "$unit" done +if enable_user_units bt-agent.service; then + fail "first-run reports a unit it could not enable" bt-agent.service +fi +[[ $(<"$test_tmp/calls") == "$(grep -Fvx -- "--user enable --no-block --now bt-agent.service" <<<"$clean_run")" ]] || + fail "a unit missing from the build costs first-run only that unit" bt-agent.service (( ${#units[@]} > 1 )) || fail "first-run enables each unit on its own" pass "a unit missing from the build costs first-run only that unit"