From 6538c50662bb9fb83eb2aafcb14020c2c5b1e4e0 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Mon, 31 Aug 2026 11:51:37 +0800 Subject: [PATCH] feat(shoukei): enable wluma ambient-light auto brightness - read Asahi aop-sensors ALS via iio and drive eDP-1 backlight - drop PrivateUsers for wluma so it can reach the real user D-Bus session - remove hypridle 10min screen-dim listener: its brightnessctl writes fight wluma and get learned as manual adjustments --- home/hosts/linux/12kingdoms-shoukei.nix | 5 ++- home/hosts/linux/12kingdoms-shoukei/wluma.nix | 43 +++++++++++++++++++ home/linux/gui/base/hypridle/hypridle.conf | 10 ++--- 3 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 home/hosts/linux/12kingdoms-shoukei/wluma.nix diff --git a/home/hosts/linux/12kingdoms-shoukei.nix b/home/hosts/linux/12kingdoms-shoukei.nix index 9fd1931a..4cf470e3 100644 --- a/home/hosts/linux/12kingdoms-shoukei.nix +++ b/home/hosts/linux/12kingdoms-shoukei.nix @@ -4,7 +4,10 @@ let mkSymlink = config.lib.file.mkOutOfStoreSymlink; in { - imports = [ ../../linux/gui.nix ]; + imports = [ + ../../linux/gui.nix + ./12kingdoms-shoukei/wluma.nix + ]; programs.ssh.settings."github.com".IdentityFile = "${config.home.homeDirectory}/.ssh/${hostName}"; diff --git a/home/hosts/linux/12kingdoms-shoukei/wluma.nix b/home/hosts/linux/12kingdoms-shoukei/wluma.nix new file mode 100644 index 00000000..6c73e88d --- /dev/null +++ b/home/hosts/linux/12kingdoms-shoukei/wluma.nix @@ -0,0 +1,43 @@ +{ ... }: +# Automatic brightness for shoukei (the only host with an ambient light +# sensor: aop-sensors-als, exposed through iio-sensor-proxy). +# +# wluma learns brightness preferences from manual adjustments (the QuickShell +# slider counts as training data), then adjusts the backlight automatically +# based on ambient light + screen contents. +# +# gamma = false keeps color temperature handled by noctalia's NightLight +# (zwlr-gamma-control is an exclusive protocol, wluma and noctalia cannot +# both own it). Other hosts keep the existing time-based NightLight setup. +# +# No extra udev rules or ACLs are needed: the sysfs brightness node is +# root-owned, so wluma falls back to the systemd-logind D-Bus API +# (org.freedesktop.login1.Session.SetBrightness), which authorizes active +# sessions. Verified working inside Home Manager's default PrivateUsers +# sandbox; do not "fix" it by disabling the sandbox. +{ + services.wluma = { + enable = true; + # Exactly one top-level ALS section is mandatory in wluma's config. + # The als.iio path scans /sys/bus/iio/devices and picks up the AOP + # ambient light sensor (aop-sensors-als) exported via iio-sensor-proxy. + settings.als.iio = { + path = "/sys/bus/iio/devices"; + thresholds = { + "0" = "night"; + "20" = "dark"; + "80" = "dim"; + "250" = "normal"; + "500" = "bright"; + "800" = "outdoors"; + }; + }; + settings.output.backlight = [ + { + name = "eDP-1"; + path = "/sys/class/backlight/apple-panel-bl"; + gamma = false; + } + ]; + }; +} diff --git a/home/linux/gui/base/hypridle/hypridle.conf b/home/linux/gui/base/hypridle/hypridle.conf index f94c76de..02a35bf5 100644 --- a/home/linux/gui/base/hypridle/hypridle.conf +++ b/home/linux/gui/base/hypridle/hypridle.conf @@ -13,11 +13,11 @@ listener { on-resume = brightnessctl --restore --device=kbd_backlight # turn on keyboard backlight. } -listener { - timeout = 600 # 10min. - on-timeout = brightnessctl -s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor. - on-resume = brightnessctl -r # monitor backlight restore. -} +# NOTE: intentionally no 10min screen-dim listener here. Writing brightnessctl +# directly fights the ambient-light auto-brightness daemon (wluma on shoukei): +# wluma is adaptive, and hypridle's periodic brightness writes get learned as if +# the user had made those adjustments. niri (26.04) has no built-in idle timers, +# so hypridle stays responsible for keyboard backlight, dpms and locking below. listener { timeout = 1200 # 20 minutes