Skip to content

Only count this user's hyprsunset as running for night light - #14038

Open
manuaudio wants to merge 8 commits into
omacom:quattrofrom
manuaudio:fix/nightlight-own-hyprsunset
Open

manuaudio wants to merge 8 commits into
omacom:quattrofrom
manuaudio:fix/nightlight-own-hyprsunset

Conversation

@manuaudio

@manuaudio manuaudio commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14037.

Both night light paths used an unscoped pgrep -x hyprsunset: the CLI in bin/omarchy-toggle-nightlight and the shell service. On a multi-user machine, another user's process satisfied that lookup even though it belonged to a different Hyprland session. This user's process never started, so the temperature command had no socket to control.

I scoped both checks, including the CLI's newest-process lookup, to the effective user with $UID. The existing startup retry behavior is unchanged. I also incorporated two useful pieces from #14530 with co-author credit to @henningfutrell: the shell command now lives in NightlightModel.applyCommand, which lets the focused test execute it against mocks, and omarchy-restart-app scopes its pkill to the same user.

The regression models another user's running process and proves that both the CLI and shell service start this user's instance without touching the other one. It also covers an already-running instance and the finished, still-booting, and freshly-started timing paths. The service test runs without a login shell so profile setup cannot bypass its mocks.

Verified on a disposable Omarchy worker against current quattro: the old behavior reproduces the missing-socket failure; this head starts the session user's process, applies 4000K, returns to 6500K when disabled, and leaves the other user's process alone.

Checks:

  • test/shell.d/nightlight-test.sh: 18/18
  • test/shell.d/command-operand-boundaries-test.sh: pass
  • ./test/cli: pass
  • GitHub i18n-check and Greptile Review: pass

The full shell suite has the same six unrelated failures on this head and current quattro; none touches these files.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no new actionable issues were found.

Summary

This PR limits night-light process checks and application restarts to the calling user.

  • Night-light controls use this user's hyprsunset process.
  • App restarts stop only this user's matching process.

Previous discussion:

  • The UID mock now checks the supplied UID and covers an already-running instance.
  • manuaudio accepted leaving the existing startup policy unchanged because it comes from the target branch. Greptile accepted that explanation.
  • The service still calls the shared helper. The source-text checks were removed to meet the repository's testing rules.

Reviews (10) · Last reviewed commit: "Merge remote-tracking branch 'upstream/q..." · Reviewed by Greptile

Comment thread test/shell.d/nightlight-test.sh Resolved

@chessing234 chessing234 left a comment

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.

everything seems fine, ready to merge.

Comment thread bin/omarchy-toggle-nightlight Resolved
The loop's comment, from omacom#15035, says why a hyprsunset still starting needs the resend even once its socket answers: it applies its boot default after accepting a temperature. The rewrite in this branch described only an unopened socket, which loses the reason a process under three seconds old counts as starting, and is unrelated to scoping the lookup to this user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Oct 15, 2026
@greptile-apps

This comment has been minimized.

@omarchybot omarchybot added the ready Good to merge label Oct 15, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified. This fixes #14037 for both the toggle command and the bar's night light service.

Reproduced on an Omarchy worker (Hyprland 0.56.2, hyprsunset 0.4.0), with a second user's hyprsunset running and none for the session user:

  • quattro's omarchy-toggle-nightlight, and this branch with -u "$UID" removed again, both start nothing and leave hyprctl hyprsunset temperature failing with the issue's Couldn't connect to …/.hyprsunset.sock. quattro's shell service command does the same.
  • This branch starts the session user's own hyprsunset and sets 4000K, from the CLI and from omarchy-shell nightlight enable with the shell running from this branch. Disabling returns it to 6500K, and the other user's process is left alone.

Tests on the worker: test/shell.d/nightlight-test.sh passes 18 of 18 and ./test/cli passes. With the fix reverted, the new assertion fails, so the test is not vacuous.

Pushed one commit, 75f99b7. It restores the retry-loop comment in bin/omarchy-toggle-nightlight to its quattro wording from #15035. The rewrite described only an unopened socket. That drops the reason a hyprsunset under three seconds old still counts as starting: it can accept a temperature and then apply its boot default over it. The comment change was also unrelated to scoping the lookup. The code is unchanged.

Two optional test gaps, not blocking: removing -u "$UID" from the age lookup at line 44 alone would still pass, because the fake ps ignores its PID. And the grep on Service.qml checks that a string is present, not what the command does.

