fix: i3 lock on sleep

This commit is contained in:
Noah Masur 2022-05-17 08:43:47 -04:00
parent ec4dcbd3a6
commit 490c78714f

View File

@ -2,7 +2,7 @@
let let
lockCmd = ''exec i3lock --nofork --color "${config.gui.colorscheme.base00}"''; lockCmd = ''i3lock --nofork --color "${config.gui.colorscheme.base00}"'';
in { in {
@ -124,7 +124,7 @@ in {
"${modifier}+Shift+r" = "restart"; "${modifier}+Shift+r" = "restart";
"${modifier}+Shift+q" = '' "${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'"''; 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 # Window options
"${modifier}+q" = "kill"; "${modifier}+q" = "kill";
@ -238,6 +238,19 @@ in {
extraConfig = ""; 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" ];
};
}; };
} }