diff --git a/default/systemd/user/bt-agent.service b/default/systemd/user/bt-agent.service index cad87cefd518..d2c375cdb4eb 100644 --- a/default/systemd/user/bt-agent.service +++ b/default/systemd/user/bt-agent.service @@ -8,9 +8,10 @@ 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/install/user/first-run/enable-user-units.sh b/install/user/first-run/enable-user-units.sh index 07534d4fee74..c7f953fde17d 100755 --- a/install/user/first-run/enable-user-units.sh +++ b/install/user/first-run/enable-user-units.sh @@ -19,7 +19,6 @@ systemctl --user daemon-reload # one unit, and that should not cost the session its bluetooth agent as well. failed=0 for unit in \ - bt-agent.service \ owed.service \ omarchy-recover-internal-monitor.service \ omarchy-sleep-lock.service \ @@ -31,5 +30,9 @@ for unit in \ systemctl --user enable --now "$unit" || failed=1 done +# bt-agent fails its start until bluetoothd is up and retries on its own, so +# don't wait on it. +systemctl --user enable --no-block --now bt-agent.service || failed=1 + omarchy-hook-install theme-set /usr/share/owe/10-owe-sync exit "$failed" 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" diff --git a/test/shell.d/systemd-test.sh b/test/shell.d/systemd-test.sh index 66074c8b3c19..85f88c1c936c 100755 --- a/test/shell.d/systemd-test.sh +++ b/test/shell.d/systemd-test.sh @@ -6,8 +6,8 @@ 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 'Restart=on-failure' "$service" >/dev/null pass "bt-agent still restarts after runtime failures" @@ -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 --no-block --now bt-agent.service || failed=1' "$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