Skip to content

Start hyprsunset for the current user when toggling nightlight - #14041

Open
nickolss wants to merge 1 commit into
omacom:quattrofrom
nickolss:fix-nightlight-per-user-hyprsunset
Open

nickolss wants to merge 1 commit into
omacom:quattrofrom
nickolss:fix-nightlight-per-user-hyprsunset

Conversation

@nickolss

@nickolss nickolss commented Oct 2, 2026

Copy link
Copy Markdown

Fixes #14037

omarchy-toggle-nightlight checked for hyprsunset with pgrep -x hyprsunset, which matches processes from every user. If another user on the machine has a Hyprland session with hyprsunset running, the toggle never starts one for the current session. Then hyprctl hyprsunset temperature can't reach a socket and the toggle silently does nothing.

This limits the check to the current user with pgrep -u "$USER" -x hyprsunset.

Testing

  • Added an assertion to test/shell.d/nightlight-test.sh that the toggle only looks for the current user's hyprsunset. It fails without the fix and passes with it.
  • ./test/all has the same 11 failures before and after this change on my machine. All of them are environment-related (vscode theme, omarchy-pkgs checkout, browser launcher, etc.) and none are in the nightlight tests.
  • Checked by hand on a machine with a second user logged in: the toggle did nothing before the fix, and works once hyprsunset runs in the current session.

🤖 Generated with Claude Code

The toggle checked for any hyprsunset process, so another logged-in user's
instance kept it from starting one for this session, and the toggle silently
did nothing.

Fixes omacom#14037

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Scopes nightlight daemon lookup to the current user.

The PR appears safe to merge, with non-blocking robustness and regression-test gaps.

Findings

  1. P2 Environment user can misidentify processes ▶
  2. P2 Startup branch remains untested ▶

Summary

The PR limits the nightlight toggle’s hyprsunset process check to a named user and adds an assertion for the new pgrep arguments.

  • The user identifier can be stale or absent in the command environment.
  • The test does not exercise daemon startup when the current user has no matching process.

Reviews (1) · Last reviewed commit: "Start hyprsunset for the current user wh..."

# Ensure hyprsunset is running
if ! pgrep -x hyprsunset >/dev/null; then
# Ensure hyprsunset is running in this session (another user may have their own)
if ! pgrep -u "$USER" -x hyprsunset >/dev/null; then

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 Environment user can misidentify processes. If USER is unset, pgrep fails and the toggle tries to start another hyprsunset even when one is running. If it names another logged-in user, that user's process can prevent the current user's daemon from starting. Use the running UID for this check.

Suggested change
if ! pgrep -u "$USER" -x hyprsunset >/dev/null; then
if ! pgrep -u "$(id -u)" -x hyprsunset >/dev/null; then

Comment on lines +43 to 44
printf '%s\n' "$*" >>"$PGREP_LOG"
exit 0

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 Startup branch remains untested. The pgrep stub always reports that a process exists, while the new assertion checks only the arguments passed to it. The test therefore cannot catch a failure to start hyprsunset when only another user has one running. Model that case in the stub and assert that startup occurs.

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!

@jandrusk

jandrusk commented Oct 6, 2026

Copy link
Copy Markdown

Thanks for the fix! Heads up that #14038 (opened about 20 minutes earlier for the same issue, #14037) covers the toggle too and also the second copy of this check in shell/plugins/services/nightlight/Service.qml (runApply). That copy still uses an unscoped pgrep -x hyprsunset, so with only this PR the shell's own night light service can still skip starting hyprsunset when another user has one running.

Small difference between the two: #14038 uses -u "$UID", and you use -u "$USER". $UID is set by bash itself, while $USER comes from the environment and can be stale or unset under some launchers, so I'd go with $UID. It probably makes sense to consolidate on #14038, or to pick up the Service.qml change here.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this, @nickolss. The cause is right: pgrep -x hyprsunset matches every user's processes, and current quattro still has that unscoped check, so #14037 is a real bug.

Three open pull requests fix #14037: #14038 (opened about 20 minutes before this one), this one, and #14530. #14038 is the one going forward. It is older, which wins by default, and it also covers two places this one leaves unscoped:

  • shell/plugins/services/nightlight/Service.qml (runApply) starts hyprsunset with the same unscoped pgrep -x hyprsunset, so the shell's night light service still fails for the second user with only this change.
  • On current quattro, bin/omarchy-toggle-nightlight has a second lookup, pgrep -nx hyprsunset, which picks the process whose age decides whether to wait for it to finish starting. This branch predates it, which is why it no longer merges cleanly, and scoping only the first lookup would leave that one reading another user's process.

#14038 also uses $UID, which bash sets itself, rather than $USER from the environment. Nothing here carries over that #14038 lacks, so this pull request was not run on a test machine: verifying a fix that will not be merged spends one for nothing.

Checked by reading the three diffs against current quattro. Codex Medium reviewed the three side by side and separately chose #14038 for the same reasons; it could read this session's working, so treat that as agreement rather than an independent check. This now waits on the maintainer, who decides what happens to the competing pull requests.

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