From c5fdfffaf6b2372432620a99cc72160b13b5da65 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Sun, 6 Oct 2024 15:57:08 +0200 Subject: [PATCH] home/programs/swayidle: add configuration, setup with loginctl --- home/profiles/vamos/default.nix | 1 + home/programs/niri/binds.nix | 14 ++++++++++---- home/programs/swayidle.nix | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 home/programs/swayidle.nix diff --git a/home/profiles/vamos/default.nix b/home/profiles/vamos/default.nix index a587323..811c76f 100644 --- a/home/profiles/vamos/default.nix +++ b/home/profiles/vamos/default.nix @@ -9,6 +9,7 @@ "${self}/home/programs/fuzzel.nix" "${self}/home/programs/swaybg.nix" "${self}/home/programs/swaylock.nix" + "${self}/home/programs/swayidle.nix" "${self}/home/terminal/emulators/foot.nix" diff --git a/home/programs/niri/binds.nix b/home/programs/niri/binds.nix index eaa78ba..6e33da7 100644 --- a/home/programs/niri/binds.nix +++ b/home/programs/niri/binds.nix @@ -1,7 +1,11 @@ -{config, ...}: let +{ + config, + pkgs, + lib, + ... +}: let appLauncher = "fuzzel"; terminal = "foot"; - screenLocker = "swaylock"; in { programs.niri.settings.binds = { "Mod+D".action.spawn = appLauncher; @@ -114,8 +118,10 @@ in { "Alt+Print".action = config.lib.niri.actions.screenshot-window; # System - "Mod+Shift+P".action = config.lib.niri.actions.power-off-monitors; - "Mod+Alt+L".action.spawn = screenLocker; + "Mod+Alt+L".action.spawn = [ + "${lib.getExe' pkgs.systemd "loginctl"}" + "lock-session" + ]; # Media keys "XF86AudioRaiseVolume" = { diff --git a/home/programs/swayidle.nix b/home/programs/swayidle.nix new file mode 100644 index 0000000..a3d3423 --- /dev/null +++ b/home/programs/swayidle.nix @@ -0,0 +1,20 @@ +{ + lib, + config, + ... +}: { + services.swayidle = { + enable = true; + events = [ + { + event = "lock"; + command = "${lib.getExe config.programs.swaylock.package}"; + } + { + event = "before-sleep"; + command = "${lib.getExe config.programs.swaylock.package}"; + } + ]; + }; + systemd.user.services.swayidle.Unit.After = lib.mkForce ["graphical-session.target"]; +}