Skip to content

feat(brightness): lower brightness with hyprsunset - #13261

Open
vander00 wants to merge 3 commits into
omacom:quattrofrom
vander00:brightness
Open

vander00 wants to merge 3 commits into
omacom:quattrofrom
vander00:brightness

Conversation

@vander00

Copy link
Copy Markdown
Contributor

The brightness can be lower than the hardware's 1% with the hyprsunset utility.
When the backlight reaches 0%, brightness keys use hyprsunset gamma for 10 finer steps to 25% gamma possible.

The slider, OSD, and keyboard shortcut support values below 1%.
External display brightness behavior is unchanged.
image

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: in a sandbox with stubs modelled on hyprsunset v0.4.0 IPC and brightnessctl 0.5.x arithmetic, the brightness keys on an internal panel step down from 2% to 1%, then to hardware 0 (reported 1.0), then through ten gamma steps (93, 85, 78, 70, 63, 55, 48, 40, 33, 25, reported 0.9 to 0.0). The + keys retrace the same steps. With night light off and at most one profile in hyprsunset.conf, the hyprsunset started by the brightness script is stopped again once gamma returns to 100%. The new test passes on this head and fails on the base scripts.

The main concerns are at the edges: the 1% backlight floor is gone, gamma also dims external monitors, the monitor panel steps unevenly around 1%, and normal-range brightness changes now reset any hyprsunset gamma.

Default keys and the panel now write raw backlight 0

Base clamps the down key at 1% ((( target < 1 )) && target=1), a clamp added in #5525 ("Ensure we don't go below 1% / To prevent screen from turning off entirely on some models"). Base also binds Shift+Down "Brightness minimum" to 1%. The PR removes both limits: the down key steps to 0, media.lua binds Shift+Down to 0%, every absolute value below 1% runs brightnessctl set 0%, and the internal slider minimum is now 0. brightnessctl's default minimum is raw 0, so set 0% writes raw 0.

Sandbox run, max brightness 255, starting at raw 3 (1%):

Action Base This PR
5%- at 1% raw stays 3 raw 0, OSD 1.0
Shift+Down 1% → raw 3 0% → raw 0, gamma 25

On base, the precise down key (1%-) could already reach raw 0. The PR moves the plain down key, the minimum shortcut and the panel onto that path.

