omarchy-update-user-notify.path watched /usr/share/omarchy/migrations, but pacman writes that directory during every update, including the blessed omarchy update, which runs omarchy-migrate a step later. The watcher fired a critical notification for the migrations the update was already applying in the visible terminal. A watcher cannot tell that apart from a bypassed pacman -Syu, so the only trigger that never collides with a running update is a once-per-login check. The service that already ran at graphical-session.target is now the whole mechanism, renamed after the command it runs. That is also all the second-user case needs: markers are per-user, so anyone who did not run the update finds them missing at their next login. Login timing means the toast can be sent before the shell has claimed org.freedesktop.Notifications, so the notifier waits for a live server first. The wait is omarchy-first-run's, lifted into omarchy-notification-wait rather than duplicated. The package keeps omarchy-update-user-notify.service as a symlink onto the new unit. Existing users hold an absolute wants symlink to the old path, and the migration that repoints it only runs for users who run an update, which is the opposite of who the notifier is for. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
42 lines
1.5 KiB
Bash
Executable File
42 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Notify the user when Omarchy has pending migrations
|
|
|
|
set -euo pipefail
|
|
|
|
pending_migrations=$(omarchy-migrate --pending 2>/dev/null) || exit 0
|
|
pending_count=$(printf '%s\n' "$pending_migrations" | sed '/^[[:space:]]*$/d' | wc -l)
|
|
|
|
if (( pending_count == 1 )); then
|
|
message="Click to run 1 pending migration."
|
|
else
|
|
message="Click to run $pending_count pending migrations."
|
|
fi
|
|
|
|
notify_command=$(printf 'if [[ -n $(omarchy-notification-send -u critical -g "Pending Omarchy Migrations" %q -a) ]]; then omarchy-launch-floating-terminal-with-presentation omarchy-migrate; fi' "$message")
|
|
|
|
# This runs from omarchy-migrate-notify.service at graphical-session.target,
|
|
# which the session can reach before the shell has claimed
|
|
# org.freedesktop.Notifications. Without the wait the toast is sent into the
|
|
# void and the user never learns about their pending migrations.
|
|
omarchy-notification-wait || true
|
|
|
|
unit="omarchy-migrations-notification-$(date +%Y%m%d%H%M%S)"
|
|
systemd-run --user --scope --unit="$unit" bash -lc "$notify_command" >/dev/null 2>&1 && exit 0
|
|
|
|
# Reached when there is no user manager to run the scope under, such as a
|
|
# non-graphical shell, so fall back to telling the user in the terminal.
|
|
print_pending_migrations() {
|
|
echo "Omarchy has pending migrations. Run omarchy-migrate in a terminal to apply them:"
|
|
while IFS= read -r migration; do
|
|
[[ -n $migration ]] || continue
|
|
printf ' %s\n' "$migration"
|
|
done <<<"$pending_migrations"
|
|
}
|
|
|
|
if [[ -t 1 ]]; then
|
|
print_pending_migrations
|
|
else
|
|
print_pending_migrations >&2
|
|
fi
|