Second opinion: Codex Medium reviewed it in two rounds. It agreed that the user scoping is correct ($UID over $USER, the QML escaping, the newest-process lookup) and that the comment rewrite should go. It contributed the test-gap note above. Its last round, on 75f99b7, found nothing open. It can read this session's work, so its agreement is not guaranteed to be independent.

Competing fixes: #14041 and #14530 fix the same bug. This one is the oldest and covers both the CLI and the shell service. #14041 scopes only the CLI. #14530's extra pkill -u change to omarchy-restart-app is a separate path, since an ordinary user cannot signal another user's process anyway. Neither carries anything this one lacks for #14037.

CI is green. This now waits on the maintainer.

omarchybot and others added 2 commits October 16, 2026 07:01
The service's start-and-apply command moves into NightlightModel.applyCommand, so the test runs it against the mocks instead of grepping Service.qml for the string. It runs the script without -l, so no login profile can put the real commands ahead of the mocks.

Co-Authored-By: Henning Futrell <11961362+henningfutrell@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Another user's process of the same name belongs to their session; an unprivileged pkill could not signal it anyway and only reported the failure.

Co-Authored-By: Henning Futrell <11961362+henningfutrell@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot removed the ready Good to merge label Oct 16, 2026
Comment thread test/shell.d/nightlight-test.sh Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

Two parts of #14530 by @henningfutrell, which fixes the same bug and was decided in favour of this one, are now on this branch with credit to them:

  • 3ed8d77 moves the shell service's start-and-apply command into NightlightModel.applyCommand, so nightlight-test.sh now runs that command against mocks instead of grepping Service.qml for the string. It runs the script without -l, so a login profile cannot put the real commands ahead of the mocks. Service.qml sends the same command as before.
  • 41f7ac1 scopes pkill in omarchy-restart-app to -u "$UID". Its only caller is omarchy-restart-hyprsunset, which on a shared machine printed Operation not permitted trying to signal the other user's hyprsunset.

Checked on a worker built from the Omarchy ISO, with this head merged onto current quattro and another user's hyprsunset running. On quattro, and on this head with the scoping reverted, neither omarchy-toggle-nightlight nor the linked shell's nightlight enable starts one, and hyprctl hyprsunset temperature fails with the socket error from #14037. On this head both start this user's hyprsunset at 4000K and leave the other user's alone. The new service test fails if only the service's lookup is unscoped. nightlight-test.sh and command-operand-boundaries-test.sh pass, and so does ./test/cli. The full shell suite has six failures, the same six it has on current quattro. None of them is in a file this touches: the 18-column greeting, the block-art logo animation, da/menu.json, lock-view build time, a pre_remove exit status and the keepLoaded fixture's IPC.

Reviewed by Claude Opus 5.5, with Codex Medium as a second opinion. Codex found nothing to change: same command as before, a sound test, and no other unscoped hyprsunset lookup. Its independence is not guaranteed.

This stays verified but not ready, because the full suite is not green on quattro itself. That is waiting on the maintainer, not on the author.

@manuaudio

manuaudio commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @chessing234 — I appreciate the review. I also closed the remaining service-wiring coverage gap in 086768cd8; the focused tests pass, the branch is clean, and both GitHub checks are green. On Greptile’s separate startup-comment concern, I kept the explanation because live worker verification showed a process under three seconds can accept the command and then apply its boot default over it, which is why the retry remains.

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Oct 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed the new commit, 086768c, and verified this head again. Nothing found.

The commit adds an assertion to test/shell.d/nightlight-test.sh that Service.qml's runApply sends NightlightModel.applyCommand(temp), the command the test already runs against mocks. It closes the remaining gap: nothing previously tied the tested command to the one the service sends. With runApply changed back to building its own command inline, the new assertion fails, so it checks the wiring rather than its own presence.

Checked on a worker built from the Omarchy ISO, with this head merged onto current quattro (33783b1), the shell linked to it, and a process named hyprsunset running under a second user account. On quattro, and on this head with -u "$UID" removed, omarchy-toggle-nightlight starts nothing and hyprctl hyprsunset temperature fails with the socket error from #14037. On this head the toggle starts this user's own hyprsunset at 4000K and returns to 6500K, omarchy-shell nightlight enable does the same through the shell service, and the other user's process is left running. nightlight-test.sh passes 20 of 20 and fails with the scoping reverted. command-operand-boundaries-test.sh and ./test/cli pass.

