home: Adjust display brightness using backlight
This commit is contained in:
parent
9acbf395fd
commit
af37c28a6c
2 changed files with 19 additions and 53 deletions
|
@ -2,32 +2,15 @@
|
|||
let
|
||||
osConfig = args.osConfig or { };
|
||||
|
||||
brightnessctl = lib.getExe pkgs.brightnessctl;
|
||||
busctl = osConfig.systemd.package + /bin/busctl;
|
||||
gammarelay = lib.getExe pkgs.wl-gammarelay-rs;
|
||||
pwvucontrol = lib.getExe pkgs.pwvucontrol;
|
||||
wpctl = osConfig.services.pipewire.wireplumber.package + /bin/wpctl;
|
||||
|
||||
gr = cmd: "${busctl} --user -- ${cmd} rs.wl-gammarelay / rs.wl.gammarelay";
|
||||
gr-get = gr "get-property";
|
||||
gr-set = gr "set-property";
|
||||
gr-call = gr "call";
|
||||
|
||||
gr-inv = let
|
||||
pkg = pkgs.writeShellApplication {
|
||||
name = "gammarelay-inverted";
|
||||
text = ''
|
||||
state="$(${gr-get} Inverted)";
|
||||
|
||||
if [[ "$state" == "b false" ]]; then
|
||||
echo
|
||||
elif [[ "$state" == "b true" ]]; then
|
||||
echo
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
};
|
||||
in lib.getExe pkg;
|
||||
in lib.mkIf (osConfig.hardware.graphics.enable or false) {
|
||||
programs.waybar = {
|
||||
enable = true;
|
||||
|
@ -61,10 +44,8 @@ in lib.mkIf (osConfig.hardware.graphics.enable or false) {
|
|||
"disk"
|
||||
"battery"
|
||||
"idle_inhibitor"
|
||||
"custom/gammarelay-temperature"
|
||||
"custom/gammarelay-brightness"
|
||||
"custom/gammarelay-gamma"
|
||||
"custom/gammarelay-invert"
|
||||
"backlight"
|
||||
"custom/gammarelay"
|
||||
"mpris"
|
||||
"pulseaudio#sink"
|
||||
"pulseaudio#source"
|
||||
|
@ -123,7 +104,14 @@ in lib.mkIf (osConfig.hardware.graphics.enable or false) {
|
|||
timeout = 15.0;
|
||||
};
|
||||
|
||||
"custom/gammarelay-temperature" = {
|
||||
"backlight" = {
|
||||
format = " {percent} %";
|
||||
on-click-right = "${brightnessctl} set 100%";
|
||||
on-scroll-up = "${brightnessctl} set +1%";
|
||||
on-scroll-down = "${brightnessctl} set 1%-";
|
||||
};
|
||||
|
||||
"custom/gammarelay" = {
|
||||
format = " {} K";
|
||||
exec = "${gammarelay} watch {t}";
|
||||
on-click-right = "${gr-set} Temperature q 6500";
|
||||
|
@ -131,31 +119,6 @@ in lib.mkIf (osConfig.hardware.graphics.enable or false) {
|
|||
on-scroll-down = "${gr-call} UpdateTemperature n -100";
|
||||
};
|
||||
|
||||
"custom/gammarelay-brightness" = {
|
||||
format = " {} %";
|
||||
exec = "${gammarelay} watch {bp}";
|
||||
on-click-right = "${gr-set} Brightness d 1";
|
||||
on-scroll-up = "${gr-call} UpdateBrightness d +0.01";
|
||||
on-scroll-down = "${gr-call} UpdateBrightness d -0.01";
|
||||
};
|
||||
|
||||
"custom/gammarelay-gamma" = {
|
||||
format = "γ {}";
|
||||
exec = "${gammarelay} watch {g}";
|
||||
on-click-right = "${gr-set} Gamma d 1";
|
||||
on-scroll-up = "${gr-call} UpdateGamma d +0.01";
|
||||
on-scroll-down = "${gr-call} UpdateGamma d -0.01";
|
||||
};
|
||||
|
||||
"custom/gammarelay-invert" = {
|
||||
exec = gr-inv;
|
||||
exec-on-event = true;
|
||||
interval = 60;
|
||||
|
||||
on-click = "${gr-call} ToggleInverted";
|
||||
on-click-right = "${gr-set} Inverted b false";
|
||||
};
|
||||
|
||||
battery = let
|
||||
fmt = "{capacity} %";
|
||||
dis = {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
let
|
||||
osConfig = args.osConfig or { };
|
||||
|
||||
busctl = osConfig.systemd.package + /bin/busctl;
|
||||
brightnessctl = lib.getExe pkgs.brightnessctl;
|
||||
fish = lib.getExe osConfig.programs.fish.package;
|
||||
fuzzel = lib.getExe config.programs.fuzzel.package;
|
||||
kitty = lib.getExe config.programs.kitty.package;
|
||||
|
@ -12,8 +12,6 @@ let
|
|||
wpctl = osConfig.services.pipewire.wireplumber.package + /bin/wpctl;
|
||||
xdg-open = pkgs.xdg-utils + /bin/xdg-open;
|
||||
|
||||
busctl-gr = [ busctl "--user" "--" "call" "rs.wl-gammarelay" "/" "rs.wl.gammarelay" ];
|
||||
|
||||
niri-each-output = let
|
||||
pkg = pkgs.writeShellApplication {
|
||||
name = "niri-each-output";
|
||||
|
@ -130,8 +128,8 @@ in lib.mkIf (osConfig.hardware.graphics.enable or false) {
|
|||
|
||||
XF86Explorer.action = spawn [ xdg-open "https:" ];
|
||||
} // lib.mapAttrs (n: v: v // { allow-when-locked = true; }) {
|
||||
XF86MonBrightnessUp.action = spawn (busctl-gr ++ [ "UpdateBrightness" "d" "0.05" ]);
|
||||
XF86MonBrightnessDown.action = spawn (busctl-gr ++ [ "UpdateBrightness" "d" "-0.05" ]);
|
||||
XF86MonBrightnessUp.action = spawn [ brightnessctl "-e" "set" "+5%" ];
|
||||
XF86MonBrightnessDown.action = spawn [ brightnessctl "-e" "set" "5%-" ];
|
||||
XF86AudioRaiseVolume.action = spawn [ wpctl "set-volume" "@DEFAULT_AUDIO_SINK@" "+2dB" ];
|
||||
XF86AudioLowerVolume.action = spawn [ wpctl "set-volume" "@DEFAULT_AUDIO_SINK@" "-2dB" ];
|
||||
XF86AudioMute.action = spawn [ wpctl "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle" ];
|
||||
|
@ -173,6 +171,11 @@ in lib.mkIf (osConfig.hardware.graphics.enable or false) {
|
|||
];
|
||||
|
||||
timeouts = [
|
||||
{
|
||||
timeout = 210;
|
||||
command = "${brightnessctl} --save -e set 20%-";
|
||||
resumeCommand = "${brightnessctl} --restore";
|
||||
}
|
||||
{
|
||||
timeout = 240;
|
||||
command = "${loginctl} lock-session";
|
||||
|
|
Loading…
Reference in a new issue