aboutsummaryrefslogtreecommitdiff
path: root/modules/desktop/sway/swayidle.nix
blob: 0708abc502171bdc70c0bfa7c6a10b168ca2efc4 (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
{
  config,
  lib,
  pkgs,
  username,
  ...
}:

{
  options.nx.desktop.swayidle.enable = lib.mkEnableOption "Enable swayidle configuration" // {
    default = config.nx.desktop.sway.enable;
  };
  config = lib.mkIf config.nx.desktop.swayidle.enable {
    home-manager.users."${username}" = {
      services.swayidle = {
        enable = true;
        timeouts = [
          {
            timeout = 300;
            command = "${pkgs.swaylock}/bin/swaylock -f -c 000000";
          }
          {
            timeout = 600;
            command = "${pkgs.sway}/bin/swaymsg 'output * dpms off";
            resumeCommand = "${pkgs.sway}/bin/swaymsg output * dpms on";
          }
          {
            timeout = 900;
            command = "${pkgs.systemd}/bin/systemctl suspend";
          }
        ];
        events = [
          {
            event = "after-resume";
            command = "${pkgs.sway}/bin/swaymsg output * dpms on";
          }
          {
            event = "before-sleep";
            command = "${pkgs.swaylock}/bin/swaylock -f -c 000000";
          }
        ];
      };
    };
  };
}