From 8218f499e074ce4b642da9f79165cd2a3c369e21 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 11 Jan 2023 17:24:18 -0800 Subject: ref(home/swayidle): configure it using upstream module --- home/wm/swaylock/default.nix | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'home/wm') diff --git a/home/wm/swaylock/default.nix b/home/wm/swaylock/default.nix index 803a7c3..a22d548 100644 --- a/home/wm/swaylock/default.nix +++ b/home/wm/swaylock/default.nix @@ -5,24 +5,30 @@ 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"; - }; + 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"; + } + ]; }; + }; } -- cgit 1.4.1