fix(backlight): Use brightnessctl

light is unmantained and xbacklight doesn't work on wayland
This commit is contained in:
Jalil David Salamé Messina 2024-01-24 18:41:11 +01:00
parent 26d7f20dd6
commit 682fc0633c
Signed by: jalil
GPG key ID: F016B9E770737A0B
2 changed files with 4 additions and 5 deletions

View file

@ -19,7 +19,8 @@ let
[ -f "$msgid_file" ] && msgid="$(cat "$msgid_file")" [ -f "$msgid_file" ] && msgid="$(cat "$msgid_file")"
msgid="''${msgid:-0}" msgid="''${msgid:-0}"
# Get brightness # Get brightness
brightness="$(xbacklight -perceived -get)" brightness="$(${pkgs.brightnessctl}/bin/brightnessctl --machine-readable info | awk -F "\"*,\"*" '{print $4}')"
brightness="$${brightnes%\%}" # strip % sign
# Send notification # Send notification
${pkgs.libnotify}/bin/notify-send -pu low -r "$msgid" -a "$app" -i "$icon" -h int:value:"$brightness" "Brightness: $brightness%" >"$msgid_file" ${pkgs.libnotify}/bin/notify-send -pu low -r "$msgid" -a "$app" -i "$icon" -h int:value:"$brightness" "Brightness: $brightness%" >"$msgid_file"
''; '';
@ -98,8 +99,8 @@ builtins.foldl' (l: r: l // r)
"XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- && ${audio-source-notify}"; "XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- && ${audio-source-notify}";
"XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && ${audio-source-notify}"; "XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && ${audio-source-notify}";
"XF86ScreenSaver" = "exec swaylock --image ${cfg.background}"; "XF86ScreenSaver" = "exec swaylock --image ${cfg.background}";
"XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5 && ${brightness-notify}"; "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5% && ${brightness-notify}";
"XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5 && ${brightness-notify}"; "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%- && ${brightness-notify}";
# Floating # Floating
"${mod}+Space" = "floating toggle"; "${mod}+Space" = "floating toggle";
"${mod}+Shift+Space" = "focus mode_toggle"; "${mod}+Shift+Space" = "focus mode_toggle";

View file

@ -30,8 +30,6 @@ in
fonts.fontDir.enable = true; fonts.fontDir.enable = true;
# Backlight control
programs.light.enable = true;
programs.dconf.enable = true; programs.dconf.enable = true;
programs.sway.enable = cfg.sway; programs.sway.enable = cfg.sway;