feat(tazjin/tverskoy): Enable automatic screen locking

Defines a small helper script that resets the keyboard layout (to
avoid getting stuck in Russian layout) and locks the screen via
xsecurelock, and configures home-manager to launch this automatically.

Fascinatingly this actually seems to be capable of locking the
screen *on suspend*, not *after suspend*.

Change-Id: Ib6279a445aba18c2fb5bc073b675e6e2598fa228
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2644
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2021-03-23 22:08:01 +02:00 committed by tazjin
parent 4daa4c1923
commit 4057634a7a

View file

@ -16,6 +16,15 @@ config: let
enableDaemon = false;
monolithic = false;
};
# Use a screen lock command that resets the keyboard layout
# before locking, to avoid locking me out when the layout is
# in Russian.
screenLock = nixpkgs.writeShellScriptBin "tazjin-screen-lock" ''
${nixpkgs.xorg.setxkbmap}/bin/setxkbmap us
${nixpkgs.xorg.setxkbmap}/bin/setxkbmap -option caps:super
exec ${nixpkgs.xsecurelock}/bin/xsecurelock
'';
in lib.fix(self: {
imports = [
"${depot.third_party.impermanence}/nixos.nix"
@ -195,6 +204,7 @@ in lib.fix(self: {
emacs
third_party.lieer
tools.nsfv-setup
screenLock
]) ++
# programs from nixpkgs
@ -279,6 +289,15 @@ in lib.fix(self: {
pull.rebase = true;
};
};
services.screen-locker = {
enable = true;
enableDetectSleep = true;
inactiveInterval = 10; # minutes
lockCmd = "${screenLock}/bin/tazjin-screen-lock";
};
systemd.user.startServices = true;
};
system.stateVersion = "20.09";