about summary refs log tree commit diff
path: root/users/tazjin/nixos/tverskoy
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-03-23T20·08+0200
committertazjin <mail@tazj.in>2021-03-23T21·00+0000
commit4057634a7a91ecc4a1aff3d7acd11b0d7b422027 (patch)
tree1965d2861289d910bf1b5a45d7fa2051a6a8786f /users/tazjin/nixos/tverskoy
parent4daa4c192374a0e6e5596507541d832dd5d02f4d (diff)
feat(tazjin/tverskoy): Enable automatic screen locking r/2321
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
Diffstat (limited to 'users/tazjin/nixos/tverskoy')
-rw-r--r--users/tazjin/nixos/tverskoy/default.nix19
1 files changed, 19 insertions, 0 deletions
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";