Impact: on panels whose backlight turns off at raw 0 (the case #5525 guarded against, also described in systemd's src/backlight/backlight.c), the first press below 1% blanks the screen while the OSD shows 1.0%, and the ten gamma steps are not visible. Getting back from the minimum takes 11 presses of the up key (Shift+Up jumps straight to 100%). The bindings are locked = true, so this also applies at the lock screen. Not reproduced on physical hardware.

Suggested change: keep the backlight at its existing 1% floor and apply the gamma steps on top of it, or make raw 0 opt-in.

Gamma dims external monitors too, with no way back from them

hyprsunset builds one colour matrix (src/Hyprsunset.cpp:93-94) and applies it to every bound output in reload(). v0.4.0 has no per-output option. The Apple and DDC branches of omarchy-brightness-display never touch gamma, and the external panel slider keeps its minimum of 1.

Sandbox run:

internal eDP-1: 0%           -> gamma 25, brightness-owned hyprsunset running
focus DP-1:     +5%, +5%     -> DDC stub only, gamma stays 25
focus DP-1:     100%, 80%    -> DDC stub only, gamma stays 25

Impact: dimming the laptop below 1% also dims connected external monitors down to 25% gamma. After focus moves to an external monitor, or the lid closes in clamshell mode, the keys and panel only adjust DDC, and the picture stays dimmed until brightness is raised on the internal panel again, hyprsunset restarts, or hyprsunset re-applies its configured profile at the profile's time (07:00 in the shipped config). This differs from the description's "External display brightness behavior is unchanged".

Suggested change: one option is to reset gamma to 100% when an Apple or DDC display is adjusted. Because gamma is global, this also lifts the internal panel back to the 1.0 level, so the trade-off is worth stating in the code or docs. The script only runs on key presses, so it cannot react to focus changes by itself.

Monitor panel sticks at 1% going up and jumps to the minimum going down

In Panel.qml, the keyboard handler and the bar-icon wheel use a 0.1 step whenever brightnessPercent <= 1, otherwise the full step. Model.clampBrightness rounds values of 1 or more to integers, so 1 + 0.1 rounds back to 1. Going down, the full step is not clamped at 1 before entering the sub-1% range.

Results from a Node harness that loads the pinned Model.js and copies the Panel expressions verbatim (internal eDP-1):

Start Action Result
1 l five times 1 → 1, 1, 1, 1, 1
0.8 l five times 0.8 → 0.9, 1, 1, 1, 1
2 to 5 h once 0 (sends 0%: hardware 0 plus gamma 25)
3 bar scroll down 0

External monitors are unaffected (l from 1 on DP-1 gives 1, 6, 11). QML was not run in Quickshell.

Impact: on internal displays, keyboard l and bar scroll-up cannot leave 1%, and one step down from 2 to 5% goes straight to the darkest level.

Suggested change: use the 0.1 step only when going down from 1 or less, or up from below 1. When stepping down from above 1, stop at 1 first.

Normal-range brightness changes reset hyprsunset gamma and depend on its IPC

After every step at hardware above 0, and before every absolute set of 1% or more, the script now runs omarchy-brightness-display-gamma set 100 and exits on failure. set runs whenever pgrep -n -x hyprsunset finds any hyprsunset, not only one the script started, and makes up to 10 attempts 0.2 s apart before failing.

Sandbox run with hyprsunset started outside the script (profile gamma 0.8, backlight at 50%):

Action Base gamma This PR gamma
+5% 80 100
5%- 80 100
40% 80 100

Impact: a gamma the user set through hyprsunset.conf, -g or hyprctl hyprsunset gamma is overwritten by the next brightness key press. Brightness keys also now depend on hyprsunset IPC at every level: when pgrep sees a hyprsunset whose IPC does not answer (simulated in the sandbox), each normal-range key press exits 1 after about 2 s with no OSD, absolute sets leave the backlight unchanged because the gamma reset runs first, and at hardware 0 the keys fail immediately and brightness stays at 0.

Suggested change: record in the state file when this script lowers gamma, and reset to 100 only while that record exists. Also scope pgrep to the current user (pgrep -u "$UID"), and don't abort a hardware brightness change when the gamma reset fails.

Night light note: a hyprsunset started by the brightness script loads the shipped identity profile at 6000 K. omarchy-toggle-nightlight only turns night light on from an empty value or 6500, so after dimming below 1% the first Super+Ctrl+N press sets 6500 and only the second gives 4000 (sandbox run). Base already behaves this way when hyprsunset is autostarted, which Omarchy does not do by default.

Related open PR: #13332 ("Fall back to hyprsunset gamma on displays without DDC/CI") also changes bin/omarchy-brightness-display. It defines its own gamma_brightness function, which returns hyprsunset's current gamma as an integer percentage (its writes are clamped to 20 to 100), while this PR's function returns 0.0 to 1.0. Since hyprsunset gamma applies to every output, the two features would also overwrite each other's gamma if both were merged.

Optional test improvement: in test/shell.d/brightness-display-gamma-test.sh, replacing the PID ownership check in owned_pid() ([[ $(running_pid) == "$pid" ]] || return 1), which cleanup calls, with true still passes every case, and so does disabling the multi-profile guard. The "preexisting hyprsunset is preserved" case passes because the state file is already absent, and the fixture config has only one profile. Covering the ownership check needs a case where the state file names a live process other than the running hyprsunset, asserting that this process survives cleanup. A case with a two-profile hyprsunset.conf would cover the other guard.


Review information

Test scope: source review of the head plus hyprsunset v0.4.0, Hyprland v0.56.2 (hyprctl, CTM protocol) and brightnessctl sources. Sandboxed runs of the real scripts against stubs modelled on hyprsunset IPC and brightnessctl; the Panel and OSD logic ran in a Node harness, not Quickshell. No real hyprsunset, Hyprland, backlight hardware or external monitor was used, so the raw-0 blanking relies on #5525 and systemd's documentation. The related test/shell.d tests pass on head and base. In a full test/shell.d run, head and base had the same environment-related failures, and the new test was the only difference.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@llstrk

llstrk commented Sep 29, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: at 98c9a1af the gamma test fails, and on quattro plain keys skip the gamma range.

Earlier review: raw 0 and gamma resets resolved (IPC dependence returns at 1%); panel keys resolved (not the slider wheel); external monitors dimmed still present.

brightness-display-gamma-test.sh fails

Exits 1 at brightness reaches hardware zero: two blocks still expect the raw-0 handoff. Impact: no CI flags it.

Suggested change: update them for the 1% floor.

Reproducer (fails at de7857a and 98c9a1a)

The PR's own test fails at 98c9a1af51 and de7857a43e

Run in a checkout of the PR head 98c9a1af51 or the previous head de7857a43e (needs bash, awk and ripgrep; no hardware, Hyprland or hyprsunset):

bash test/shell.d/brightness-display-gamma-test.sh

Actual output at de7857a43e:

not ok - brightness reaches hardware zero
(exit status 1)

Actual output at the earlier reviewed head fd986e1213:

ok - hardware reaches zero before gamma changes
ok - gamma range has ten steps and a 25-percent floor
ok - absolute brightness and OSD support fractional values
ok - preexisting hyprsunset is preserved
ok - night light retains the process only while needed
(exit status 0)

Every assertion that disagrees with the tree, identical at de7857a43e and 98c9a1af51 (diagnostic copy of the same test with fail() redefined to print instead of exit, so it continues past the first failure; not a change to propose):

not ok - brightness reaches hardware zero
not ok - hyprsunset waits until a gamma adjustment is needed
not ok - hardware zero at neutral gamma reports the handoff level
ok - hardware reaches zero before gamma changes
not ok - first gamma step is 93 percent
not ok - first gamma step reports 0.9 percent
ok - gamma range has ten steps and a 25-percent floor
ok - absolute brightness and OSD support fractional values
ok - preexisting hyprsunset is preserved
ok - night light retains the process only while needed

The five failing assertions are the first two blocks, which still describe the old handoff (backlight to raw 0, hyprsunset untouched until then, 1.0 reported at hardware 0, first gamma step on the third press). Both heads now stop the backlight at 1% and apply gamma 93 when a Down press at 1% would have gone below it.

Still reproduces after the head moved

The author pushed 98c9a1af51 ("fix: no more delay for changing brightness") during this review; it changes only the two brightness scripts.

Actual output on the newer head 98c9a1af51:

not ok - brightness reaches hardware zero
(exit status 1)

quattro runs plain keys in the shell

Since #13427, plain Up/Down on internal panels run BrightnessKeys.qml, not the script. Impact: after a clean merge, Down stops at 1%, and Up keeps the lowered gamma.

Suggested change: make BrightnessKeys.handle() defer to the script when lowering from 1% or while the gamma state file exists.

Reproducer (fails on the merge into quattro e332dc9)

With current quattro, the plain brightness keys bypass the gamma range

Since #13427 (commit d3fb028, "Step the internal backlight in the shell instead of a script per keypress"), quattro binds XF86MonBrightnessUp/Down to { brightness = "raise" } / { brightness = "lower" }. default/hypr/helpers.lua dispatches them as Hyprland global shortcuts (listed in default/omarchy/shortcuts), and on an internal panel shell/services/BrightnessKeys.qml writes brightnessctl set <BrightnessModel.brightnessKeyTarget(action, current)>% directly, never running omarchy-brightness-display. The PR merges cleanly into quattro e332dc975d:

git checkout e332dc975d
git merge --no-ff 98c9a1af51   # clean merge; de7857a43e also merges cleanly

The two tests below use the mocks from test/shell.d/brightness-display-gamma-test.sh and drive the shell's step through the tree's own shell/services/BrightnessModel.js (Node). QML is not run. Save each as test/shell.d/<name> in the merged tree and run bash test/shell.d/<name>.

Plain Down at 1% never reaches the gamma steps

brightness-display-gamma-shell-keys-test.sh:

#!/bin/bash
# Reproducer for the PR merged into current quattro (#13427 "Step the internal
# backlight in the shell instead of a script per keypress").
# On quattro the plain XF86MonBrightnessUp/Down keys are Hyprland global
# shortcuts; on an internal panel shell/services/BrightnessKeys.qml handles them
# with one `brightnessctl set <BrightnessModel.brightnessKeyTarget(action, current)>%`
# and never runs omarchy-brightness-display. This test drives that same step
# (BrightnessModel.js, read from the tree) with the mocks from
# test/shell.d/brightness-display-gamma-test.sh. QML itself is not run.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

[[ -f $ROOT/shell/services/BrightnessModel.js ]] || { skip "tree has no in-shell brightness keys"; exit 0; }
grep -q 'brightness = "raise"' "$ROOT/default/hypr/bindings/media.lua" || fail "plain brightness keys are bound to the shell shortcut"

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'profile {\n  identity = true\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
printf 'eDP-1\n'
SH
cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH
cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH
cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH
cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH
cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
SH
cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then printf '%s\n' "$3" >"$TEST_ROOT/gamma"; else cat "$TEST_ROOT/gamma"; fi
  ;;
temperature) cat "$TEST_ROOT/temperature" ;;
*) exit 1 ;;
esac
SH
cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH
chmod +x "$mock_bin"/*

run_brightness() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-brightness-display" "$@"
}

# The in-shell key: one brightnessctl write, no omarchy-brightness-display.
shell_key() {
  local current target
  current=$(<"$test_tmp/hardware")
  target=$(node -e 'console.log(require(process.argv[1]).brightnessKeyTarget(process.argv[2], Number(process.argv[3])))' \
    "$ROOT/shell/services/BrightnessModel.js" "$1" "$current")
  TEST_ROOT="$test_tmp" PATH="$mock_bin:$PATH" brightnessctl -q -d mock_backlight set "$target%"
}

printf '1\n' >"$test_tmp/hardware"
shell_key lower
shell_key lower
printf 'after two plain Down presses at 1%%: hardware=%s hyprsunset=%s\n' "$(<"$test_tmp/hardware")" "$([[ -e $test_tmp/running ]] && echo started || echo 'not started')"
[[ -e $test_tmp/running ]] || fail "plain Down at 1% enters the gamma range"
pass "plain Down at 1% enters the gamma range"

Actual output on the merge of de7857a43e into e332dc975d:

after two plain Down presses at 1%: hardware=1 hyprsunset=not started
not ok - plain Down at 1% enters the gamma range
(exit status 1)

Plain Up out of the dimmed range leaves gamma at 25%

brightness-display-gamma-shell-up-test.sh:

#!/bin/bash
# Reproducer for the PR merged into current quattro (#13427): after dimming
# below 1% (Shift+Down runs omarchy-brightness-display 0%), the plain Up key is
# handled in the shell (BrightnessKeys.qml -> brightnessctl set N%) and never
# resets the hyprsunset gamma. Mocks as in brightness-display-gamma-test.sh;
# the shell step uses the tree's BrightnessModel.js. QML itself is not run.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

[[ -f $ROOT/shell/services/BrightnessModel.js ]] || { skip "tree has no in-shell brightness keys"; exit 0; }

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'profile {\n  identity = true\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
printf 'eDP-1\n'
SH
cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH
cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH
cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH
cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH
cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
SH
cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then printf '%s\n' "$3" >"$TEST_ROOT/gamma"; else cat "$TEST_ROOT/gamma"; fi
  ;;
temperature) cat "$TEST_ROOT/temperature" ;;
*) exit 1 ;;
esac
SH
cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH
chmod +x "$mock_bin"/*

run_brightness() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-brightness-display" "$@"
}

shell_key() {
  local current target
  current=$(<"$test_tmp/hardware")
  target=$(node -e 'console.log(require(process.argv[1]).brightnessKeyTarget(process.argv[2], Number(process.argv[3])))' \
    "$ROOT/shell/services/BrightnessModel.js" "$1" "$current")
  TEST_ROOT="$test_tmp" PATH="$mock_bin:$PATH" brightnessctl -q -d mock_backlight set "$target%"
}

run_brightness --no-osd 0%
printf 'after Shift+Down: hardware=%s%% gamma=%s\n' "$(<"$test_tmp/hardware")" "$(<"$test_tmp/gamma")"
for _ in 1 2 3 4 5 6; do shell_key raise; done
printf 'after six plain Up presses: hardware=%s%% gamma=%s reported=%s\n' "$(<"$test_tmp/hardware")" "$(<"$test_tmp/gamma")" "$(run_brightness)"
[[ $(<"$test_tmp/gamma") == "100" ]] || fail "plain Up out of the gamma range restores full gamma"
pass "plain Up out of the gamma range restores full gamma"

Actual output on the merge of de7857a43e into e332dc975d:

after Shift+Down: hardware=1% gamma=25
after six plain Up presses: hardware=15% gamma=25 reported=15
not ok - plain Up out of the gamma range restores full gamma
(exit status 1)

Both tests skip on the PR head and on the earlier reviewed head, because those trees predate the in-shell keys: the problem only appears once the PR is combined with current quattro.

Still reproduces after the head moved

The author pushed 98c9a1af51 ("fix: no more delay for changing brightness") during this review; it changes only the two brightness scripts.

Actual output on the merge of the newer head 98c9a1af51 into e332dc975d (plain Down):

after two plain Down presses at 1%: hardware=1 hyprsunset=not started
not ok - plain Down at 1% enters the gamma range
(exit status 1)

Actual output on the merge of the newer head 98c9a1af51 into e332dc975d (plain Up):

after Shift+Down: hardware=1% gamma=25
after six plain Up presses: hardware=15% gamma=25 reported=15
not ok - plain Up out of the gamma range restores full gamma
(exit status 1)
More findings: Gamma still dims external monitors, with no way back from them (still present)

Gamma still dims external monitors, with no way back from them (still present)

The Apple and DDC branches still never reset gamma, and hyprsunset applies one matrix to every output. After dimming the laptop below 1%, keys and panel on a focused external monitor leave it at 25% gamma. The PR description still says "External display brightness behavior is unchanged".

Impact: external monitors stay dimmed until the internal panel is brought back to 1% or more through the script (Shift+Up, the panel, or the step keys at the PR head), or hyprsunset restarts.

Suggested change: call gamma_command release || true in the Apple and DDC branches (it only resets a gamma this script recorded, and lifts the internal panel back to 1%), and update the description.

Reproducer:

Gamma lowered on the internal panel stays lowered while adjusting an external monitor

brightness-display-gamma-external-test.sh (mocks from test/shell.d/brightness-display-gamma-test.sh, plus a DDC helper stub and a switchable focused monitor). Save as test/shell.d/brightness-display-gamma-external-test.sh and run bash test/shell.d/brightness-display-gamma-external-test.sh.

#!/bin/bash
# Reproducer: after dimming the internal panel below 1%, adjusting a focused
# external (DDC) monitor leaves the global hyprsunset gamma lowered.
# Mocks are the ones from test/shell.d/brightness-display-gamma-test.sh, plus a
# DDC helper stub and a switchable focused monitor.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'eDP-1\n' >"$test_tmp/focused"
printf 'profile {\n  identity = true\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
cat "$TEST_ROOT/focused"
SH

cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH

cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH

cat >"$mock_bin/omarchy-brightness-display-ddc" <<'SH'
#!/bin/bash
printf 'ddc %s\n' "$*" >>"$TEST_ROOT/events"
printf '80\n'
SH

cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH

cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH

cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
SH

cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then
    printf '%s\n' "$3" >"$TEST_ROOT/gamma"
  else
    cat "$TEST_ROOT/gamma"
  fi
  ;;
temperature)
  cat "$TEST_ROOT/temperature"
  ;;
*) exit 1 ;;
esac
SH

cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH

chmod +x "$mock_bin"/*

run_brightness() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-brightness-display" "$@"
}

run_brightness --no-osd 0%
[[ $(<"$test_tmp/gamma") == "25" ]] || fail "Shift+Down dims the internal panel with gamma 25"
pass "internal panel dimmed to gamma 25"

printf 'DP-1\n' >"$test_tmp/focused"
run_brightness --no-osd +5%
run_brightness --no-osd 100%
run_brightness --no-osd --monitor DP-1 80%
grep -c '^ddc DP-1' "$test_tmp/events" | grep -qx 3 || fail "external adjustments reach the DDC helper"
printf 'gamma after adjusting DP-1: %s\n' "$(<"$test_tmp/gamma")"
[[ $(<"$test_tmp/gamma") == "100" ]] || fail "adjusting the external monitor restores full gamma on it"
pass "adjusting the external monitor restores full gamma on it"

Actual output at the previous head de7857a43e:

ok - internal panel dimmed to gamma 25
gamma after adjusting DP-1: 25
not ok - adjusting the external monitor restores full gamma on it
(exit status 1)

Actual output at the earlier reviewed head fd986e1213 (same result):

ok - internal panel dimmed to gamma 25
gamma after adjusting DP-1: 25
not ok - adjusting the external monitor restores full gamma on it
(exit status 1)

Still reproduces after the head moved

The author pushed 98c9a1af51 ("fix: no more delay for changing brightness") during this review; it changes only the two brightness scripts.

Actual output on the newer head 98c9a1af51:

ok - internal panel dimmed to gamma 25
gamma after adjusting DP-1: 25
not ok - adjusting the external monitor restores full gamma on it
(exit status 1)
More findings: New at 98c9a1a: step keys at 1% fail when hyprsunset IPC does not answer

New at 98c9a1a: step keys at 1% fail when hyprsunset IPC does not answer

step up|down exits 1 when pgrep -n -x hyprsunset finds a process but hyprctl hyprsunset gamma fails, and the caller falls back to the hardware step only on exit 2. pgrep is not scoped to the user, so another user's hyprsunset also triggers this.

Impact: at 1%, +5%, +1% and 5%- exit 1 without changing brightness. At de7857a4 the same case completed normally.

Suggested change: exit 2 when the IPC read fails, and use pgrep -u "$UID".

Reproducer:

(Head 98c9a1a) Step keys at 1% exit 1 while a hyprsunset is visible to pgrep but its IPC does not answer

Commit 98c9a1af51 ("fix: no more delay for changing brightness") routes every step key at hardware 1% through omarchy-brightness-display-gamma step up|down, which exits 1 when pgrep -n -x hyprsunset finds a process but hyprctl hyprsunset gamma fails. The caller only falls back to the hardware step on exit 2. pgrep is not scoped to the user, so another logged-in user's hyprsunset also triggers this. On current quattro the plain keys on an internal panel go through the shell instead (#13427), so there this affects the Alt precise keys and the script fallback.

Save as test/shell.d/brightness-display-gamma-ipc-test.sh and run bash test/shell.d/brightness-display-gamma-ipc-test.sh (mocks from test/shell.d/brightness-display-gamma-test.sh):

#!/bin/bash
# Reproducer: at 1% with a hyprsunset that pgrep finds but hyprctl cannot reach
# (hung IPC, or another user's hyprsunset: running_pid() uses pgrep without -u),
# the step keys exit 1 without changing the backlight.
# Mocks are the ones from test/shell.d/brightness-display-gamma-test.sh.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'eDP-1\n' >"$test_tmp/focused"
printf 'profile {\n  identity = true\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
cat "$TEST_ROOT/focused"
SH

cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH

cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH

cat >"$mock_bin/omarchy-brightness-display-ddc" <<'SH'
#!/bin/bash
printf 'ddc %s\n' "$*" >>"$TEST_ROOT/events"
printf '80\n'
SH

cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH

cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH

cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
SH

cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then
    printf '%s\n' "$3" >"$TEST_ROOT/gamma"
  else
    cat "$TEST_ROOT/gamma"
  fi
  ;;
temperature)
  cat "$TEST_ROOT/temperature"
  ;;
*) exit 1 ;;
esac
SH

cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH

chmod +x "$mock_bin"/*

run_brightness() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-brightness-display" "$@"
}

printf '1\n' >"$test_tmp/hardware"
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$test_tmp/running"
printf '100\n' >"$test_tmp/gamma"
# hyprsunset IPC unreachable
printf '#!/bin/bash\nexit 1\n' >"$mock_bin/hyprctl"

status=0
run_brightness --no-osd +5% || status=$?
printf '+5%% at 1%%: exit=%s hardware=%s%%\n' "$status" "$(<"$test_tmp/hardware")"
[[ $(<"$test_tmp/hardware") == "2" ]] || fail "brightness up from 1% works while hyprsunset IPC is unreachable"
pass "brightness up from 1% works while hyprsunset IPC is unreachable"

Actual output at 98c9a1af51:

+5% at 1%: exit=1 hardware=1%
not ok - brightness up from 1% works while hyprsunset IPC is unreachable
(exit status 1)

Actual output at the previous head de7857a43e:

+5% at 1%: exit=0 hardware=2%
ok - brightness up from 1% works while hyprsunset IPC is unreachable
(exit status 0)

Same result on the merge of 98c9a1af51 into quattro e332dc975d:

+5% at 1%: exit=1 hardware=1%
not ok - brightness up from 1% works while hyprsunset IPC is unreachable
(exit status 1)
More findings: A single hyprsunset.conf profile stays applied after brightness recovers

A single hyprsunset.conf profile stays applied after brightness recovers

hyprsunset applies a lone profile at start whatever the time, and cleanup() keeps the process alive when its temperature is below 6000 K. With one temperature = 4000 profile and no hyprsunset autostart (the manual's night light example without launch_on_start), the hyprsunset started by the brightness script applies 4000 K and keeps it after brightness returns to 100%. On base the brightness keys never start hyprsunset.

Impact: a warm tint appears during the day and stays until night light is toggled (or longer when prepare left it unrecorded). At 98c9a1af any Down step to 5% or below starts it, through prepare.

Suggested change: record the temperature when the script starts hyprsunset, and let cleanup() also stop an owned process whose temperature has not changed since then, or document this.

Reproducer:

A warm single-profile hyprsunset.conf stays applied after the brightness script's hyprsunset should stop

The manual (manual/13-toggles-idle-screensaver.md) tells users who want night light by the clock to replace the identity profile with profile { time = 20:00; temperature = 4000 } and to autostart hyprsunset. With autostart, the brightness script never owns that process and nothing changes. Without autostart, dimming below 1% starts hyprsunset, which applies the single profile at once (hyprsunset v0.4.0 currentProfile() returns 0 whenever there is exactly one profile, so the time is ignored), and cleanup() keeps the process because its temperature is below 6000. On 98c9a1af a Down step key landing at 5% or below starts it too (prepare).

Save as test/shell.d/brightness-display-gamma-single-profile-test.sh and run bash test/shell.d/brightness-display-gamma-single-profile-test.sh (mocks from test/shell.d/brightness-display-gamma-test.sh):

#!/bin/bash
# Reproducer: hyprsunset.conf holds one non-identity profile (the manual's
# `time = 20:00, temperature = 4000`) and hyprsunset is not autostarted. Dimming
# below 1% starts hyprsunset, which applies that profile at once; when
# brightness recovers, cleanup() keeps the process because its temperature is
# below 6000, so the 4000K tint stays on. Before this PR the brightness keys
# never started hyprsunset. Mocks as in brightness-display-gamma-test.sh, with
# `hyprctl hyprsunset temperature N` recorded and omarchy-shell stubbed.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'eDP-1\n' >"$test_tmp/focused"
# The manual's time profile, used without autostarting hyprsunset. With a single
# profile hyprsunset applies it at start whatever the time (currentProfile()
# returns 0), so a started hyprsunset reports 4000.
printf 'profile {\n    time = 20:00\n    temperature = 4000\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"
printf '4000\n' >"$test_tmp/temperature"
printf '100\n' >"$test_tmp/gamma"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
cat "$TEST_ROOT/focused"
SH

cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH

cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH

cat >"$mock_bin/omarchy-brightness-display-ddc" <<'SH'
#!/bin/bash
printf 'ddc %s\n' "$*" >>"$TEST_ROOT/events"
printf '80\n'
SH

cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH

cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH

cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
SH

cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then
    printf '%s\n' "$3" >"$TEST_ROOT/gamma"
  else
    cat "$TEST_ROOT/gamma"
  fi
  ;;
temperature)
  if [[ -n ${3:-} ]]; then printf '%s\n' "$3" >"$TEST_ROOT/temperature"; else cat "$TEST_ROOT/temperature"; fi
  ;;
*) exit 1 ;;
esac
SH

cat >"$mock_bin/omarchy-shell" <<'SH'
#!/bin/bash
exit 0
SH

cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH

chmod +x "$mock_bin"/*

run_brightness() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-brightness-display" "$@"
}

hyprsunset_state() {
  if [[ -e $test_tmp/running ]] && kill -0 "$(<"$test_tmp/running")" 2>/dev/null; then
    printf 'running at %sK' "$(<"$test_tmp/temperature")"
  else
    printf 'not running'
  fi
}

printf '50\n' >"$test_tmp/hardware"
run_brightness --no-osd 0%
printf 'after Shift+Down: hardware=%s%% gamma=%s hyprsunset %s\n' "$(<"$test_tmp/hardware")" "$(<"$test_tmp/gamma")" "$(hyprsunset_state)"
run_brightness --no-osd 100%
printf 'after Shift+Up:   hardware=%s%% gamma=%s hyprsunset %s\n' "$(<"$test_tmp/hardware")" "$(<"$test_tmp/gamma")" "$(hyprsunset_state)"
[[ $(hyprsunset_state) == "not running" ]] || fail "the hyprsunset the brightness script started does not keep its warm profile on after brightness recovers"
pass "the hyprsunset the brightness script started does not keep its warm profile on after brightness recovers"

Actual output at 98c9a1af51:

after Shift+Down: hardware=1% gamma=25 hyprsunset running at 4000K
after Shift+Up:   hardware=100% gamma=100 hyprsunset running at 4000K
not ok - the hyprsunset the brightness script started does not keep its warm profile on after brightness recovers
(exit status 1)

Actual output at de7857a43e:

after Shift+Down: hardware=1% gamma=25 hyprsunset running at 4000K
after Shift+Up:   hardware=100% gamma=100 hyprsunset running at 4000K
not ok - the hyprsunset the brightness script started does not keep its warm profile on after brightness recovers
(exit status 1)

Same on the merge of 98c9a1af51 into quattro e332dc975d (Shift+Down/Up still run the script there):

after Shift+Down: hardware=1% gamma=25 hyprsunset running at 4000K
after Shift+Up:   hardware=100% gamma=100 hyprsunset running at 4000K
not ok - the hyprsunset the brightness script started does not keep its warm profile on after brightness recovers
(exit status 1)

Before this PR the brightness keys never start hyprsunset, so this configuration only takes effect when night light is toggled.

More findings: New at 98c9a1a: prepare can leave an unrecorded hyprsunset running

New at 98c9a1a: prepare can leave an unrecorded hyprsunset running

prepare checks hyprsunset's IPC once, right after pgrep sees the process. If that check runs before the socket answers, it exits before writing the state files, and none of the brightness or night light scripts stop that process later. This was reproduced with a modelled IPC start-up delay; real hyprsunset timing was not measured.

Impact: a hyprsunset that no state file records keeps running after brightness returns to normal.

Suggested change: retry the IPC check as set does, or record the process before checking.

Reproducer:

(Head 98c9a1a, modelled startup latency) A hyprsunset started by prepare can be left running unrecorded

prepare (started in the background when a Down step key lands at 5% or below) spawns hyprsunset, waits only until pgrep sees the process, then checks hyprctl hyprsunset gamma once, with no retry. If the IPC socket is not answering yet, it exits 1 before writing the state file, so cleanup never stops that hyprsunset. hyprsunset v0.4.0 binds its IPC socket only after the Wayland roundtrip and the first reload() (src/Hyprsunset.cpp init()); the 0.3 s delay below is a model, not a measured value.

Save as test/shell.d/brightness-display-gamma-prepare-test.sh and run bash test/shell.d/brightness-display-gamma-prepare-test.sh (mocks from test/shell.d/brightness-display-gamma-test.sh, with the IPC answering 0.3 s after start):

#!/bin/bash
# Reproducer (models startup latency): hyprsunset's IPC socket answers only after
# the Wayland roundtrip and first reload() in init(). Here it answers 0.3 s after
# the process appears. The background `prepare` started on the way down to 5%
# then leaves a hyprsunset running that no state file records, so nothing stops it.
# Mocks are the ones from test/shell.d/brightness-display-gamma-test.sh, with
# setsid/hyprctl extended for the latency.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'eDP-1\n' >"$test_tmp/focused"
printf 'profile {\n  identity = true\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
cat "$TEST_ROOT/focused"
SH

cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH

cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH

cat >"$mock_bin/omarchy-brightness-display-ddc" <<'SH'
#!/bin/bash
printf 'ddc %s\n' "$*" >>"$TEST_ROOT/events"
printf '80\n'
SH

cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH

cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH

cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
rm -f "$TEST_ROOT/ipc_ready"
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
( sleep 0.3; touch "$TEST_ROOT/ipc_ready" ) >/dev/null 2>&1 &
SH

cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running && -f $TEST_ROOT/ipc_ready ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then
    printf '%s\n' "$3" >"$TEST_ROOT/gamma"
  else
    cat "$TEST_ROOT/gamma"
  fi
  ;;
temperature)
  cat "$TEST_ROOT/temperature"
  ;;
*) exit 1 ;;
esac
SH

cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH

chmod +x "$mock_bin"/*

run_brightness() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-brightness-display" "$@"
}

printf '10\n' >"$test_tmp/hardware"
run_brightness --no-osd 5%-
sleep 1.5
printf 'after 5%%-: hardware=%s%% hyprsunset=%s state_file=%s\n' "$(<"$test_tmp/hardware")" \
  "$(kill -0 "$(<"$test_tmp/running")" 2>/dev/null && echo running || echo stopped)" \
  "$(cat "$test_tmp/runtime/omarchy-brightness-display.hyprsunset" 2>/dev/null || echo absent)"
printf '50\n' >"$test_tmp/hardware"
run_brightness --no-osd +5%
printf 'after +5%% at 50%%: hyprsunset=%s\n' "$(kill -0 "$(<"$test_tmp/running")" 2>/dev/null && echo running || echo stopped)"
if kill -0 "$(<"$test_tmp/running")" 2>/dev/null; then
  [[ -s $test_tmp/runtime/omarchy-brightness-display.hyprsunset ]] || fail "a hyprsunset started by the brightness script is recorded so it can be stopped"
fi
pass "a hyprsunset started by the brightness script is recorded so it can be stopped"

Actual output at 98c9a1af51:

after 5%-: hardware=5% hyprsunset=running state_file=absent
after +5% at 50%: hyprsunset=running
not ok - a hyprsunset started by the brightness script is recorded so it can be stopped
(exit status 1)

At the previous head de7857a43e no hyprsunset is started on the way down, so the test passes there (its output also contains harmless "No such file" lines from reading the absent running file).

Same result on the merge of 98c9a1af51 into quattro e332dc975d:

after 5%-: hardware=5% hyprsunset=running state_file=absent
after +5% at 50%: hyprsunset=running
not ok - a hyprsunset started by the brightness script is recorded so it can be stopped
(exit status 1)
More findings: New at 98c9a1a: the first night light press after dimming to 5% does nothing

New at 98c9a1a: the first night light press after dimming to 5% does nothing

The hyprsunset that prepare starts loads the shipped identity profile at 6000 K, and omarchy-toggle-nightlight turns night light on only from an empty value or 6500. The earlier review noted this below 1%; it now happens from 5% down.

Impact: the first Super+Ctrl+N press sets 6500 and changes nothing visible, and the second press gives 4000.

Suggested change: treat 6000 like 6500 in omarchy-toggle-nightlight, as its --status already does.

Reproducer:

(Head 98c9a1a) After lowering brightness to 5% with the key, the first night light toggle does nothing

Commit 98c9a1af51 starts hyprsunset in the background (prepare) whenever a Down step key lands at 5% or below. That hyprsunset loads the shipped identity profile, which reports 6000 K. omarchy-toggle-nightlight (Super+Ctrl+N) only turns night light on from an empty reading or 6500, so the first press sets 6500 (no visible change) and only the second press gives 4000. Before this commit, the same situation arose only after dimming below 1%.

Save as test/shell.d/brightness-display-gamma-nightlight-test.sh and run bash test/shell.d/brightness-display-gamma-nightlight-test.sh (mocks from test/shell.d/brightness-display-gamma-test.sh; a newly started hyprsunset answers IPC 0.3 s after it appears, which is a model):

#!/bin/bash
# Reproducer: lowering brightness to 5% with the step key now starts hyprsunset
# in the background (`prepare`). That hyprsunset loads the shipped identity
# profile (6000 K), and omarchy-toggle-nightlight only turns night light on from
# an empty reading or 6500, so the first Super+Ctrl+N press sets 6500 instead.
# Mocks are the ones from test/shell.d/brightness-display-gamma-test.sh, with
# `hyprctl hyprsunset temperature N` recorded, omarchy-shell stubbed, and a newly
# started hyprsunset answering IPC 0.3 s after it appears (a model, not measured).

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'eDP-1\n' >"$test_tmp/focused"
printf 'profile {\n  identity = true\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
cat "$TEST_ROOT/focused"
SH

cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH

cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH

cat >"$mock_bin/omarchy-brightness-display-ddc" <<'SH'
#!/bin/bash
printf 'ddc %s\n' "$*" >>"$TEST_ROOT/events"
printf '80\n'
SH

cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH

cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH

cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
rm -f "$TEST_ROOT/ipc_ready"
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
( sleep 0.3; touch "$TEST_ROOT/ipc_ready" ) >/dev/null 2>&1 &
SH

cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running && -f $TEST_ROOT/ipc_ready ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then
    printf '%s\n' "$3" >"$TEST_ROOT/gamma"
  else
    cat "$TEST_ROOT/gamma"
  fi
  ;;
temperature)
  if [[ -n ${3:-} ]]; then printf '%s\n' "$3" >"$TEST_ROOT/temperature"; else cat "$TEST_ROOT/temperature"; fi
  ;;
*) exit 1 ;;
esac
SH

cat >"$mock_bin/omarchy-shell" <<'SH'
#!/bin/bash
exit 0
SH

cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH

chmod +x "$mock_bin"/*

run() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$@"
}

printf '10\n' >"$test_tmp/hardware"
run "$ROOT/bin/omarchy-brightness-display" --no-osd 5%-
sleep 1
printf 'after 5%%- to %s%%: hyprsunset %s\n' "$(<"$test_tmp/hardware")" "$([[ -e $test_tmp/running ]] && kill -0 "$(<"$test_tmp/running")" 2>/dev/null && echo running || echo 'not running')"
run "$ROOT/bin/omarchy-toggle-nightlight" >/dev/null 2>&1 || true
printf 'first Super+Ctrl+N: temperature %s\n' "$(<"$test_tmp/temperature")"
[[ $(<"$test_tmp/temperature") == "4000" ]] || fail "first night light toggle at 5% brightness turns night light on"
pass "first night light toggle at 5% brightness turns night light on"

Actual output at 98c9a1af51:

after 5%- to 5%: hyprsunset running
first Super+Ctrl+N: temperature 6500
not ok - first night light toggle at 5% brightness turns night light on
(exit status 1)

Actual output at the previous head de7857a43e:

after 5%- to 5%: hyprsunset not running
first Super+Ctrl+N: temperature 4000
ok - first night light toggle at 5% brightness turns night light on
(exit status 0)

Same result as 98c9a1af51 on its merge into quattro e332dc975d (via the script; on quattro the plain Down key on an internal panel goes through the shell and does not run prepare, so there this follows Alt+Down):

after 5%- to 5%: hyprsunset running
first Super+Ctrl+N: temperature 6500
not ok - first night light toggle at 5% brightness turns night light on
(exit status 1)
More findings: N%- other than 5%- or 1%- raises brightness from the sub-1% range

N%- other than 5%- or 1%- raises brightness from the sub-1% range

The new ^[0-9]+%-$ branch clamps to 1% and resets gamma to 100, so 2%- from 0.4% jumps up to 1%. This only affects custom bindings or CLI use.

Suggested change: handle any N%- at hardware 1% with owned gamma like 5%-.

Reproducer:

In the sub-1% range, N%- other than 5%-/1%- raises brightness to 1%

brightness-display-gamma-ndelta-test.sh (mocks from test/shell.d/brightness-display-gamma-test.sh). Save as test/shell.d/brightness-display-gamma-ndelta-test.sh and run bash test/shell.d/brightness-display-gamma-ndelta-test.sh.

#!/bin/bash
# Reproducer: in the sub-1% range, `5%-` and `1%-` step gamma down, but any
# other `N%-` (new ^[0-9]+%-$ branch) clamps to 1% and resets gamma to 100,
# so a decrease makes the screen brighter.
# Mocks are the ones from test/shell.d/brightness-display-gamma-test.sh.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

test_tmp=$(mktemp -d)
trap 'if [[ -r $test_tmp/running ]]; then kill "$(<"$test_tmp/running")" 2>/dev/null || true; fi; rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
mkdir -p "$mock_bin" "$test_tmp/runtime" "$test_tmp/config/hypr"
printf '50\n' >"$test_tmp/hardware"
printf '6000\n' >"$test_tmp/temperature"
printf 'eDP-1\n' >"$test_tmp/focused"
printf 'profile {\n  identity = true\n}\n' >"$test_tmp/config/hypr/hyprsunset.conf"

cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH'
#!/bin/bash
cat "$TEST_ROOT/focused"
SH

cat >"$mock_bin/omarchy-hyprland-monitor-focused-apple" <<'SH'
#!/bin/bash
exit 1
SH

cat >"$mock_bin/omarchy-hw-display" <<'SH'
#!/bin/bash
printf 'mock_backlight\n'
SH

cat >"$mock_bin/omarchy-brightness-display-ddc" <<'SH'
#!/bin/bash
printf 'ddc %s\n' "$*" >>"$TEST_ROOT/events"
printf '80\n'
SH

cat >"$mock_bin/brightnessctl" <<'SH'
#!/bin/bash
if [[ $* == *" -m"* ]]; then
  brightness=$(<"$TEST_ROOT/hardware")
  printf 'mock_backlight,backlight,%s,%s%%\n' "$brightness" "$brightness"
elif [[ $* == *" set "* ]]; then
  value=${@: -1}
  printf '%s\n' "${value%%%}" >"$TEST_ROOT/hardware"
fi
SH

cat >"$mock_bin/pgrep" <<'SH'
#!/bin/bash
[[ -f $TEST_ROOT/running ]] || exit 1
pid=$(<"$TEST_ROOT/running")
[[ -r /proc/$pid/stat ]] || exit 1
[[ $(awk '{ print $3 }' "/proc/$pid/stat") != "Z" ]] || exit 1
printf '%s\n' "$pid"
SH

cat >"$mock_bin/setsid" <<'SH'
#!/bin/bash
sleep 1000 >/dev/null 2>&1 &
printf '%s\n' "$!" >"$TEST_ROOT/running"
printf '100\n' >"$TEST_ROOT/gamma"
SH

cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
[[ ${1:-} == "hyprsunset" && -f $TEST_ROOT/running ]] || exit 1
case ${2:-} in
gamma)
  if [[ -n ${3:-} ]]; then
    printf '%s\n' "$3" >"$TEST_ROOT/gamma"
  else
    cat "$TEST_ROOT/gamma"
  fi
  ;;
temperature)
  cat "$TEST_ROOT/temperature"
  ;;
*) exit 1 ;;
esac
SH

cat >"$mock_bin/omarchy-osd" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_ROOT/osd"
SH

chmod +x "$mock_bin"/*

run_brightness() {
  TEST_ROOT="$test_tmp" XDG_RUNTIME_DIR="$test_tmp/runtime" XDG_CONFIG_HOME="$test_tmp/config" \
    PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-brightness-display" "$@"
}

run_brightness --no-osd 0.4%
printf 'after 0.4%%: hardware=%s%% gamma=%s reported=%s\n' "$(<"$test_tmp/hardware")" "$(<"$test_tmp/gamma")" "$(run_brightness)"
run_brightness --no-osd 2%-
printf 'after 2%%-: hardware=%s%% gamma=%s reported=%s\n' "$(<"$test_tmp/hardware")" "$(cat "$test_tmp/gamma" 2>/dev/null)" "$(run_brightness)"
[[ $(run_brightness) != "1" ]] || fail "a 2%- decrease from 0.4% does not raise brightness to 1%"
pass "a 2%- decrease from 0.4% does not raise brightness to 1%"

Actual output at the previous head de7857a43e (the commit that added the ^[0-9]+%-$ branch):

after 0.4%: hardware=1% gamma=55 reported=0.4
after 2%-: hardware=1% gamma=100 reported=1
not ok - a 2%- decrease from 0.4% does not raise brightness to 1%
(exit status 1)

The earlier reviewed head sent 2%- straight to brightnessctl, which the test's simple brightnessctl mock does not model, so this reproducer is only meaningful on the current head.

Still reproduces after the head moved

The author pushed 98c9a1af51 ("fix: no more delay for changing brightness") during this review; it changes only the two brightness scripts.

Actual output on the newer head 98c9a1af51:

after 0.4%: hardware=1% gamma=55 reported=0.4
after 2%-: hardware=1% gamma=100 reported=1
not ok - a 2%- decrease from 0.4% does not raise brightness to 1%
(exit status 1)
More findings: Monitor panel slider wheel needs five notches to leave 1%

Monitor panel slider wheel needs five notches to leave 1%

The slider's own wheel adds 0.1 at 1% on internal panels, and clampBrightness rounds 1.1 to 1.4 back to 1 while the slider keeps adding 0.1, so the value only moves at the fifth notch (1, 1, 1, 1, 2). The keyboard and bar-icon paths are fixed; this path was not changed.

Suggested change: use Model.stepBrightness for the slider wheel too (PanelSlider needs a direction-aware step or a wheel hook for this).

Reproducer (Node harness, QML not run):

Mouse wheel over the monitor panel's brightness slider needs five notches to leave 1%

monitor-slider-wheel-test.sh copies the PanelSlider.onWheel and Panel.qml slider expressions (asserting they are present in the tree) and uses the tree's own Model.js. QML is not run. Save as test/shell.d/monitor-slider-wheel-test.sh and run bash test/shell.d/monitor-slider-wheel-test.sh (needs Node).

#!/bin/bash
# Reproducer: mouse wheel over the monitor panel's brightness slider on an
# internal display. PanelSlider.onWheel adds `step` to liveValue; Panel.qml sets
# `step` to 0.1 while brightnessPercent <= 1, and Model.clampBrightness rounds
# values >= 1 to integers. brightnessPercent stays 1 (no valueChanged), so
# liveValue keeps accumulating (1.1, 1.2, ...) until it rounds to 2.
# The PanelSlider/Panel expressions are copied here; QML itself is not run.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

grep -qF 'step: root.internalBrightness() && root.brightnessPercent <= 1 ? 0.1 : 1' "$ROOT/shell/plugins/panels/monitor/Panel.qml" ||
  fail "Panel.qml slider step expression is the one reproduced here"
grep -qF 'var next = Math.max(root.minimum, Math.min(root.maximum, root.liveValue + delta))' "$ROOT/shell/Ui/PanelSlider.qml" ||
  fail "PanelSlider wheel expression is the one reproduced here"

run_node_test <<'JS'
const model = requireFromRoot('shell/plugins/panels/monitor/Model.js')
let brightnessPercent = 1
let liveValue = 1
const seen = []
for (let notch = 0; notch < 5; notch++) {
  const step = brightnessPercent <= 1 ? 0.1 : 1                 // Panel.qml slider step (internal display)
  const next = Math.max(0, Math.min(100, liveValue + step))       // PanelSlider onWheel, integer: false
  liveValue = next
  const percent = model.clampBrightness(next, true)               // previewBrightness / setBrightness
  if (percent !== brightnessPercent) liveValue = percent          // onValueChanged only fires on a change
  brightnessPercent = percent
  seen.push(brightnessPercent)
}
console.log(`wheel up from 1% on eDP-1, five notches: ${seen.join(', ')}`)
assertEqual(seen[0], 2, 'first wheel notch up from 1% on an internal display reaches 2%')
JS

Actual output at the previous head de7857a43e:

wheel up from 1% on eDP-1, five notches: 1, 1, 1, 1, 2
expected: 2
actual:   1
not ok - first wheel notch up from 1% on an internal display reaches 2%
(exit status 1)

Actual output at the earlier reviewed head fd986e1213 (same result; the new commit changed the keyboard and bar-icon paths but not the slider's own wheel):

wheel up from 1% on eDP-1, five notches: 1, 1, 1, 1, 2
expected: 2
actual:   1
not ok - first wheel notch up from 1% on an internal display reaches 2%
(exit status 1)

Still reproduces after the head moved

The author pushed 98c9a1af51 ("fix: no more delay for changing brightness") during this review; it changes only the two brightness scripts.

Actual output on the newer head 98c9a1af51:

wheel up from 1% on eDP-1, five notches: 1, 1, 1, 1, 2
expected: 2
actual:   1
not ok - first wheel notch up from 1% on an internal display reaches 2%
(exit status 1)
Details
  • Verified at 98c9a1af: step keys, N%- and sub-1% absolute values stop the backlight at 1% (Shift+Down gives hardware 1% plus gamma 25). A gamma set by the user through hyprsunset.conf or hyprctl stays unchanged through +5%, 5%- and 40%. Panel l from 1 gives 2, 3, 4, 5, 10, and h from 2, 3 or 5 gives 1, 2 or 4. The other brightness, monitor, OSD and night light tests pass, on the PR head and on the merge into quattro.
  • Related open PRs: Fall back to hyprsunset gamma on displays without DDC/CI #13332 still defines its own gamma_brightness() in bin/omarchy-brightness-display, returning an integer percentage where this PR returns tenths, and would still overwrite this PR's gamma. Run display brightness from omarchy-media: one process per key press, not sixteen #13286 replaces bin/omarchy-brightness-display with a wrapper around omarchy-media, which would drop this PR's gamma path unless it is ported.
  • Optional test improvement: test/shell.d/nightlight-test.sh passes when omarchy-brightness-display-gamma cleanup is missing or fails, because the OFF step only checks the stored temperature and the toggle's exit status comes from its last command. The test also does not override XDG_RUNTIME_DIR, so with an installed Omarchy containing this PR on PATH it deletes the real brightness state files if they exist. A recording stub for cleanup and a private XDG_RUNTIME_DIR would cover both.

Reproducer (night light test):

nightlight-test.sh passes whether or not the OFF path's cleanup runs

test/shell.d/nightlight-test.sh is unchanged by the PR. Its OFF toggle (lines 85-87) only asserts the stored temperature. bin/omarchy-toggle-nightlight has no set -e, and its exit status comes from the final omarchy-shell -q nightlight refresh, so the result of omarchy-brightness-display-gamma cleanup is ignored. The test also runs "$ROOT/bin/omarchy-toggle-nightlight" with PATH="$TMPDIR/bin:$PATH", so omarchy-brightness-display-gamma is looked up on the ambient PATH, not in the checkout.

Diagnostic variants (disposable copies), each running bash test/shell.d/nightlight-test.sh:

Head Variant Result Exit
98c9a1af51 unmodified; omarchy-brightness-display-gamma not on PATH 14 ok, 0 not ok 0
98c9a1af51 cleanup block deleted from bin/omarchy-toggle-nightlight 14 ok, 0 not ok 0
98c9a1af51 an omarchy-brightness-display-gamma that exits 1 put on PATH 14 ok, 0 not ok 0
de7857a43e unmodified; omarchy-brightness-display-gamma not on PATH 14 ok, 0 not ok 0
de7857a43e cleanup block deleted from bin/omarchy-toggle-nightlight 14 ok, 0 not ok 0
de7857a43e an omarchy-brightness-display-gamma that exits 1 put on PATH 14 ok, 0 not ok 0

In the unmodified run the only trace of the cleanup call is stderr: line 60: omarchy-brightness-display-gamma: command not found. The variant with a failing cleanup on PATH recorded exactly one call, cleanup.

Deleted lines for the second variant:

-if (( TARGET_TEMP == OFF_TEMP )); then
-  omarchy-brightness-display-gamma cleanup
-fi

Review information

Test scope: source and stubbed sandbox tests at 98c9a1af and its quattro merge; no hardware.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Checking in, since the branch hasn't changed since the Sep 29 review. At 98c9a1af, test/shell.d/brightness-display-gamma-test.sh still expects the raw-0 handoff and exits 1. Also, hyprsunset gamma is global, so dimming the internal panel below 1% dims external monitors too. That second part probably needs a maintainer call before this can land. #13332 also uses hyprsunset gamma, as a fallback for external displays without DDC/CI, so the two should agree on who owns the hyprsunset process.

A small nit: some checks compare gamma to "100" only (prepare, release, step) and others accept "100" or "100.0". Normalizing it once would make every check agree, whatever hyprsunset prints:

current_gamma() {
  local gamma
  gamma=$(hyprctl hyprsunset gamma 2>/dev/null) || return 1
  [[ $gamma =~ ^[0-9]+([.][0-9]+)?$ ]] || return 1
  printf '%.0f\n' "$gamma"
}

@vander00

vander00 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Yes. Unfortunatelly, it is impossible to dim only one monitor using hyprsunset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants