repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

Use wiki RUN+= rule for backlight group; demote polkit; explain NotYourDevice

403306e7b97988a450f684900b6fa60dae963e36

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (2)

ironbar/PLAN.md

Modified
397 397 - Rejected for this host: the seat's `ActiveSession` is the greeter (Type=wayland, Class=greeter) and the user session is `Idle=yes`. udev `uaccess` hands the device to the session that owns the seat, not the user session ironbar runs in. Live test: after installing `ACTION=="add", SUBSYSTEM=="backlight", TAG+="uaccess"`, `SetBrightness` still returned `NotYourDevice`. Rule was removed. Skip on this seat layout, or also reconfigure seat ownership.
399 -Recommended fix (Option B): polkit rule for `login1.set-brightness`.
399 +Note on polkit `login1.set-brightness`:
401 +- `NotYourDevice` is raised by `logind` **before** polkit is consulted, so the polkit rule cannot fix it on this seat layout. Staged at `polkit/10-brightness.rules` for completeness; install only after the seat is reconfigured so a real user session owns the foreground.
403 +Arch wiki ([Backlight](https://wiki.archlinux.org/title/Backlight)) recommended fix: udev `RUN+=` to chgrp/chmod the sysfs file, plus the `video` group. sysfs `brightness` is a `DEVICE_ATTR_RW` whose mode is hardcoded `0644`; udev `GROUP=` / `MODE=` keys do **not** apply to sysfs. The rule must include `KERNEL==` to avoid a `RUN+=` flood on every brightness change.
402 - doas install -m 0644 /home/oli/Workspace/dotfiles/polkit/10-brightness.rules /etc/polkit-1/rules.d/10-brightness.rules
403 - systemctl --user restart ironbar.service
406 + # udev/backlight.rules
407 + ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="intel_backlight", RUN+="/usr/bin/chgrp video /sys/class/backlight/intel_backlight/brightness"
408 + ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="intel_backlight", RUN+="/usr/bin/chmod g+w /sys/class/backlight/intel_backlight/brightness"
407 - # /etc/polkit-1/rules.d/10-brightness.rules
408 - polkit.addRule(function(action, subject) {
409 - if (action.id == "org.freedesktop.login1.set-brightness" &&
410 - subject.local && subject.active) {
411 - return polkit.Result.YES;
412 - }
413 - });
412 + doas install -m 0644 /home/oli/Workspace/dotfiles/udev/backlight.rules /etc/udev/rules.d/backlight.rules
413 + doas udevadm control --reload
414 + doas udevadm trigger --subsystem-match=backlight --action=add
415 + doas usermod -aG video oli # log out / log in (or `newgrp video` for current shell)
416 -Alternative Option C: write access via group `video` (last resort; not staged, because `chmod` does not survive sysfs re-creation and `usermod -aG video` requires a re-login):
418 - ```sh
419 - doas chgrp video /sys/class/backlight/intel_backlight/brightness
420 - doas chmod 664 /sys/class/backlight/intel_backlight/brightness
421 - doas usermod -aG video oli
422 - ```
418 + After that, logind `SetBrightness` from the user session still works through the builtin `systemd` backend; sysfs is also directly writable by members of `video` for any helper that bypasses logind (e.g. `brightnessctl` from inside the user session).
424 420 ### Step 9 — bindmode

udev/backlight.rules

Added
new file mode 100644
1 +ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="intel_backlight", RUN+="/usr/bin/chgrp video /sys/class/backlight/intel_backlight/brightness"
2 +ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="intel_backlight", RUN+="/usr/bin/chmod g+w /sys/class/backlight/intel_backlight/brightness"