From 490c78714fdc31509255f16ee89cf4a6b603a54c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 17 May 2022 08:43:47 -0400 Subject: [PATCH] fix: i3 lock on sleep --- modules/graphical/i3.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/graphical/i3.nix b/modules/graphical/i3.nix index 993e596..db32018 100644 --- a/modules/graphical/i3.nix +++ b/modules/graphical/i3.nix @@ -2,7 +2,7 @@ let - lockCmd = ''exec i3lock --nofork --color "${config.gui.colorscheme.base00}"''; + lockCmd = ''i3lock --nofork --color "${config.gui.colorscheme.base00}"''; in { @@ -124,7 +124,7 @@ in { "${modifier}+Shift+r" = "restart"; "${modifier}+Shift+q" = '' exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; - "${modifier}+Shift+x" = lockCmd; + "${modifier}+Shift+x" = "exec ${lockCmd}"; # Window options "${modifier}+q" = "kill"; @@ -238,6 +238,19 @@ in { extraConfig = ""; }; + systemd.services.lock = { + description = "Lock the screen on resume from suspend"; + before = [ "sleep.target" "suspend.target" ]; + serviceConfig = { + User = config.user; + Type = "forking"; + Environment = "DISPLAY=:0"; + ExecStart = '' + ${pkgs.i3lock}/bin/i3lock --color "${config.gui.colorscheme.base00}"''; + }; + wantedBy = [ "sleep.target" "suspend.target" ]; + }; + }; }