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

    # https://github.com/nix-community/home-manager/pull/2610
    # won't be needed for ever
    systemd.user.services.swayidle = {
      Unit.PartOf = [ "sway-session.target" ];
      Install.WantedBy = [ "sway-session.target" ];

      Service = {
        Environment =
          "PATH=${pkgs.bash}/bin:${config.wayland.windowManager.sway.package}/bin";
        ExecStart = ''
          ${pkgs.swayidle}/bin/swayidle -w \
              timeout 300 "${pkgs.swaylock}/bin/swaylock" \
              timeout 300 'swaymsg "output * dpms off"' \
                  resume 'swaymsg "output * dpms on"' \
              before-sleep "${pkgs.swaylock}/bin/swaylock"
        '';
        Restart = "on-failure";
      };
    };
  };
}