about summary refs log tree commit diff
path: root/home/wm/swaylock/default.nix
blob: a22d548d86c8a40c92f7e2f384e01b765f4f88ed (plain) (blame)
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
{ config, lib, pkgs, ... }:
let isEnabled = config.my.home.wm.windowManager == "sway";
in
{
  config = lib.mkIf isEnabled {
    xdg.configFile."swaylock/config" = { source = ./config; };

    services.swayidle = {
      enable = true;
      events = [
        {
          event = "before-sleep";
          command = "${pkgs.swaylock}/bin/swaylock -fF";
        }
        {
          event = "lock";
          command = "${pkgs.swaylock}/bin/swaylock -fF";
        }
      ];
      timeouts = [
        {
          timeout = 300;
          command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
          resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\"";
        }
        {
          timeout = 310;
          command = "${pkgs.systemd}/bin/loginctl lock-session";
        }
      ];
    };

  };
}