Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions default/systemd/user/bt-agent.service
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Repeated starts when Bluetooth stays down If a machine has a Bluetooth adapter but bluetooth.service is masked or persistently failing, this check fails on every start attempt. The existing two-second restart interval then produces repeated failures and log entries instead of leaving the unit idle as ExecCondition did. Consider a backoff or a way to distinguish delayed startup from a service that will not start.

Knowledge Base Used: Desktop session and window management

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

# 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
Expand Down
5 changes: 4 additions & 1 deletion install/user/first-run/enable-user-units.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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"
5 changes: 5 additions & 0 deletions test/shell.d/first-run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 5 additions & 2 deletions test/shell.d/systemd-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +9 to +10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Retry recovery remains untested This assertion checks that the pre-start command is present, but it does not test whether the agent starts after bluetooth.service changes from inactive to active. A test of that transition would protect the race fix; the current test could pass even if recovery stopped working.


grep -Fx 'Restart=on-failure' "$service" >/dev/null
pass "bt-agent still restarts after runtime failures"
Expand All @@ -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
Expand Down