about summary refs log tree commit diff
path: root/users/fcuny/desktop/sway/sway-idle.nix
blob: 8583a3b4d988aed700670414e038c1946c32fe16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{ pkgs, 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 -f -c FFFFEA" \
            timeout 300 'swaymsg "output * dpms off"' \
                resume 'swaymsg "output * dpms on"' \
            before-sleep "${pkgs.swaylock}/bin/swaylock -f -c FFFFEA"
      '';
      Restart = "on-failure";
    };
  };
}