Reviewed by Claude Opus 5.5, with Codex Medium as a second opinion. Codex found no defect in the new commit or the full diff. It noted that a check on the source text cannot rule out the assignment ending up in a dead branch, which is a limit of that kind of test and not something to change here. Its independence is not guaranteed.

This stays verified but not ready, because the full shell suite is not green on quattro itself. Seven test files fail, on this head and on quattro alike, and none of them touches night light. This now waits on the maintainer, not on the author.

…793113457

# Conflicts:
#	test/shell.d/nightlight-test.sh
@manuaudio

manuaudio commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

I merged current quattro (bc220e702) into this branch as 54b2de324. The only conflict was in test/shell.d/nightlight-test.sh; I kept the current base’s startup-race cases together with this PR’s current-user CLI/service checks and service-wiring assertion. The production change is unchanged.

Focused verification on the merged tree:

  • bash test/shell.d/nightlight-test.sh: 20/20 passed
  • test/shell.d/command-operand-boundaries-test.sh: 15/15 passed
  • bash -n on the two commands and two focused tests: passed
  • git diff --check: passed

A fresh Codex review against current quattro found no blocking security or logic issue and confirmed the conflict resolution preserves both sets of coverage. I did not run the broad local suites on ai-nab6.

Comment thread test/shell.d/nightlight-test.sh Resolved
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 28, 2026
…8-20261031

# Conflicts:
#	shell/plugins/services/nightlight/Service.qml
@manuaudio

Copy link
Copy Markdown
Contributor Author

I merged current quattro (690edc5ce) into this branch as 8da311ce9. The only conflict was in Service.qml: the resolution keeps this PR's current-user lookup and the base branch's identity-matrix reset when night light is disabled.

I added the reset behavior to the tested NightlightModel.applyCommand boundary. The new assertion failed before the resolution and passes now. Focused verification:

  • bash test/shell.d/nightlight-test.sh: 22/22 passed
  • bash test/shell.d/command-operand-boundaries-test.sh: 15/15 passed
  • bash -n on both commands and focused tests: passed
  • PR diff check against current quattro: passed

A fresh Codex review found no blocking security or logic issue. It also ran the two permitted focused tests and found the conflict resolution preserved both sides' behavior. I did not run test/all, test/shell, or test/cli locally.

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed the two merges of quattro and the test cleanup since 086768c, and verified this head, 8da311c, again. Nothing found.

The merge that brought in #14489 is resolved correctly. NightlightModel.applyCommand now takes a resetIdentity flag, and Service.qml passes temp === dayTemperature, so turning night light off still sends hyprctl hyprsunset identity after the temperature, as quattro does. The only difference from quattro's command is the -u "$UID" scoping. Taking out the tests that only read source text matches #16334 on quattro.

Checked on a worker built from the Omarchy ISO with the shell linked to each tree, and a process named hyprsunset running under a second user account. On quattro (690edc5), and on this head with the scoping in bin/ and Service.qml reverted, both omarchy-toggle-nightlight and omarchy-shell nightlight enable start nothing, and hyprctl hyprsunset temperature fails with the socket error from #14037. On this head both start this user's hyprsunset at 4000K. Turning it off returns it to 6500K, and --status reports it off. The other user's process keeps running, including through omarchy-restart-app hyprsunset. nightlight-test.sh passes 22 of 22 and fails with the scoping reverted. command-operand-boundaries-test.sh and ./test/cli pass. The full shell suite fails the same four tests on this head and on quattro, and none of them involves night light.

Reviewed by Claude Opus 5.5, with Codex Medium and muse-wonder (via pi, thinking high) as second opinions. Neither found a defect, and both agreed the merge resolution and the $UID scoping are right. Their independence is not guaranteed. They noted two gaps in the tests, neither of which needs changing here. Dropping -u from only the pgrep -n age lookup would not fail any test. Nothing runs Service.qml itself, so the identity flag it passes is checked by reading the code, not by a test.

#14041 and #14530 fix the same bug and are still open. This one is the oldest, it covers the CLI, the shell service and omarchy-restart-app, and it already includes what #14530 added. Choosing between them is up to the maintainer, and nothing is waiting on the author.

@manuaudio

Copy link
Copy Markdown
Contributor Author

This still merges cleanly on the current base; happy to adjust anything.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightlight toggle does nothing when another user has hyprsunset running

3 participants