From 4057634a7a91ecc4a1aff3d7acd11b0d7b422027 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 23 Mar 2021 22:08:01 +0200 Subject: 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 Tested-by: BuildkiteCI --- users/tazjin/nixos/tverskoy/default.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'users') diff --git a/users/tazjin/nixos/tverskoy/default.nix b/users/tazjin/nixos/tverskoy/default.nix index 066d54899f84..7d2e01b0971b 100644 --- a/users/tazjin/nixos/tverskoy/default.nix +++ b/users/tazjin/nixos/tverskoy/default.nix @@ -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"; -- cgit 1.4.1