Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions install/user/first-run/enable-user-units.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
set -euo pipefail

systemctl --user daemon-reload
systemctl --user enable --now \

# One at a time: given a list, systemctl enables none of it when it cannot find
# 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 \
Expand All @@ -21,6 +25,9 @@ systemctl --user enable --now \
omarchy-fcitx5.service \
omarchy-crash-watch.service \
omarchy-usb-authorization.service \
omarchy-thunderbolt-authorization.service
omarchy-thunderbolt-authorization.service; do
systemctl --user enable --now "$unit" || failed=1
done

omarchy-hook-install theme-set /usr/share/owe/10-owe-sync
exit "$failed"
13 changes: 13 additions & 0 deletions test/shell.d/config-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ for source, destination, legacy in package_defaults:
if destination and (source not in pkgbuild or destination not in pkgbuild):
errors.append(f"PKGBUILD does not explicitly install {source} -> {destination}")

# A user unit has to be on the machine before anything turns it on: shipped in
# /usr/lib/systemd/user, or copied out of default/ by the command enabling it.
scripts = [path.read_text(errors="ignore") for folder in ("bin", "install", "migrations")
for path in (root / folder).rglob("*") if path.is_file()]
for unit in sorted(path.name for path in (root / "default/systemd/user").glob("*.service")):
if f"/usr/lib/systemd/user/{unit}" in pkgbuild:
continue
named = [text for text in scripts if unit in text]
if not any("default/systemd/user/" in text for text in named):
errors.append(f"PKGBUILD does not ship default/systemd/user/{unit} and no command installs it")
elif any("systemctl --user enable" in text and "default/systemd/user/" not in text for text in named):
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
errors.append(f"{unit} is enabled without being shipped by PKGBUILD or installed first")

# Existing users have an absolute wants symlink to the old unit path, and the
# migration that repoints it only runs for users who run an update -- the
# opposite of who the notifier is for. Dropping this alias strands them.
Expand Down
21 changes: 21 additions & 0 deletions test/shell.d/first-run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,24 @@ if grep -F 'skip-first-run-update-notification' "$ROOT/install/user/first-run/wi
fi

pass "first-run uses one lifecycle completion marker"

# systemctl enables none of a list when one unit in it is unknown, so a unit
# missing from a build must cost first-run only that unit.
cat >"$mock_bin/systemctl" <<'SH'
#!/bin/bash
[[ $* != *omarchy-sleep-lock.service* ]] || exit 1
printf '%s\n' "$*" >>"$OMARCHY_TEST_CALLS"
SH
cat >"$mock_bin/omarchy-hook-install" <<'SH'
#!/bin/bash
echo hook >>"$OMARCHY_TEST_CALLS"
SH
chmod +x "$mock_bin/systemctl" "$mock_bin/omarchy-hook-install"

if PATH="$mock_bin:$PATH" OMARCHY_TEST_CALLS="$test_tmp/calls" bash "$ROOT/install/user/first-run/enable-user-units.sh"; then
fail "first-run reports a unit it could not enable"
fi
for expected in bt-agent.service omarchy-crash-watch.service hook; do
grep -Fq "$expected" "$test_tmp/calls" || fail "a unit missing from the build does not cost first-run $expected"
done
pass "a unit missing from the build costs first-run only that unit"