Repository navigation
Conversation
A brightness key press spends about sixteen processes: hyprctl and jq twice over for the monitor name, three more bash helpers, brightnessctl and awk to read the percentage, brightnessctl to write it, the same again for the OSD, then omarchy-osd and omarchy-shell around jq and timeout. Those bindings are repeating, so it happens several times a second while the key is down. omarchy-media does the same work in one binary, and exec replaces this shell rather than running beside it, so a press is one process plus the qs call the OSD needs. Same argv, same percentages, same exit codes. Two cases in the test suite are re-pointed at where the work happens now: the internal panel is read from the kernel node rather than through brightnessctl, and the focused monitor comes from Hyprland rather than from a stub for the script this no longer calls. Both assert the same behaviour as before. Co-Authored-By: cefege <cefege@users.noreply.github.com>
|
Notes for whoever reviews this, so they are not all in the description. Trying it without the package
git clone https://github.com/cefege/omarchy-media
cd omarchy-media && cargo build --release
PATH="$PWD/target/release:$PATH" ./test/shell.d/brightness-display-test.shThe suite runs green against the wrapper that way — it is how the four bugs in Fifty runs of each, same machine, timed the same way:
That machine spawns processes slowly, which is why the last row matters: most of The two behaviour differences, in fullA failed write now exits 1. The script runs The internal panel is read from the kernel. Not through RevertingOne commit, one file of behaviour. What is not in hereThe audio and keyboard commands are the same shape and are not part of this PR. |
|
One blocking issue besides the packaging step you already listed: adding echo "Install omarchy-media for the brightness keys"
omarchy-pkg-add omarchy-mediaThe larger question is a product call: moving a core key path into a separate binary from a personal repo means the maintainers take on its packaging and review. #13332 also edits |
A brightness key press currently spends about sixteen processes:
omarchy-hyprland-monitor-focused(bash +hyprctl+jq)omarchy-hyprland-monitor-focused-apple(bash +hyprctl+jq)omarchy-hw-display(bash)brightnessctl+awkbrightnessctlbrightnessctl+awkomarchy-osd(bash +jq) +omarchy-shell(bash +timeout+qs)default/hypr/bindings/media.luamarks those bindingsrepeating = true, soit happens several times a second while the key is held down.
This moves the implementation to
cefege/omarchy-media, which does the
same work in one binary: the monitor list comes from Hyprland's socket instead
of
hyprctl | jq, the internal panel is read from/sys/class/backlightdirectly, and the OSD is one
qs ipccall.execreplaces the wrapper's shellrather than running beside it, so a press is one process, plus the
qscallthe OSD needs and a
brightnessctlcall on writes, where the kernel node isroot-owned and brightnessctl is what talks to systemd-logind.
Same argv, same percentages, same exit codes. The
# omarchy:header stays,because
omarchyroutes subcommands through it.Measured
omarchy-media benchruns the query form 50 times with every helper onPATHreplaced by a logging stub, and reports what a press cost and what it called:
The comparable figure is a shell loop over each side, 50 runs, timed the same
way on the same machine (aarch64, Hyprland, one internal panel):
omarchy-media/bin/true, for scaleThat machine spawns processes slowly, which is what the last row is for: most
of what is left after the rewrite is the cost of starting any process at all.
The work itself is under a millisecond, and the process count goes from sixteen
to one. Run it on your own hardware with the loop the bench prints.
Deliberate behaviour differences
brightnessctl's exitstatus and carries on to show an OSD for a brightness that did not change.
The native command exits 1 with the reason on stderr. Only reachable when
brightnessctl also fails.
brightnessctl.The percentage is brightnessctl's rule,
roundf(current / max * 100)inf32, so the number on the OSD does not move.Tests
test/shell.d/brightness-display-test.shpasses unchanged apart from two casesthat are re-pointed at where the work happens now: the panel case reads a fake
kernel node instead of asserting a
brightnessctlcall, and the focused-monitorcase answers Hyprland instead of stubbing a script this no longer calls. Both
still assert the same behaviour. The full suite and
brightness-display-apple-cache-test.shpass against the wrapper.The package carries 39 tests of its own, 14 of which drive the built binary
with the same stubs and are the port of that suite; they found four bugs in the
native implementation, which is why they exist here rather than upstream.
Before this can merge
omarchy-medianeeds to be in a repository this can install from. It ispackaged and ready, but AUR is not GitHub, so submitting it is a manual step
and it is not done yet. Without it the base package list would fail to
pacstrap.
🤖 Generated with Claude Code