I have no nice release but on hyprland, I use the following to increase /sys/class/backlight/intel_backlight/brightness by steps of +- 200 units that I calibrated with my eyeballs and /sys/class/backlight/intel_backlight/max_brightness:
binde = , XF86MonBrightnessDown, exec, $HOME/.config/hypr/changebrightness.sh - 200
binde = , XF86MonBrightnessUp, exec, $HOME/.config/hypr/changebrightness.sh + 200
The script is just reading /sys/class/backlight/intel_backlight/brightness and writing back the same value +- 200
The most important is what plays with that: color inversion, red shift, contrast increase, so install gammarelay-rs and wl-gammactl then do key mappings.
The contrast increase is a nice feature to avoid trimming low contrast element (ex: light key text on a grey background), before moving to use exclusively red on black ("submarine" night mode)
# alt= dark red nightmode
# WARNING conflict betweel wl-gammarelay-rs and wl-gammactl: before using one, must killall the other first
# So unconditionally kill the other before running commands
bind = ALT,Print, exec, killall wl-gammactl
bind = ALT,Print, exec, killall wl-gammarelay-rs || ( wl-gammarelay-rs & busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay Temperature q 1000 )
# Control= increase contrast for OLED dark
bind = CONTROL,Print, exec, killall wl-gammarelay-rs
bind = CONTROL,Print, exec, killall wl-gammactl || GTK_THEME=Adwaita-amoled-dark-Fix wl-gammactl -c 2.500 -b 0.700 -g 1.000
# Shift= invert
bind = SHIFT,Print, exec, killall wl-gammarelay-rs
bind = SHIFT,Print, exec, killall wl-gammactl || GTK_THEME=Adwaita-amoled-dark-Fix wl-gammactl -c -1.000 -b 2.000 -g 1.000
# Win= brightness menu
bind = WIN,Print, exec, killall wl-gammarelay-rs
bind = WIN,Print, exec, killall wl-gammactl || GTK_THEME=Adwaita-amoled-dark-Fix wl-gammactl
> I’ve been wanting to do something similar for ages for those few occasions where ambient sunlight really wanted me moving to something that wasn’t a dark.
If it's a rare occasion, you must use a dark theme by default, so I would do
- first Ctrl+Printscreen to try to increase the constrast of your back theme: it's rare and counterintuitive, but if you have no reflections on the screen, it can help in the sun
- if it's not enough cancel it by another Ctrl+PrintScreen, then Shift+Printscreen to toggle the inverted mode
- then Fn F5 (which causes XF86MonBrightnessDown on by thinkpad) to reduce the brightness until you like it
If works best if you have OS-wide theme toggle. I use 2 terminals with different themes because unlike on Windows Terminal, on Linux the hot toggles of colors themes for Terminals isn't working so well.
If you have a brightness sensor (often in the keyboard, for color calibration on thinkpads, or in the webcam housing for balance adjustement), you could do much better: record in a sqlite database the timestamps, the brightness value, and your actions (ex: reducing lightness +400)
After a few days of collecting metrics, you should be able to calibrate a default reponse that would change with your habits: imagine pressing a key and reproducing your modal reponse to this kind of ambiant brightness (this theme, that brightness, this color filter...)