summaryrefslogtreecommitdiff
path: root/users/kassouni/palette/kbd-backlight.nix
blob: 9da0fb9f96dfb014a31c4c5dedb436eae497f81a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{ pkgs, ... }:
{
  kassouni.palette.commands = [
    {
      name = "toggle keyboard backlight";
      icon = "󰌌";
      # The leds sysfs node is group-writable by `video`, which kassouni is in, so
      # this needs no root. Toggle between off and full rather than cycling levels.
      exe = pkgs.writers.writeBash "kbd-backlight" ''
        set -eu
        dev=framework_laptop::kbd_backlight
        if [ "$(${pkgs.brightnessctl}/bin/brightnessctl -d "$dev" get)" -gt 0 ]; then
          ${pkgs.brightnessctl}/bin/brightnessctl -d "$dev" set 0
        else
          ${pkgs.brightnessctl}/bin/brightnessctl -d "$dev" set 100%
        fi
      '';
    }
  ];
}