summaryrefslogtreecommitdiff
path: root/modules/home-manager/hypridle.nix
blob: 1c920a99cafcb1480f23fe7c8250cf927cce79da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{pkgs , ... }: {
  services.hypridle = {
    enable = true;
    settings = 
    let
    dpmsCommand = "${pkgs.hyprland}/bin/hyprctl dispatch dpms";
    brightnessSet = "${pkgs.brightnessctl}/bin/brightnessctl -s %% brightnessctl s";
    # brightnessSet = "${pkgs.brightnessctl}/bin/brightnessctl";
    in {
      general = {
        lock_cmd = "pidof swaylock || swaylock"; # avoid starting multiple swaylock instances.
        # unlock_cmd = "notify-send 'unlock!'"
        before_sleep_cmd = "${dpmsCommand} off";
        after_sleep_cmd = "${dpmsCommand} on";
        ignore_dbus_inhibit = false;
      };
      listener = [
        {
          timeout = 180;
          on-timeout = "${brightnessSet} 15%";
          on-resume = "brightnessctl -r";
        }
        { #comment out if no keyboard backlight
          timeout = 200;
          on-timeout = "brightnessctl -sd asus::kbd_backlight set 0";
          on-resume = "brightnessctl -rd asus::kbd_backlight";
        }
        {
          timeout = 300;
          on-timeout = "loginctl lock-session";
        }
        {
          timeout = 350;
          on-timeout = "${dpmsCommand} off";
          on-resume = "${dpmsCommand} on";
        }
        {
          timeout = 420;
          on-timeout = "systemctl suspend";
          # on-timeout = "${brightnessSet} 0% && systemctl suspend";
          # on-resume = "brightnessctl -r";
        }
      ];
    };
  };
}