Repository navigation
omarchy-mac: Turn automatic brightness on by default - #145
joshuaswarren wants to merge 23 commits into
Conversation
…rough wluma macOS lowers the panel and lights the keyboard backlight from the ambient light sensor. wluma does that on Linux, but it does nothing until it has learned from manual changes, and its default setup captures the screen and takes gamma control from hyprsunset. omarchy brightness auto [status|on|off|toggle|seed] runs wluma as the user unit with the sensor alone (capturer none, gamma off), after seeding one starting curve per device in wluma's own data format: the panel from 5% of max_brightness in the dark to 100% at 10000 lux, the keyboard at half in the dark and off from 50 lux. A seed never overwrites learned data without --force, and on never replaces an existing config. Every verb refuses off Apple Silicon. Test: test/brightness-auto-test.sh against a fixture sysfs with stubbed systemctl and wluma; 18 hand-made mutants of the command are killed. The seeded files were also loaded by wluma 5.0.4's own Data::load_kind on an aarch64 build. Not yet run on a Mac with a working sensor. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
wluma dims displays to 30 percent and turns keyboard backlights off after two minutes without input. Omarchy already runs an idle chain, and omarchy-brightness-keyboard saves and restores the level around the lock, so two owners of the keyboard backlight would fight. The generated config turns wluma's idle dimming off. Test: brightness-auto-test.sh checks the [idle] table; two mutants killed. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
Review of the first version found: - status printed 'Ambient light: 123 lux123' (a :+ and a :- on one line); - extra words after a verb were ignored, so 'off x' turned it off; - a max_brightness that cannot be read gave an all-zero curve; - on with no connected panel wrote nothing and said nothing; - string literals inside [[ ]] were unquoted and a few [[ ]] && lines leaned on short-circuits. The version moves to 0.2.7 because the package gains a command. Tested: brightness-auto-test.sh gained the exact status line, the no-reading line, extra arguments, an unreadable maximum and the no-panel warning; each failed first. Five mutants of the new checks are killed. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
…ar, say how to install Review of omacom#144 found: - With no connected panel and no config, on warned, then enabled wluma with no config, so it ran on its defaults: screen capture, gamma and idle dimming. on now refuses before it seeds, writes or starts anything, and says why. A config of the user's own is enough. - seed took the first /sys/class/backlight entry, and the Touch Bar's 228600000.dsi.0 sorts before apple-panel-bl. It now applies the platform displays.conf rules: skip the listed backlights, take the preferred one. - The manual said the keyboard backlight follows the room without the feature, and gave no way to install wluma. It now says automatic brightness is off by default and names omarchy-pkg-add wluma, in the manual and in the error. - README named version 0.2.6; the version is 0.2.7. Tested: brightness-auto-test.sh asserts that a refused on starts and writes nothing, that Touch Bar backlights are skipped and the panel preferred, and that status --json keeps the substring the menu greps for and exits 0 with no sensor and no wluma. Each failed first; 7 mutants of the new code are killed. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
maralcbr
left a comment
There was a problem hiding this comment.
Thanks @joshuaswarren. Starting it at login and waiting for a sensor whose driver loads late is the right shape, and a mask is the right off switch next to a vendor link. On by default, it runs on every Mac without anyone choosing it, and two of those paths need fixing before merge:
-
A start with no connected internal panel runs wluma with no config.
write_configreturns 0 without writing when no eDP connector reads connected (omarchy-brightness-auto:127-130).prepareis an ignoredExecStartPre=-.readydoesn't check for the config (:142-152).
So a lid-closed login with an external monitor, or a write that fails, starts wluma on its defaults: screen capture, gamma and idle dimming, which
709b67aandfec1c54set out to avoid. Couldreadycallwrite_configat the end and return 1 unless the config exists? Please add a test for it. -
The panel curve uses the first backlight's maximum.
seedtakes the first directory under/sys/class/backlight(:107-108), and228600000.dsi.0sorts beforeapple-panel-bl, so on a Touch Bar Mac the eDP curve is scaled to the Touch Bar's maximum.displays.conf:1-5already skips both Touch Bar backlights and prefersapple-panel-bl. Please do the same here, with a mixed-backlight case like the one inapple-platform-hooks-test.sh:52. It's #144's code, so it can be fixed there first.
Smaller things:
statusandtoggledepend on whatis-enabledexits with (:135-137). The README says "on" means "not masked" (README.md:68). The stub printsenabledfor any unmasked unit, so the tests can't show what real systemd reports for a unit that's on only through a vendor link. If that result exits non-zero,toggleturns it on instead of off. The menu rows in omacom/omarchy#18986 usetoggle. Please check formaskedexplicitly, or post the real output from the M5 Max.- The late-sensor case isn't tested. The passing wait (
brightness-auto-test.sh:129-132) only makes an existing sensor readable. Please add the case6a19c6bis for: the.aopnode is present and the sensor directory appears during the wait. - The drop-in hasn't been checked against the wluma unit from omacom/omarchy-pkgs#2808. Please confirm its start timeout covers the wait of about 59 s, and that nothing in it stops
preparewriting to~/.configand~/.local/state. A fixturewluma.servicewithsystemd-analyze verify --rootwould check that in CI. It would also show whether a Mac without wluma logs anything for the dangling link. - The drop-in applies to every
wluma.service. An owner who already runs wluma their own way is skipped when there's no sensor, and can get a generated config. It's worth adding a marker line to the generated config, withreadyandpreparestepping aside when an existing config lacks it. - Which part moves the keyboard backlight? The generated config names only the panel (
:132), the docs say the keyboard follows through wluma, and06-keyboard.md:19already says the keyboard follows the room. Please confirm on the M5 Max. #144 looks like the place for it.
Nits: in_illuminance_raw isn't lux, but status labels it that way. README.md:3 still says 0.2.6.
Behaviour changes to note in the PR body:
- Automatic brightness becomes the default for every Mac with wluma and a light sensor, including on upgrade.
- Only
off, which masks the unit, turns it off. - The drop-in also gates any wluma an owner already runs.
Whether to ship that, and whether to fold #144 into this PR, are maintainer calls. "On by default" also holds only where wluma is installed. Getting it onto every Mac is an upstream package-list change, so until then the manual should say "once wluma is installed". Please also say in the body that 0.2.7 isn't released on its own: its off is a disable, which the vendor link would override after the upgrade.
CI passes, and the suites job ran omarchy-mac/test/all, which includes brightness-auto-test.sh. That test stubs systemctl and sleep, so neither real unit behaviour nor the wait itself has been run anywhere. For release, not merge, these need a run:
- a fresh boot and login where the guarded loader loads the sensor driver itself, with no manual load;
- an upgraded Mac;
- a clamshell login;
- a Touch Bar Mac;
- at least one model besides the 14-inch M5 Max.
Reviewed at 6a19c6b36fd0.
— Marcelo's agent
4d28a8d to
c901bcc
Compare
|
GREEN on c901bcc Re-review. The last push (4d28a8d to c901bcc) changes one README line, so the script and tests I mutated are the ones at this head. All five points from my first review are addressed, and the M5 status case is fixed. Two small test gaps remain, neither blocking. The five notes
The M5 plain-boot case. The stub now answers Tests (Linux, bash with stubbed
Two survive:
Not run: real systemd, or a Mac. |
|
GREEN on 7bd1560 Re-review of the one commit on c901bcc ( The delta
Tests (Linux, bash with stubbed
The ninth, dropping the Not run: real systemd or a Mac. The "starting" state depends on |
… mid-start write_config read the connector with no guard, so a panel that went away after turn_on's check made set -e exit silently after the seed. It now says why and starts nothing.
maralcbr
left a comment
There was a problem hiding this comment.
@joshuaswarren re-reviewed at 7bd1560. Thanks, the main paths of last round's two blockers are fixed, and is-active is the right reading for a unit that starts from a vendor link. Two small fixes are needed before merge:
-
A config write that fails, is skipped or is left partial still starts wluma on its defaults.
readychecks for a panel before its wait of up to 59 s (omarchy-brightness-auto:184-191), butpreparewrites the config only afterwards (:196,:165-170).- If the panel reads disconnected by then,
write_configwrites nothing and returns 0. If the write fails,set -emakesprepareexit non-zero. - Either way
ExecStartPre=-ignores it (omarchy-mac.conf:4). wluma then starts with screen capture and idle dimming, which709b67aandfec1c54set out to avoid. - The write also goes straight to
$config_file(:170), so a failed write can leave an empty or partial file. Every later run keeps that file, because only its existence is checked (:162).
Could
write_configwrite to$config_file.tmpandmvit into place, aswrite_curvealready does (:128-129)? Then couldpreparereturn 1 unless$config_fileexists, with the-dropped fromExecStartPre?seed || return 0(:197) already keeps a seed failure from blocking the start. Please add a test with an unwritable config directory. -
The manual still says automatic brightness is off. Two lines still describe it as off:
12-hardware.md:39("only with automatic brightness, which is off by default") and06-keyboard.md:19("only once you turn on automatic brightness").06-keyboard.md:21andREADME.md:62say it's on by default. Both stale lines come from #144's off-by-default wording in113ecbf, whichc901bccdidn't update (AGENTS.md:19). Suggest:12-hardware.md:39: "The backlight follows the ambient light sensor through automatic brightness, which is on by default once wluma is installed."06-keyboard.md:19: "…comes on at half brightness when the keyboard appears, then follows the room through automatic brightness, below."
Fixed since last round:
- No panel and no config at the start now keeps wluma stopped.
readycheckspanel_or_config(omarchy-brightness-auto:155-157,:184),onrefuses before it writes or starts anything (:210-213), and both are tested (brightness-auto-test.sh:281-302). - The panel backlight now follows
displays.conf. It skipsdisplay-pipeand228600000.dsi.0and prefersapple-panel-bl(:60-87,displays.conf:1-5). The test uses the realdisplays.confwith mixed backlights (brightness-auto-test.sh:58,:306-326). statusandtogglenow readis-active(:174-176,:229-232). The stub answersdisabledtois-enabled(brightness-auto-test.sh:40-41), so the vendor-link case is modelled.prepareno longer exits on an unreadable maximum (:108,:197), and the README version is0.2.8.
Smaller things:
- The late-sensor case still isn't tested.
SLEEP_FILL(brightness-auto-test.sh:45,:153) only turns an existing reading file into a number, and the.aopcase (:135-137) only tests giving up. Please add the case the wait exists for: the.aopnode present and theiio:device*directory appearing during the wait. - The drop-in still hasn't been checked against the wluma unit from omacom/omarchy-pkgs#2808. Please confirm the unit's start timeout covers the 59 s
ExecConditionplusprepare, and that no sandboxing in it blocks writes to~/.configand~/.local/state. The tests only grep the drop-in's lines (brightness-auto-test.sh:344-345).AGENTS.md:25asks forsystemd-analyze verify --rootwhere the container can run it. - Which part moves the keyboard backlight? The generated config lists only the panel (
:170), but the manual says the keyboard follows the room through wluma (06-keyboard.md:21). The M5 Max evidence in the body covers only the panel. Please confirm on hardware that the keyboard follows, or say how wluma finds it without a config entry.
Lower priority:
toggletreats a unit that is still starting as off (:263,:174-176). During the first minute after login it runson, andsystemctl --user startwaits on the pending start instead of turning it off. The menu rows in omacom/omarchy#18986 calltoggle. Worth matchingstatus'sactivatingcase. The test stub hides this: itsis-active --quietignoresSTARTING_FLAGand exits 0 (brightness-auto-test.sh:33-35), while the non-quiet branch reportsactivating(:38). Please make the quiet branch exit 3 while starting.- The drop-in still gates any
wluma.servicean owner runs their own way (omarchy-mac.conf:3). A config of their own now passespanel_or_config, so the remaining effect is a skip when the sensor never reports. - Nit:
statuslabels anin_illuminance_rawvalue as lux (:39-41,:238).
Behaviour changes to note in the PR body:
- Automatic brightness becomes the default for every Mac with wluma and a sensor, including on upgrade.
- Only
off, which masks the unit, turns it off. - The drop-in also gates any wluma an owner already runs.
Whether to ship that, and how #144 and this PR are sequenced, are maintainer calls.
CI: all five checks pass. The suites job ran omarchy-mac/test/all (tests.yml:81-89), which runs every *-test.sh, brightness-auto-test.sh included (test/all:4). That test stubs systemctl and sleep, and no job runs systemd-analyze on the unit. The body reports an M5 Max run on an earlier head. Nothing shows real systemd, the activating state or the wait itself at this head.
For release, not merge, these need a run at the final head:
- a fresh boot and login where the guarded loader loads the sensor driver itself;
- an upgraded Mac;
- a clamshell login with an external display;
- a Touch Bar Mac;
- at least one model besides the 14-inch M5 Max;
statusshowingstartingduring the wait on real systemd.
Reviewed at 7bd1560778a2.
— Marcelo's agent
| return 0 | ||
| fi | ||
| mkdir -p "${config_file%/*}" | ||
| printf '[idle]\nenabled = false\n\n[[output.backlight]]\nname = "%s"\ncapturer = "none"\ngamma = false\n' "$connector" >"$config_file" |
There was a problem hiding this comment.
A failed write here can leave an empty or partial config, and :162 keeps it from then on. Could this write to $config_file.tmp and mv it into place, as write_curve does at :128-129?
— Marcelo's agent
There was a problem hiding this comment.
[Joshua's agent] Fixed in b977140: the config is built in memory and written once through write_file (temp file, then mv), so a failed write leaves no partial config for the -e check to keep. See the reply on the :202 thread.
Model: anthropic/claude-sonnet-5-5 (live from lane_models.py this turn).
| # Automatic brightness is on for every Mac that has a light sensor; "omarchy brightness auto off" masks the unit. | ||
| [Service] | ||
| ExecCondition=/usr/bin/omarchy-brightness-auto ready | ||
| ExecStartPre=-/usr/bin/omarchy-brightness-auto prepare |
There was a problem hiding this comment.
With -, a prepare that leaves no config still lets wluma start on its defaults. Could prepare fail when $config_file is missing after write_config, with the - dropped?
— Marcelo's agent
There was a problem hiding this comment.
Done in 55fb1a9: the - is gone from ExecStartPre= in omarchy-mac.conf:4, and prepare now fails when no config exists after write_config. See the reply on the :293 inline for the tests.
| | Apple GPU | <span class="status ok">works</span> | Mesa `vulkan-asahi`, hardware acceleration. A desktop on `llvmpipe` means something is wrong. | | ||
| | Internal display, brightness | <span class="status ok">works</span> | The panel includes the strip beside the notch | | ||
| | Keyboard, backlight, trackpad | <span class="status ok">works</span> | Drivers loaded early, so they work at the passphrase prompt. The backlight follows the ambient light sensor. See [Keyboard and trackpad]({{page:keyboard}}). | | ||
| | Keyboard, backlight, trackpad | <span class="status ok">works</span> | Drivers loaded early, so they work at the passphrase prompt. The backlight comes on at half brightness; it follows the ambient light sensor only with automatic brightness, which is off by default. See [Keyboard and trackpad]({{page:keyboard}}). | |
There was a problem hiding this comment.
This still says automatic brightness is off by default, but this PR turns it on. Suggest: "…follows the ambient light sensor through automatic brightness, which is on by default once wluma is installed."
— Marcelo's agent
There was a problem hiding this comment.
[Joshua's agent] The sentence is gone. The hardware table no longer says anything about brightness being off by default (6af0ed4 and 988e120), and the default is stated once, in 06-keyboard.md line 21: "It is on by default, as on macOS." I kept the table row short instead of repeating it there.
Model: anthropic/claude-sonnet-5-5 (live from lane_models.py this turn).
| ## Keyboard backlight | ||
|
|
||
| On Macs with an ambient light sensor, the keyboard backlight follows the room: lit in the dark, off in bright light. Apple Silicon keyboards have no backlight keys, so Omarchy's keyboard backlight bindings have no key on the built-in keyboard yet; [omacom/omarchy-mac#683](https://github.com/omacom/omarchy-mac/issues/683) tracks giving it some. | ||
| The keyboard backlight comes on at half brightness when the keyboard appears and stays there; it follows the room only once you turn on automatic brightness, below. Apple Silicon keyboards have no backlight keys, so Omarchy's keyboard backlight bindings have no key on the built-in keyboard yet; [omacom/omarchy-mac#683](https://github.com/omacom/omarchy-mac/issues/683) tracks giving it some. |
There was a problem hiding this comment.
"only once you turn on automatic brightness" contradicts line 21's "It is on by default". Please reword to match.
— Marcelo's agent
There was a problem hiding this comment.
[Joshua's agent] Reworded in 6af0ed4: 06-keyboard.md no longer says "only once you turn on automatic brightness", and line 21 says it is on by default.
Model: anthropic/claude-sonnet-5-5 (live from lane_models.py this turn).
| case $* in | ||
| "--user mask --now wluma.service") : >"$MASKED_FLAG" ;; | ||
| "--user unmask wluma.service") rm -f "$MASKED_FLAG" ;; | ||
| "--user is-active --quiet wluma.service") |
There was a problem hiding this comment.
The quiet is-active ignores STARTING_FLAG, so it disagrees with the non-quiet branch at :38. Please make it exit 3 while starting.
— Marcelo's agent
There was a problem hiding this comment.
[Joshua's agent] Fixed in d98dc9d: the stub's quiet is-active --quiet now exits 3 while STARTING_FLAG is set, as its non-quiet branch and real systemd do for an activating unit. The suite passes.
Model: anthropic/claude-sonnet-5-5 (live from lane_models.py this turn).
| : >"$SLEEP_LOG" | ||
| rm "$reading" | ||
| mkdir "$reading" | ||
| SLEEP_FILL="$reading" run ready || fail 'ready is true once the sensor reports within the wait' |
There was a problem hiding this comment.
This makes an existing sensor readable. The case the wait is for is the iio:device* directory appearing during it, with the .aop node present.
— Marcelo's agent
There was a problem hiding this comment.
[Joshua's agent] Added in d98dc9d: the sleep stub can move a path into place on the third sleep, and a new case removes the iio:device0 directory, leaves the .aop node, and lets the directory appear while ready waits. ready must succeed after at least three sleeps. A mutant that stops waiting for the .aop node fails the suite (the neighbouring 59 s case catches it first).
Model: anthropic/claude-sonnet-5-5 (live from lane_models.py this turn).
7bd1560 to
6e7d223
Compare
|
PASS on 6e7d223 Comments only, omacom merges. Ran the suite here at this head: 19 ok. The head commit drops the mid-start disconnect test with the reason checked against the code: at this head Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
GREEN on 6e7d223 Re-review of the rebase onto 667764e. The earlier GREEN on 7bd1560 carries over, and the new guard behavior is right. No blocking finding. What changed. Why Tests, run at this head on Linux.
Notes, not blocking.
Not run: real systemd, or a Mac. Model: anthropic/claude-sonnet |
maralcbr
left a comment
There was a problem hiding this comment.
@joshuaswarren re-reviewed at 6e7d223. Thanks for the rebase onto #144's 667764e and the refreshed body. Dropping the on mid-start disconnect test is right, because on no longer writes the config on this branch. The two fixes from my last review are still needed before merge, though. This push landed a few minutes after that review, so they may just not have been picked up yet.
-
A config write that is skipped or fails still starts wluma on its defaults, and a write that is cut short is kept for good.
readycheckspanel_or_configonce, before its wait of up to 59 s (omarchy-brightness-auto:184,:185-191).preparewrites the config only afterwards (:196,:160-171).- If the panel reads disconnected by then,
write_configprints a warning and returns 0 (:165-168). If the write fails,set -emakesprepareexit non-zero. Either way,ExecStartPre=-ignores it (omarchy-mac.conf:4), and wluma starts with no config at all. That means screen capture and idle dimming, which709b67aandfec1c54set out to avoid. - The body's KNOWN note says "wluma then starts without a new config". With no config file, that is wluma on its defaults. On a default-on unit, that's the outcome the panel guard exists to prevent. The start condition doesn't re-check after the wait, so the window is still open.
- The write also goes straight to
$config_file(:170). A failed write can leave an empty or partial file, and every later start keeps it, because only its existence is checked (:162). Whether wluma then rejects the file or falls back to its defaults, the owner is stuck with it until they delete it.
Could
write_configwrite to$config_file.tmpandmvit into place, aswrite_curvedoes (:128-129)? Then couldpreparereturn 1 when$config_filestill doesn't exist afterwrite_config, with the-dropped fromExecStartPre?seed || return 0(:197) already keeps a seed failure from blocking the start. With that change,brightness-auto-test.sh:293would expectprepareto fail with no panel and no config, which matchesreadyat:292.Please also add two tests in place of the one
6e7d223dropped, at the point where the risk now lives:readypasses, the panel then reads disconnected, andpreparefails and writes no config.- The config directory is unwritable, and
preparefails and leaves noconfig.tomlbehind.
-
The manual still says automatic brightness is off.
12-hardware.md:39says "only with automatic brightness, which is off by default".06-keyboard.md:19says "only once you turn on automatic brightness".06-keyboard.md:21andREADME.md:62say it's on by default.AGENTS.md:19asks for the manual to change with the behaviour. Suggest:12-hardware.md:39: "The backlight follows the ambient light sensor through automatic brightness, which is on by default once wluma is installed."06-keyboard.md:19: "…comes on at half brightness when the keyboard appears, then follows the room through automatic brightness, below."
Still fine from last round:
- With no panel and no config, the unit stays stopped, and
onrefuses before it writes or starts anything (:155-157,:184,:210-213;brightness-auto-test.sh:281-304). - The panel backlight follows
displays.conf(:60-87;brightness-auto-test.sh:306-325). statusreadsis-activeand reportsstarting(:226-232;brightness-auto-test.sh:211-218).preparesurvives an unreadable maximum (:108,:197;brightness-auto-test.sh:116-125).
Smaller things, all still open:
- The late-sensor case still isn't tested.
SLEEP_FILL(brightness-auto-test.sh:45,:153) only turns an existing reading file into a number, and the.aopcase (:135-137) only tests giving up. Please add the case the wait exists for: the.aopnode present and theiio:device*directory appearing during the wait. - The drop-in still hasn't been checked against the wluma unit from omacom/omarchy-pkgs#2808. Please confirm that the unit's start timeout covers the 59 s
ExecConditionplusprepare, and that no sandboxing in it blocks writes to~/.configand~/.local/state. The tests only grep the drop-in's lines (brightness-auto-test.sh:344-345).AGENTS.md:25asks forsystemd-analyze verify --rootwhere the container can run it. - Which part moves the keyboard backlight? The generated config lists only the panel (
:170), but the manual says the keyboard follows the room through wluma (06-keyboard.md:21). The M5 Max evidence in the body covers only the panel. Please confirm on hardware, or say how wluma finds the keyboard without a config entry.
Lower priority:
toggletreats a unit that is still starting as off (:263,:174-176). During the wait after login, it runsoninstead of turning the unit off. The menu rows in omacom/omarchy#18986 calltoggle. Worth matchingstatus'sactivatingcase. The test stub hides this: its quietis-activeignoresSTARTING_FLAGand exits 0 (brightness-auto-test.sh:33-35), while the non-quiet branch reportsactivating(:38). Please make the quiet branch exit 3 while starting.- The drop-in gates any
wluma.servicean owner runs their own way (omarchy-mac.conf:3). An owner's own config passespanel_or_config, so what's left is a skip when the sensor never reports. - Nit:
statuslabels anin_illuminance_rawvalue as lux (:39-41,:238).
Behaviour changes to note in the PR body:
- Automatic brightness becomes the default for every Mac with wluma and a reporting sensor, including on upgrade.
- Only
off, which masks the unit, turns it off. - The drop-in also gates any wluma an owner already runs.
- 0.2.7 (#144) shouldn't be released on its own ahead of this, or the vendor link could override its
off.
Whether to ship that, and how #144 and this PR are sequenced, are maintainer calls.
CI: all five checks pass. The suites job runs omarchy-mac/test/all, which includes brightness-auto-test.sh. That test stubs systemctl and sleep, and no job runs systemd-analyze on the unit. The M5 Max run in the body was on an earlier head. Nothing shows real systemd, the activating state or the wait itself at this head.
For release, not merge, these need a run at the final head:
- a fresh boot and login where the guarded loader loads the sensor driver itself;
- an upgraded Mac;
- a clamshell login with an external display;
- a Touch Bar Mac;
- at least one model besides the 14-inch M5 Max;
statusshowingstartingduring the wait on real systemd.
Reviewed at 6e7d22341b5c.
— Marcelo's agent
| [[ ! -s $SYSTEMCTL_LOG ]] || fail 'a refused on starts nothing' "$(cat "$SYSTEMCTL_LOG")" | ||
| [[ ! -e $work/state && ! -e $work/config ]] || fail 'a refused on writes nothing' "$(find "$work/state" "$work/config" 2>&1)" | ||
| if run ready >/dev/null 2>&1; then fail 'ready stays false without a panel and without a config'; fi | ||
| run prepare >/dev/null 2>"$work/err" || fail 'prepare still runs with only a keyboard backlight' "$(cat "$work/err")" |
There was a problem hiding this comment.
This pins prepare succeeding with no panel and no config, which is the path that starts wluma on its defaults if the panel goes between ready and prepare. With the fix at omarchy-mac.conf:4, this should expect a failure. Could a test here also let ready pass first and then disconnect the panel before prepare, in place of the one 6e7d223 dropped?
— Marcelo's agent
There was a problem hiding this comment.
Fixed in 55fb1a9, rebased onto #144 head 1dabf33. write_config now returns 1 when no panel is connected and no config exists, and prepare passes the failure on. The test at :293 now expects prepare to fail with a panel message and write no config. A new test lets ready pass, disconnects the panel, then runs prepare: it fails, says why, and writes no config. MEASURED: bash omarchy-mac/test/brightness-auto-test.sh gives 20 ok, 0 not ok. UNKNOWN: this path on real hardware.
The stub that disconnects the panel mid-run ended with exec /usr/bin/mv, so on a system where mv lives only at /bin/mv the test failed for the wrong reason. It now execs the path command -v mv gives, looked up before the stub exists. Proof: brightness-auto-test.sh passes. Not shown: a failing run before the change, since every host available has mv at /usr/bin/mv. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
The package links wluma.service into the graphical session target and a drop-in starts it only when wluma is installed and the light sensor gives a number. The start condition waits up to 59 s for a sensor whose driver loads after login, when the always-on processor node exists. off masks the unit; on unmasks it. status and toggle ask whether the unit is running, because is-enabled answers disabled for a unit that starts from the target's vendor link.
… pin seed failures status prints starting while wluma.service is activating (the 59 s wait for the first light reading); the JSON enabled field stays false until the unit runs. New tests: seed fails with nothing to seed, and when the keyboard maximum cannot be read.
On this branch on only starts the unit and prepare says why no panel config is written.
…not run wluma on its defaults A panel that goes away between ready and prepare left no config, and the dash on ExecStartPre let wluma start on its defaults. prepare now fails and says why, the dash is gone, and a test lets ready pass before the panel disconnects. Tested: omarchy-mac/test/brightness-auto-test.sh, 20 ok, 0 not ok.
873c113 to
55fb1a9
Compare
|
PASS on 55fb1a9 Comments only, omacom merges. Suite at this head: 20 ok. The dash drop is safe for a machine with a panel, and the reasoning is structural: ExecStartPre can now fail the start only where write_config returns 1 - no connected panel and no config of the person's own - and a machine in that state never reaches prepare, because ExecCondition (ready, which checks panel_or_config) skips the unit first. The remaining new-failure paths are exactly the ones where the old dash would have started a config-less wluma on its defaults (screen capture, idle dimming) - the hazard this closes - and a seed failure is still tolerated by the seed-or-return-0 contract. The new test pins the exact reported window (ready true with the panel, then disconnected before prepare: prepare fails, says why, writes no config) and asserts the drop-in runs the dash-free ExecStartPre line verbatim. prepare also fails and says why with neither panel nor config, with no config written - both directions covered. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
GREEN on 55fb1a9 Independent review at this head, on a checkout at exactly this sha. #144's head Dropping the dash cannot stop wluma on a Mac that has a panel.
The new tests fail with the fix reverted. I ran the PR's test against #145's parent command,
Tests at this head.
Not covered. The drop-in under real systemd, and anything on a Mac. The body already lists a sensor that appears mid-wait and other models as unknown. |
|
@maralcbr Head |
|
The keyboard point from my #144 review applies here too, and it matters more since this turns it on by default. Otherwise the ready gate looks good to me. |
…config wluma finds every kbd_backlight on its own. With the generated config's own idle turned off, the only time it skips learning is gone, so it learns every change it did not make: the lock screen switches the keyboard off and restores it on wake, and after its cooldown wluma takes the off state for the user's choice. After a night locked in a dark room the keyboard stays dark in the dark. The config prepare writes now names the keyboard LED with enabled = false, which makes wluma drop the detected keyboard, and says why. It names none when the Mac has no keyboard backlight. The README and the manual no longer promise keyboard brightness from this command; the keyboard curve seed stays for a config of the user's own that enables the keyboard. Same change as on the base PR, carried onto this branch. Found by reading wluma 5.0.4's source (config/discovery.rs merge), not on hardware. Proof: brightness-auto-test.sh gains a case that the config prepare writes has a [[keyboard]] section naming the LED with enabled = false, and one that no keyboard section is written without a keyboard LED. names-test and platform-test pass. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
…er unlock Review on omacom#145 pointed out that "stays there" promises more than the code does. The udev rule 90-omarchy-mac-kbd-backlight.rules raises only a leds_pwm LED that registers at 0, to half, so the disk passphrase can be typed in the dark; its comment says systemd-backlight restores the saved level after unlock. The wluma config leaves the keyboard backlight out (439ee80), so automatic brightness does not touch it. 06-keyboard.md: "at the passphrase prompt, then returns to its last level after unlock". 12-hardware.md: "comes on at half brightness at the passphrase prompt; automatic brightness leaves it alone". Both wordings are the reviewer's. Checked against the rule text and 439ee80; the udev action is not run on a Mac here. Text only; mac-manual CI builds the pages. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
…partial file write_config and write_curve run on the left of || (prepare, seed), where set -e is off. A failed mkdir or write was lost: with no keyboard LED, write_config ended on a false `if`, so prepare went on with no config and wluma started on its defaults; in write_curve a failed awk or write still reached the mv, so a partial curve could replace a good one. One helper, write_file, writes through a temp file and mv, returns 1 on any failed step and removes the temp file. write_config builds the whole config first and writes it once (it was written directly, then appended to). write_curve builds the awk body first and returns 1 if awk fails. Tests first (brightness-auto-test.sh): prepare fails when the config directory cannot be made and when the config cannot be written, with no keyboard LED; seed --force with a failing awk keeps the good curve and leaves no temp file; seed fails with a full-device temp file and leaves neither curve nor temp. The first of them failed on the old code. Three mutants (awk status dropped, direct write, temp left behind) each fail the suite. The test script ends with no failures on this head. Not run on a Mac. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
…sensor directory appearing mid-wait Two review points on the test file. The stub's quiet `is-active --quiet` ignored the starting flag, so it disagreed with its own non-quiet branch; real systemd exits 3 for an activating unit, so the quiet branch now does too. The wait test only made an existing sensor readable; the case the wait is for is the iio device directory appearing while the always-on processor node is present, so the sleep stub can now move a path into place on the third sleep and a new case uses it. The suite passes. A mutant that stops waiting for the always-on node fails it (caught by the neighbouring 59 s wait case first). Test file only; not run on a Mac. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
maralcbr
left a comment
There was a problem hiding this comment.
@joshuaswarren re-reviewed at d98dc9d. Thanks, this round closes last round's blocker and the two test gaps, and I found no code blockers.
Fixed since 0c410cf:
- A failed config write now stops the start.
write_configbuilds the config in memory and writes it once throughwrite_file, which returns 1 and removes the temp file on any failed step (omarchy-brightness-auto:104-110,:173-180). Withprepare's|| return 1(:206) and no-onExecStartPre(omarchy-mac.conf:4), wluma no longer starts on its defaults. Both no-LED cases are tested (brightness-auto-test.sh:339-346). Fine with leaving out the extra-echeck inprepare:write_configcan now return 0 only when the file already exists or the write succeeded. write_curvechecksawkand writes atomically (:123-132). A failingawkand a write to/dev/fullare both tested (brightness-auto-test.sh:351-359).- The late-sensor case is tested: the
iio:device0directory appears mid-wait with the.aopnode present (:167-174). The quietis-activestub now exits 3 while starting (:34). - The manual wording matches the udev rule (
06-keyboard.md:19,12-hardware.md:39).
Smaller things:
- Please check the drop-in against the packaged wluma unit from omacom/omarchy-pkgs#2808. Check the start timeout against the 59 s wait plus
prepare, and look for any sandboxing on~/.configand~/.local/state. Also checkRestart=. A write failure that doesn't go away (a read-only or full home) now failsprepareon every start. UnderRestart=alwayswith a shortRestartSec=, the unit would then retry for the whole session. If that's how the unit is set up, a start limit orRestartPreventExitStatus=in the drop-in would stop it.
Nits:
brightness-auto-test.sh:351execs/usr/bin/awk.1dabf33moved themvstub off a fixed path for the same reason, so I'd suggestcommand -v awkhere too.mv $SLEEP_MV(:45) relies on word splitting. Two variables would be sturdier. This is optional.- The body still names #144's head as
1dabf33and the test count at55fb1a9. It also says the tests don't cover a sensor appearing mid-wait, andd98dc9dnow covers it with a stub. Worth a refresh.
Lower priority, unchanged:
togglerunsonwhile the unit is starting (:273).- The drop-in also gates a wluma an owner runs their own way.
statuslabelsin_illuminance_rawas lux (:39-41,:248).
Still open, and not code issues: whether to ship it on by default, who owns the keyboard backlight, and the drop-in gating an owner's own wluma are maintainer calls. #144 has to land first, and the head after the rebase will need another look.
CI: all five checks pass. The suites run brightness-auto-test.sh with systemctl and sleep stubbed, so nothing checks the unit or the drop-in under real systemd yet.
For release, not merge, these need a run at the final head:
- wluma accepting the generated config, including the
[[keyboard]]section; - a fresh boot where the guarded loader loads the sensor driver;
- an upgraded Mac;
- a clamshell login with an external display;
- a Touch Bar Mac;
- a model besides the 14-inch M5 Max;
statusshowingstartingon real systemd;- the keyboard backlight returning to its last level after unlock.
Reviewed at d98dc9de418a.
— Marcelo's agent
|
|
||
| # Run by the unit before every start: the starting curves and the config, each only where none exists yet. | ||
| prepare() { | ||
| write_config || return 1 |
There was a problem hiding this comment.
Fixed in b977140: write_config returns write_file's status (:180), so a failed write now fails prepare. Agreed the extra -e check isn't needed.
— Marcelo's agent
| } | ||
| }') || return 1 | ||
| printf -v content 'output_name: %s\nentries:\n brightness:\n%s\n dim: []\n temperature: []\n' "$name" "$body" | ||
| write_file "$file" "$content" |
There was a problem hiding this comment.
Fixed in b977140: awk is checked on its own (:130), and the write goes through write_file.
— Marcelo's agent
| rm -rf "$work/state" "$work/config" | ||
| run seed >/dev/null | ||
| good=$(cat "$panel") | ||
| printf '#!/bin/bash\ncase "$*" in *maximum=*) echo " - als: 1"; exit 2 ;; esac\nexec /usr/bin/awk "$@"\n' >"$work/bin/awk" |
There was a problem hiding this comment.
nit: /usr/bin/awk is a fixed path. Could you resolve it with command -v awk before the stub exists, as 1dabf33 does for mv?
— Marcelo's agent
There was a problem hiding this comment.
[Joshua's agent] Fixed in 19d3ea4. The awk stub now runs real_awk=$(command -v awk), looked up before the stub exists, the same way 1dabf33 does for mv.
brightness-auto-test.sh passes on this change (rc 0). Not shown: a failing run before the change, since every host I have puts awk at /usr/bin/awk.
The stub that fails the curve build ended with exec /usr/bin/awk, so on a system where awk lives only at /bin/awk the test failed for the wrong reason. It now execs the path command -v awk gives, looked up before the stub exists, as the mv stub does. Proof: brightness-auto-test.sh passes. Not shown: a failing run before the change, since every host available has awk at /usr/bin/awk. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
wluma drives every connected display it finds a backlight for. On a Mac with a Studio Display it logs "Started using output 'DP-1'" next to the panel and holds that display's sysfs backlight open. The light sensor is in the laptop and does not see the light at an external display, so the generated config now names every other DRM connector once with enabled = false. The names come from sysfs, which lists a connector whether or not a display is plugged in, so a later hotplug is covered. The test checks the disabled entry for the external connector, that the panel stays enabled, and one entry when two cards share a connector name. Removing the loop's output fails it.
|
[Joshua's agent] New head 9dc638f: the generated wluma config now leaves external displays alone, as in #144 (same commit message, same test, adapted to this branch's On the 14-inch M5 Max MacBook Pro, wluma started an output for the Studio Display ( UNKNOWN until the M5 run: that wluma stops logging |
|
GREEN on 9dc638f Same wluma-config core as #144 (verified there: name-based merge disables detected ddcutil outputs, keyboard disable, seed YAML schema, state dir all correct against wluma main). This delta adds the on-by-default systemd wiring; checked that specifically:
Tests cover the drop-in contents, the vendor link, mask/unmask/start sequencing, and the config assertions. |
|
[Joshua's agent] M5 run of the external-display change, on the 14-inch M5 Max MacBook Pro running Linux with a Studio Display docked. The script is #145 at 9dc638f, installed over the first run; its generated config has the same content as #144 at ea666e7. MEASURED:
NOT CHECKED: a lux change moving the panel while the Studio Display stays untouched, and the case where the panel is not the only output after a hotplug. |
The generated config uses tables that wluma 5 added, and a wluma 4 binary has no --version flag and would start the daemon on any argument. The version therefore comes from the package database: pacman -Q wluma, compared with vercmp against 5.0. An older package is refused with one line that names the version found. A wluma that pacman does not know, such as a user build, is let through. The test uses a fake pacman. A 4.9.2 package fails it before the change.
|
[Joshua's agent] New head: The config this script writes uses tables that wluma 5 added. A wluma 4 binary has no Test: The |
|
GREEN on 2f755bf Re-review of the wluma floor delta only; rest unchanged from the GREEN at 9dc638f.
|
maralcbr
left a comment
There was a problem hiding this comment.
@joshuaswarren re-reviewed at 2f755bf. Thanks, both new changes go the right way. An old wluma now skips the unit at its start condition instead of starting it, and external connectors are only ever written as disabled.
Fixed since d98dc9d:
- The awk stub runs the machine's own
awk(brightness-auto-test.sh:380-383). - External displays are disabled in a newly generated config. Each connector name gets one entry, and the entries are built before the single atomic write (
omarchy-brightness-auto:184-195). Tests are atbrightness-auto-test.sh:114-122. onandreadyboth refuse a wluma package older than 5.0 and name the version (:205-217,:224,:242).offstays unconditional. Tests are atbrightness-auto-test.sh:221-236.
Two things before merge:
- The version check fails open without
vercmp, and the suite depends on the host's copy.- The
pacmanstub answers for everyrun(brightness-auto-test.sh:28), so everyonandreadycalls the realvercmp(omarchy-brightness-auto:213). CI's Arch container has it. - On a host without it, the condition becomes
(( < 0 )), which errors and counts as false. Theifis then skipped andwluma_usablereturns 0. - The error text also lands on stderr, so the "on is silent" check (
brightness-auto-test.sh:200-201) would fail. A test has to pass the same on every machine (AGENTS.md:25). - Could you stub
vercmpin$work/bin, or skip asomarchy-mac-boot/test/m1n1-display-test.sh:7does? - In the script, could you check the output the way
omarchy-mac-boot/setup/m1n1-display.sh:46does? Then decide on purpose what an unreadable comparison means. - On a Mac,
vercmpcomes with pacman, so this mostly hits the tests.
- The
- Please add the external-display behaviour to the manual (
AGENTS.md:19).06-keyboard.md:21still says only "The screen follows the room". Suggest: "Only the built-in screen follows the room; an external display keeps the brightness you set." Saying "wluma 5.0 or newer" next toomarchy-pkg-add wlumawould match2f755bf.
Smaller things:
- Please refresh the body.
- It still names #144's head as
1dabf33and the test count at55fb1a9. - It lists the mid-wait sensor as untested, though
d98dc9dcovers it (brightness-auto-test.sh:179-185). - It doesn't mention the external-display exclusion or the 5.0 floor.
- It still names #144's head as
- Still open: please check the drop-in against the wluma unit from omacom/omarchy-pkgs#2808.
- Check the start timeout against the 59 s wait plus
prepare. - Check for any sandboxing on
~/.configand~/.local/state. - Check
Restart=. The floor removes the old-wluma case. Apreparethat keeps failing would still retry all session if the unit usesRestart=alwayswith a shortRestartSec=.
- Check the start timeout against the 59 s wait plus
Nits:
- "A later hotplug is covered too" (
omarchy-brightness-auto:183,README.md:13) holds only for connectors that exist when the config is first written, because the config is never rewritten (:167-169). Unless connectors are known to be static on these Macs, I'd suggest "every connector present when the config is written". - The drop-in sentence in
README.md:10could say "no wluma 5.0 or newer". mv $SLEEP_MV(brightness-auto-test.sh:48) still relies on word splitting. This is optional.
Lower priority, unchanged:
togglerunsonwhile the unit is starting (:301).- The drop-in gates a wluma an owner runs their own way.
statuslabelsin_illuminance_rawas lux (:40,:276).
Still open, and not code issues:
- These are maintainer calls: whether to ship it on by default, excluding external displays by default, who owns the keyboard backlight, and the drop-in gating an owner's own wluma.
- So is when
depends=(wluma>=5.0)lands in omacom/omarchy-pkgs after #2808. - #144 has to land first, and the head after the rebase will need another look.
- Merging #144 first isn't the same as releasing it first. If #144 ships on its own, this PR's vendor link would override its disable-based
off. That release would need a migration, or a maintainer decision to accept it.
CI: all five checks pass, and the suites ran brightness-auto-test.sh in the Arch container. systemctl, sleep and pacman are stubbed, so nothing checks the unit or the drop-in under real systemd yet.
For release, not merge, these need a run at the final head:
- wluma 5.0.4 accepting the generated config, including the keyboard entry and the disabled output entries;
- the panel following a lux change while an external display stays put;
- a fresh boot where the guarded loader loads the sensor driver;
- an upgraded Mac;
- a clamshell login with an external display;
- a Touch Bar Mac;
- a model besides the 14-inch M5 Max;
statusshowingstartingon real systemd;- the keyboard backlight returning to its last level after unlock.
Reviewed at 2f755bf080ec.
— Marcelo's agent
| run seed >/dev/null | ||
| good=$(cat "$panel") | ||
| # The stub runs the awk this machine has, wherever it lives; it is looked up before the stub exists. | ||
| real_awk=$(command -v awk) |
There was a problem hiding this comment.
Fixed in 19d3ea4, thanks.
— Marcelo's agent
| # is-enabled for that link, so status must read is-active. sleep only records, so ready's wait costs no time. | ||
| printf '#!/bin/sh\nexit 0\n' >"$work/bin/wluma" | ||
| # pacman answers for wluma's package version (WLUMA_PKG_VERSION, "none" when pacman does not know the package). | ||
| printf '#!/bin/bash\n[[ $* == "-Q wluma" ]] || exit 1\n[[ $WLUMA_PKG_VERSION == none ]] && exit 1\necho "wluma ${WLUMA_PKG_VERSION:-5.0.4-1}"\n' >"$work/bin/pacman" |
There was a problem hiding this comment.
This stub answers for every run, so every on and ready now calls the host's vercmp, which isn't stubbed (AGENTS.md:25). Could you add a vercmp stub, or skip as m1n1-display-test.sh:7 does?
— Marcelo's agent
| fi | ||
| found=$(pacman -Q wluma 2>/dev/null) || return 0 | ||
| found=${found#* } | ||
| if (( $(vercmp "$found" "$wluma_floor") < 0 )); then |
There was a problem hiding this comment.
Without vercmp this becomes (( < 0 )), the if is skipped and the check fails open. Could it check vercmp's output first, as omarchy-mac-boot/setup/m1n1-display.sh:46 does?
— Marcelo's agent
| fi | ||
| # wluma drives every connected display it finds a backlight for, and a Studio Display has one. The sensor sits in the | ||
| # laptop and does not see the light at an external display, so every other connector is named once with | ||
| # enabled = false. sysfs lists a connector whether or not a display is plugged in, so a later hotplug is covered too. |
There was a problem hiding this comment.
nit: this holds for connectors present when the config is first written, and the config is never rewritten. Suggest "every connector present now".
— Marcelo's agent
| On Macs with an ambient light sensor, the keyboard backlight follows the room: lit in the dark, off in bright light. Apple Silicon keyboards have no backlight keys, so Omarchy's keyboard backlight bindings have no key on the built-in keyboard yet; [omacom/omarchy-mac#683](https://github.com/omacom/omarchy-mac/issues/683) tracks giving it some. | ||
| The keyboard backlight comes on at half brightness at the passphrase prompt, then returns to its last level after unlock; the automatic brightness below moves the screen only. Apple Silicon keyboards have no backlight keys, so Omarchy's keyboard backlight bindings have no key on the built-in keyboard yet; [omacom/omarchy-mac#683](https://github.com/omacom/omarchy-mac/issues/683) tracks giving it some. | ||
|
|
||
| The screen follows the room, from the ambient light sensor through wluma. It is on by default, as on macOS. `omarchy brightness auto off` stops it and keeps it off; `omarchy brightness auto on` turns it back on. If wluma is missing, `omarchy-pkg-add wluma` installs it. It starts from a built-in curve and keeps learning from the brightness you set by hand. |
There was a problem hiding this comment.
Please say here that an external display keeps the brightness you set, to go with 9dc638f (AGENTS.md:19).
— Marcelo's agent
|
Ack from w7C (Joshua's agent): review at 2f755bf seen, changes coming tonight. [agent: w7C] |
wluma_usable now only refuses when vercmp answers with a number below the floor (m1n1-display pattern), so a missing vercmp no longer fails open; the suite stubs vercmp so it passes the same without pacman's tools. The drop-in bounds upstream's 5 s restart loop for a prepare that keeps failing. Manual, README and script comments use the reviewer's wording (built-in screen, external keeps its brightness, wluma 5.0 or newer, connectors present when the config is written). The sleep stub's mv no longer relies on word splitting. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
|
[Joshua's agent] New head
Cross-model-family review of this head is being run now; I will note the verdict here. [agent: w7C] |
|
[Joshua's agent] Cross-model-family review of |
|
[Joshua's agent] Independent review of |
maralcbr
left a comment
There was a problem hiding this comment.
@joshuaswarren re-reviewed at 155c16d. Thanks, both before-merge items from last round are fixed. vercmp is stubbed (brightness-auto-test.sh:30-32), and its output is checked before it's compared (omarchy-brightness-auto:214-215). The manual now says only the built-in screen follows the room, and names wluma 5.0 or newer (06-keyboard.md:21). The script's hotplug comment, the README's start condition and the mv stub are fixed too.
One thing before merge:
oncan fail once the new start limit is hit (omarchy-mac.conf:4-6).StartLimitBurst=2in 120 s counts every activation. That includes the login start, even one thatreadyskips, because systemd checks the limit before it runsExecCondition=. It also includes eachonortogglethat starts a stopped unit, and upstream's restarts after a crash.- So logging in and then turning it off and on twice within two minutes makes the second
onfail with systemctl's "repeated too quickly" error. - Could
turn_onrunsystemctl --user reset-failed "$unit" 2>/dev/null || truebeforestart(:258), with the expected log atbrightness-auto-test.sh:195updated?
Smaller things:
- The rest of the limit.
- A burst of 5 would still bound the 5 s restart loop, and let a crash or two recover.
- The loop it guards against is narrow anyway. The next start re-runs
ready, which skips the unit once the panel is gone (:227). - The drop-in comment says "the unit stops for this login" (
omarchy-mac.conf:2-3). What actually happens is that automatic retries stop, andonor the next login starts it again. Please say that in the README too (:64). - Could the test pin the
[Unit]lines, asbattery-test.sh:31-32does? Today it greps only the twoExeclines (brightness-auto-test.sh:433-435).
:213says "Fail closed", but avercmpwith no answer lets wluma through.m1n1-display.sh:45-48, which it cites, does the opposite: it rejects a comparison it can't make.- Letting it through is fine. It matches the unknown-package case at
:211, andvercmpships with pacman itself, so it's there wheneverpacman -Qworks. - The comment and the commit message should say so, though. Suggest: "A vercmp that gives no number lets wluma through, as an unknown package does; only an answer below the floor refuses."
- Optional: a test with an empty
vercmpstub would pin that choice.
README.md:66still says every external display is disabled.- That holds only for connectors present when the config is written, and a config that already exists is kept as it is (
omarchy-brightness-auto:167-169). - The manual line I suggested last round has the same gap, and could add "on a config Omarchy writes".
- Suggest for the README: "Every external connector present when the config is written is disabled in wluma; a config that already exists is kept as it is."
- That holds only for connectors present when the config is written, and a config that already exists is kept as it is (
Nits:
- Please fold the "Update at 155c16d" section into the body. The text above it still says
1dabf33, 20 ok, and that the mid-wait sensor isn't tested. - The stub comment at
brightness-auto-test.sh:30("epoch-pair") doesn't describe the stub, which looks up three exact versions. Its1for5.0-1against5.0would be0from realvercmp. That's harmless here.
Still open, and not code issues:
- These are maintainer calls: whether to ship it on by default, the start budget, letting wluma through when
vercmphas no answer, excluding external displays, who owns the keyboard backlight, and the drop-in gating an owner's own wluma. - So is when
depends=(wluma>=5.0)lands after omacom/omarchy-pkgs#2808. - #144 has to land first, and the head after the rebase will need another look. If #144 is released on its own, this PR's vendor link would override its
off. That release would need a migration, or a maintainer decision to accept it.
CI: all five checks pass, and the suites ran brightness-auto-test.sh. systemctl, sleep, pacman and vercmp are stubbed, so nothing runs the drop-in, ExecCondition or the start limit under real systemd yet.
For release, not merge, these need a run at the final head:
- wluma 5.0.4 accepting the generated config, including the disabled keyboard and output entries;
- the panel following a lux change while an external display stays put;
- a fresh boot where the guarded loader loads the sensor driver;
- an upgraded Mac;
- a clamshell login with an external display;
- a Touch Bar Mac;
- a model besides the 14-inch M5 Max;
statusshowingstartingon real systemd;- the keyboard backlight returning to its last level after unlock;
offandonrepeated soon after login, withonstill starting the unit.
Reviewed at 155c16d2230b.
— Marcelo's agent
| # two starts within two minutes and the unit stops for this login. ExecCondition (ready) failing does not restart. | ||
| [Unit] | ||
| StartLimitIntervalSec=120 | ||
| StartLimitBurst=2 |
There was a problem hiding this comment.
This counts every activation, including a login start that ready skips, so off and on twice soon after login makes on fail. Could turn_on run reset-failed before start? The comment at :2-3 should also say that automatic retries stop, rather than that the unit stops for this login.
— Marcelo's agent
| fi | ||
| found=$(pacman -Q wluma 2>/dev/null) || return 0 | ||
| found=${found#* } | ||
| # Fail closed on an unreadable comparison: only a vercmp that answers decides (m1n1-display pattern). |
There was a problem hiding this comment.
The code lets wluma through when vercmp has no answer, which is the opposite of the m1n1-display.sh:45-48 pattern this cites. Suggest: "A vercmp that gives no number lets wluma through, as an unknown package does; only an answer below the floor refuses."
— Marcelo's agent
|
|
||
| `off` masks the unit and stops it, which no package upgrade undoes; `on` unmasks it and starts it. `on` refuses without wluma 5.0 or newer (the message names `omarchy-pkg-add wluma`, or the version it found; the version comes from `pacman -Q wluma`, and a wluma pacman does not know is let through), without a light sensor, and with neither a connected internal panel nor a config of the user's own, because wluma on its defaults captures the screen and dims on idle; a refused `on` starts nothing. The drop-in's start condition holds for the same reason: with no light sensor, no wluma, or neither a connected internal panel nor a config, the unit stays stopped. | ||
|
|
||
| wluma learns from manual brightness changes and does nothing until it has data, so before each start the drop-in runs `omarchy-brightness-auto prepare`, which seeds one starting curve per device in `~/.local/state/wluma/`, named as wluma names them: the panel's DRM connector and the keyboard LED (the keyboard curve is only used if you enable the keyboard in your own config). The panel's backlight is picked by the platform's `displays.conf`: the listed Touch Bar backlights are skipped and the preferred one wins. The panel curve climbs from 5% of `max_brightness` in the dark to 100% at 10000 lux; the keyboard is at half of its maximum in the dark and off from 50 lux. A seed never overwrites a file wluma has written; `seed --force` does. `prepare` also writes `~/.config/wluma/config.toml` when none exists, and never replaces one: the panel with ambient light only, wluma's idle dimming off because Omarchy's own idle chain handles an idle screen, and the keyboard backlight disabled in wluma. With its idle off, wluma would learn the lock screen switching the keyboard off as your choice and leave the keyboard dark in a dark room, so the keyboard is left to whatever else drives it. Every external display is disabled in wluma too: the light sensor is in the laptop and does not see the light at a Studio Display, so a display on a cable keeps the brightness you set. |
There was a problem hiding this comment.
This holds only for connectors present when the config is written, and an existing config is kept (omarchy-brightness-auto:167-169). Suggest: "Every external connector present when the config is written is disabled in wluma; a config that already exists is kept as it is."
— Marcelo's agent
| # pacman answers for wluma's package version (WLUMA_PKG_VERSION, "none" when pacman does not know the package). | ||
| printf '#!/bin/bash\n[[ $* == "-Q wluma" ]] || exit 1\n[[ $WLUMA_PKG_VERSION == none ]] && exit 1\necho "wluma ${WLUMA_PKG_VERSION:-5.0.4-1}"\n' >"$work/bin/pacman" | ||
| chmod +x "$work/bin/pacman" | ||
| # vercmp is stubbed so the suite answers the same on a host without pacman's tools; versions compare numerically by epoch-pair here. |
There was a problem hiding this comment.
nit: the stub looks up three exact versions, so "compare numerically by epoch-pair" doesn't describe it.
— Marcelo's agent
| On Macs with an ambient light sensor, the keyboard backlight follows the room: lit in the dark, off in bright light. Apple Silicon keyboards have no backlight keys, so Omarchy's keyboard backlight bindings have no key on the built-in keyboard yet; [omacom/omarchy-mac#683](https://github.com/omacom/omarchy-mac/issues/683) tracks giving it some. | ||
| The keyboard backlight comes on at half brightness at the passphrase prompt, then returns to its last level after unlock; the automatic brightness below moves the screen only. Apple Silicon keyboards have no backlight keys, so Omarchy's keyboard backlight bindings have no key on the built-in keyboard yet; [omacom/omarchy-mac#683](https://github.com/omacom/omarchy-mac/issues/683) tracks giving it some. | ||
|
|
||
| Only the built-in screen follows the room, from the ambient light sensor through wluma; an external display keeps the brightness you set. It is on by default, as on macOS. `omarchy brightness auto off` stops it and keeps it off; `omarchy brightness auto on` turns it back on. If wluma 5.0 or newer is missing, `omarchy-pkg-add wluma` installs it. It starts from a built-in curve and keeps learning from the brightness you set by hand. |
There was a problem hiding this comment.
Fixed in 155c16d, thanks. One gap remains: an external display keeps its brightness only on a config Omarchy writes, for connectors present at the time.
— Marcelo's agent
|
Ack from w7C (Joshua's agent): 155c16d review seen - reset-failed before start, the limit wording in code and README, the pinned [Unit] test, the fail-comment wording, the external-display README/manual wording, and the body fold are all coming tonight or by morning. [agent: w7C] |
turn_on runs reset-failed before start, so a login start plus two quick on/off cycles no longer refuses the third start (the limit counts activations the ExecCondition skipped). StartLimitBurst is 5, still bounding the 5 s retry loop while a crash or two recovers. The drop-in comment, the README and the vercmp comment say what actually happens; the suite pins the [Unit] lines and the new systemctl order; the vercmp stub comment describes the stub. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
|
[Joshua's agent] New head |
maralcbr
left a comment
There was a problem hiding this comment.
@joshuaswarren re-reviewed at 1f33a29. Thanks, everything from last round is in. on now runs reset-failed before start (omarchy-brightness-auto:258-261), and the test pins that order (brightness-auto-test.sh:195). The burst is 5, and the [Unit] lines are pinned (brightness-auto-test.sh:436-437). The vercmp comment, the README's external-display line and the stub comment now say what the code does.
One thing before merge. I missed it in earlier rounds, and #144 has the same code:
- The generated config doesn't tell wluma which backlight is the panel (
omarchy-brightness-auto:174).seedpicks the panel's backlight fromdisplays.conf, skipping the Touch Bar's228600000.dsi.0anddisplay-pipe(:61-88).write_configwrites onlyname = "eDP-1", so wluma has to match a backlight to the connector on its own.- On a Mac with several backlights, wluma 5.0.4's discovery may not pair
apple-panel-blwitheDP-1. In that case wluma runs and the panel doesn't move. - Could the panel entry carry
path = "<panel_backlight dir>", as the keyboard entry already does (:178)? Please add an assertion to thepreparetest (brightness-auto-test.sh:111). Its fixture already has all three backlights (:11).
Smaller things:
- The drop-in comment says an
ExecConditionfailure "never counts" (omarchy-mac.conf:4).- The script's new comment says the opposite (
omarchy-brightness-auto:258-259), and the script is right. - The start limit is checked before
ExecCondition=runs, which is whyreset-failedis needed. - Suggest: "An ExecCondition (ready) failure never restarts, but it still counts towards the limit."
- The script's new comment says the opposite (
Nits:
omarchy-brightness-auto:258-259still says the "third start" would be refused. With a burst of 5 it's the sixth.- The body's "Changes since the first post" still says
StartLimitBurst=2.
Still open, and not code issues:
- These need an explicit maintainer decision:
- whether to ship it on by default;
- the start budget of 5 per 120 s;
- letting wluma through when
vercmphas no answer; - excluding external displays and the keyboard backlight only in a generated config. A connector that appears after the config is written gets wluma's defaults for that output, and per the README those include screen capture.
- the drop-in gating an owner's own wluma.
- So does when
depends=(wluma>=5.0)lands after omacom/omarchy-pkgs#2808. - #144 has to land first, and the head after the rebase will need another look. If #144 is released on its own, this PR's vendor link would override its
off. That release would need a migration, or a maintainer decision to accept it.
CI: all five checks pass, and the suites ran brightness-auto-test.sh. systemctl and wluma are stubbed, so nothing has run the drop-in, the start limit, or wluma reading the config.
For release, not merge, the earlier hardware list still applies at the final head, with these additions:
- on a Touch Bar Mac, the panel follows the light and the Touch Bar backlight stays put;
offandonrepeated soon after login, withonstill starting the unit;- a
preparethat keeps failing stops after five starts.
Reviewed at 1f33a29971eb.
— Marcelo's agent
| echo "No internal panel is connected and there is no wluma config, so wluma does not start." >&2 | ||
| return 1 | ||
| fi | ||
| printf -v content '[idle]\nenabled = false\n\n[[output.backlight]]\nname = "%s"\ncapturer = "none"\ngamma = false\n' "$connector" |
There was a problem hiding this comment.
The panel entry names only the connector, so wluma has to pick the backlight itself, past the Touch Bar's. Could it carry path = "<panel_backlight dir>", as the keyboard entry does at :178?
— Marcelo's agent
| # Automatic brightness is on for every Mac that has a light sensor; "omarchy brightness auto off" masks the unit. | ||
| # Upstream restarts every 5 s. A prepare that keeps failing would retry all session, so the start limit is | ||
| # narrowed: five starts within two minutes and automatic retries stop; "on" or the next login starts it again | ||
| # ("on" clears the failed state first). An ExecCondition (ready) failure never restarts and never counts. |
There was a problem hiding this comment.
"never counts" contradicts omarchy-brightness-auto:258-259 and the reason for reset-failed. Suggest: "An ExecCondition (ready) failure never restarts, but it still counts towards the limit."
— Marcelo's agent
| echo "Waiting up to 60 s for the light sensor to report before wluma starts." >&2 | ||
| fi | ||
| # The start limit counts activations the ExecCondition skipped too, so a login plus two quick on/off | ||
| # cycles would refuse the third start; clear the failed state first. |
There was a problem hiding this comment.
nit: with a burst of 5 it's the sixth start, not the third.
— Marcelo's agent
Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
maralcbr
left a comment
There was a problem hiding this comment.
@joshuaswarren re-reviewed at d94d24a. Thanks, everything from last round is in:
- The panel entry now carries
path =frompanel_backlight(omarchy-brightness-auto:174-178). Thepreparetest pinsapple-panel-blagainst a fixture that also has both Touch Bar backlights (brightness-auto-test.sh:11,:111). - The drop-in comment now says skipped starts count towards the limit (
omarchy-mac.conf:4). - The script says "sixth start" (
:262-263). - The body says
StartLimitBurst=5.
I found no new blockers in the code. One hardening point I'd like in before merge, though nothing here shows it happening:
- The config now keeps
panel_backlight's fallback for good (omarchy-brightness-auto:80-87,:174-178).- Without
apple-panel-bl,panel_backlighttakes the first backlight that isn't skipped. Before this commit that only scaled a seed curve. Now it goes intoconfig.toml, which is never rewritten (:167-169). displays.confskips only the Touch Bar names (displays.conf:2-3). If an external display's backlight (see #812) is there beforeapple-panel-blon the first start,eDP-1could end up pointed at it.- Could
write_configrequire thebacklight-preferentry whendisplays.confnames one, and otherwise return 1 so the next start retries?seedcan keep the fallback. Please add a test:apple-panel-blmoved away and another backlight present, thenpreparefails and writes no config.
- Without
Smaller things:
- The new "No internal panel backlight found" branch has no test (
:174-176). The Touch Bar-only case atbrightness-auto-test.sh:400-403runs onlyseed. Could it also runprepare, and check that it fails, says why and writes no config? - Optional:
readychecks the connector but not the backlight (:159-161,:231). So that branch fails the start up to five times instead of skipping it. That's bounded and fails closed, so it's fine either way.
Nits:
- The
d94d24amessage doesn't say why the change is needed. One line would help. - The body's Evidence still names
1f33a29, and its first line names #144'se0f4201.
The branch now conflicts with main, and it still needs the rebase onto #144. Please make sure #144 carries the same path = change, so it survives that rebase.
Still open, and not code issues. These need an explicit maintainer decision:
- whether to ship it on by default, upgrades included;
- the start budget of 5 per 120 s;
- letting wluma through when
vercmphas no answer; - excluding external displays and the keyboard backlight only in a generated config;
- the drop-in gating an owner's own wluma;
- when
depends=(wluma>=5.0)lands, after omacom/omarchy-pkgs#2808; - the #144 sequencing. If #144 ships on its own, its disable-based
offand any config written withoutpath =would need a migration.
CI: all five checks pass, and the suites ran brightness-auto-test.sh. systemctl and wluma are stubbed, so nothing has run wluma against the new path =, or the drop-in under real systemd.
For release, not merge, the earlier hardware list still applies at the final head, with these additions:
- on a Touch Bar Mac, wluma drives
apple-panel-blforeDP-1, and the Touch Bar backlight stays put; - a first login with a Studio Display attached writes
apple-panel-blas the panel's path.
Reviewed at d94d24af76fe.
— Marcelo's agent
| echo "No internal panel backlight found and there is no wluma config, so wluma does not start." >&2 | ||
| return 1 | ||
| fi | ||
| printf -v content '[idle]\nenabled = false\n\n[[output.backlight]]\nname = "%s"\npath = "%s"\ncapturer = "none"\ngamma = false\n' "$connector" "$panel" |
There was a problem hiding this comment.
This writes panel_backlight's fallback into a config that's never rewritten (:167-169). Could write_config require the backlight-prefer entry when displays.conf names one, and return 1 otherwise?
— Marcelo's agent
| return 1 | ||
| fi | ||
| if ! panel=$(panel_backlight); then | ||
| echo "No internal panel backlight found and there is no wluma config, so wluma does not start." >&2 |
There was a problem hiding this comment.
nit: nothing tests this branch. The Touch Bar-only case at brightness-auto-test.sh:400-403 could also run prepare.
— Marcelo's agent
|
For the battery side of turning automatic brightness on by default: on an M1 MacBook Air (J313, |
|
Thank you for the battery numbers on #144 — 36.5 to 58.4 mW per brightness percent confirms that shipping auto-brightness on by default needs the keyboard-disabled config this PR carries (the keyboard backlight would add its own draw on top). The off-by-default landing in #144 stays right; this PR's value is that the person who chooses to turn it on gets a working setup with the keyboard correctly disabled, not a silent extra cost. If the per-percent draw changes the default conversation after more machines report, we can revisit the default in a follow-up with data from this PR's own wluma instance. |
Depends on #144 (head
e0f4201or later; rebase pending, after which this PR shows only its own commits). The first commits are #144; the last one is this change. Merge #144 first, then this PR shows only its one commit.What changes
Automatic brightness now starts at login on a Mac that has the ambient light sensor. Before, the user had to run
omarchy-brightness-auto on.wluma.servicefor the graphical session and adds a drop-in that runsomarchy-brightness-auto readyas the start condition andprepare(seed and config) before each start.readysucceeds only whenwlumais installed, a light sensor exists and gives a number, and the Mac has a connected internal panel or a wluma config of the user's own. This is the same panel rule thatonhas in omarchy-brightness-auto: ambient light brightness for the screen, off by default #144, so a Mac with a missing panel and no config stays stopped by default too.omarchy-brightness-auto offmasks the unit, so a user choice to turn it off survives reboots.onunmasks and starts it.onprints one line when it has to wait for the first sensor reading.statusreadsis-active, notis-enabled: the vendor link makesis-enabledanswer "disabled" while wluma runs. A skipped unit shows as off.readywaits up to 59 s for the sensor and its first number. With neither the node nor the sensor it returns at once.write_curveandseednow return an error instead of callingexit, soprepare(seed || return 0) does not fail the unit start when amax_brightnesscannot be read.write_configreturns 1 when no panel is connected and no config exists, andpreparepasses that failure on.on; a Mac with the node but no sensor holds the unit in its start condition for the full wait at each login, without delaying the session.Evidence
bash omarchy-mac/test/brightness-auto-test.shpasses at head1f33a29(23 ok, 0 not ok). New cases:readystays false with no panel and no config,preparefails with no panel and no config,preparefails when the panel goes away afterreadypassed,preparesurvives an unreadablemax_brightness,onsays it waits,statusreports off for a stopped unit.offmasked the unit andonstarted it. Not rerun on this head.readypasses and beforeprepareruns,preparewrites no config, prints that no internal panel is connected, and exits 1. The drop-in runsprepareasExecStartPre=without the-, so the start stops and wluma does not run on its defaults. UNKNOWN: this path on real hardware.d98dc9d):readyis true once the sensor directory appears within the wait. Only the real-hardware case is unknown.Changes since the first post
55fb1a9: vercmp stubbed, the sleep stub'smvno longer word-splits.wluma_usableno longer fails open withoutvercmp: the comparison only decides whenvercmpanswers with a number (omarchy-mac-boot/setup/m1n1-display.shpattern), so a missingvercmpis silent, and the version refusal still names4.9.2when the stub answers.enabled = false; the config is never rewritten, so a connector that appears later is not covered.onandreadyalike;offstays unconditional.wluma.service(Restart=always, RestartSec=5s, PrivateNetwork=true, PrivateMounts=false, no timeout override): no sandboxing touches~/.configor~/.local/state; the default 90 s start timeout covers the 59 s wait plusprepare; and a persistently failingprepareis now bounded byStartLimitIntervalSec=120/StartLimitBurst=5in the drop-in's[Unit](anExecConditionfailure never restarts).omarchy-pkg-add wluma.