omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

omarchy-restart-hyprsunset kills hyprsunset and the uwsm-app relaunch dies silently — night light config changes never apply

Open gcap0n1 opened this issue 3 months ago • 2 comments

What happened

Running the official omarchy restart hyprsunset (or omarchy-restart-hyprsunset) kills the running hyprsunset and ends with no hyprsunset process at all. The replacement launched by omarchy-restart-app via setsid uwsm-app -- hyprsunset & dies within seconds, silently (no error in the command output, nothing in the user journal).

This matters more than a plain crash because hyprsunset reads ~/.config/hypr/hyprsunset.conf only at startup: users who edit the night-light temperature (or any profile) and restart to apply it end up with either a dead night light or a stale-tinted screen, and no visible error anywhere. It looks exactly like "my config change doesn't work / reverted".

Steps to reproduce

pgrep -a hyprsunset                     # e.g. 412508 hyprsunset — running
omarchy-restart-hyprsunset
sleep 2
pgrep -a hyprsunset                     # -> (empty)

Journal shows the replacement starting and then vanishing with no error:

uwsm_app-daemon[1228]: received: app -- hyprsunset
uwsm_app-daemon[1228]: sent: exec systemd-run --user --scope --slice=app-graphical.slice --unit=app-Hyprland-hyprsunset-8ff5fc60.scope --quiet --collect --same-dir -- hyprsunset
systemd[977]: Started hyprsunset.
# ... process gone seconds later, no stop/error line anywhere

The same death pattern hits every launch through the uwsm-app client when the launching context exits (which omarchy-restart-app always does, being a script that backgrounds and returns): three app-Hyprland-hyprsunset-*.scope instances started and disappeared within one debugging session, while a hyprsunset started outside uwsm (pkill -x hyprsunset; setsid hyprsunset >/dev/null 2>&1 &) survived two days of suspend/resume cycles.

Expected

omarchy-restart-hyprsunset should leave a working hyprsunset running with the current config.

Root cause (hypothesis)

omarchy-restart-app relaunches background daemons through the uwsm-app client, whose daemon wraps the app in systemd-run --user --scope. The scope appears to be torn down when the short-lived uwsm-app client process goes away — which is immediately, since omarchy-restart-app backgrounds it and exits. For a long-running daemon like hyprsunset this wrapper is the wrong lifetime model; a plain setsid exec (or a proper long-lived systemd-run --user --unit=... service) is what sticks.

Workaround

pkill -x hyprsunset
setsid hyprsunset >/dev/null 2>&1 &

System

  • Omarchy: dev (83881e97)
  • hyprsunset 0.4.0-3, Hyprland 0.56.2-1, quickshell 0.3.1-1
  • Kernel: 7.1.9-arch1-2
  • AMD Ryzen 5 5500U, Lucienne iGPU

gcap0n1 avatar Aug 27 '26 18:08 gcap0n1

Additional confirmed failure mode from an Omarchy 4.0.4-1 system, with a symbolized core.

A daily config updater called the official omarchy restart hyprsunset. The journal timeline was:

  • 00:05:52.958: config update completed
  • 00:05:53.017: uwsm-app -- hyprsunset requested
  • 00:05:53.026: replacement scope started
  • 00:05:53.032: replacement received SIGSEGV

The matching Arch debug symbols show two relevant threads:

main thread:
  Hyprland CTM blocked callback
  -> exit(1)

scheduler thread:
  CHyprsunset::schedule()
  -> CHyprsunset::currentProfile()
  -> std::chrono::current_zone()
  -> SIGSEGV in libstdc++.so.6

Hyprsunset's blocked callback runs because another CTM manager is still active. The Omarchy helper currently does:

pkill -x $1
setsid uwsm-app -- "$@" >/dev/null 2>&1 &

There is no wait between signaling the old process and starting its replacement. In this occurrence, the new process reached Hyprland roughly 9 ms after the launch request, before the old Hyprsunset had released exclusive CTM control. Hyprsunset 0.4.0 then calls exit(1) from the blocked callback while its scheduler is a detached thread; C++ static teardown races that thread's timezone lookup and turns the intended exit into a segfault.

The same SIGSEGV, at identical Hyprsunset/libstdc++ offsets and under the same scheduled restart, also occurred on August 30. A retry two seconds later succeeded once the previous CTM owner was gone. This makes the missing wait in omarchy-restart-app a confirmed trigger, though the UWSM lifetime behavior described in the original report may be an additional failure mode.

A robust fix would wait for the killed PID/process to disappear before relaunching, or manage Hyprsunset through a proper user service whose restart operation orders stop completion before start.

Filed by GPT-5 via Codex.

prestoncabe avatar Sep 19 '26 17:09 prestoncabe

Diagnosed against current quattro (c352b62d6); not reproduced on a worker, because the mechanism is established in source and an open pull request already fixes it.

What happens. omarchy-restart-hyprsunset calls omarchy-restart-app, which runs pkill -x hyprsunset and immediately relaunches (bin/omarchy-restart-app:6-7). pkill only delivers SIGTERM; the old hyprsunset still holds Hyprland's CTM manager while it shuts down. Hyprland sends a new CTM client blocked when one already exists, and hyprsunset 0.4.0 answers that with exit(1) (src/Hyprsunset.cpp, the setBlocked callback). So the replacement exits, the old one finishes exiting, and nothing is left running. That matches the timeline and core dump in @prestoncabe's comment.

The uwsm scope explanation in the original report does not hold up in source: uwsm-app execs the systemd-run --scope command the daemon hands back, so the client becomes the app's launcher rather than exiting and taking the scope with it. A direct setsid hyprsunset surviving is consistent with the race too, since it changes the timing.

Fix. #8732 already targets this issue (Fixes #8646): it waits for the old process to go before relaunching. It will be reviewed and run on a worker as its own item. Points for that review: after five seconds of waiting it launches anyway, it drops uwsm-app without that being the cause, and the other two places that start hyprsunset (bin/omarchy-toggle-nightlight and the shell's nightlight service) are not coordinated with it. #8164 (for #8161) changes the same script differently, by moving hyprsunset to a systemd user service, so the two will conflict; which approach lands is the maintainer's call.

Checked by Opus 5.5 in Claude Code, with Codex Medium as a second opinion. Codex reached the same mechanism on its own reading of the Hyprland and hyprsunset sources, and raised the points about #8732 above. Its independence from this review is not guaranteed.

This is waiting on the maintainer to pick between #8732 and #8164.

omarchybot avatar Oct 09 '26 04:10 omarchybot