From cdc29efafcce0fa1b843a3e83eba357dd6d0ac35 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 6 Apr 2021 17:54:26 +0000 Subject: [PATCH] home: wm: screen-lock: add xautolock options --- home/wm/default.nix | 7 +++++++ home/wm/screen-lock.nix | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/home/wm/default.nix b/home/wm/default.nix index 05c0e85..b4cece9 100644 --- a/home/wm/default.nix +++ b/home/wm/default.nix @@ -47,6 +47,13 @@ in description = "Locker command to run"; }; + cornerLock = my.mkDisableOption '' + Move mouse to upper-left corner to lock instantly, lower-right corner to + disable auto-lock. + ''; + + notify = my.mkDisableOption "Notify when about to lock the screen"; + timeout = mkOption { type = types.ints.between 1 60; default = 5; diff --git a/home/wm/screen-lock.nix b/home/wm/screen-lock.nix index eca5895..e6eee22 100644 --- a/home/wm/screen-lock.nix +++ b/home/wm/screen-lock.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: let cfg = config.my.home.wm.screen-lock; in @@ -10,6 +10,21 @@ in inactiveInterval = cfg.timeout; lockCmd = cfg.command; + + xautolockExtraOptions = lib.optionals cfg.cornerLock [ + # Mouse corners: instant lock on upper-left, never lock on lower-right + "-cornerdelay" + "5" + "-cornerredelay" + "5" + "-corners" + "+00-" + ] ++ lib.optionals cfg.notify [ + "-notify" + "5" + "-notifier" + ''"${pkgs.libnotify}/bin/notify-send -u critical -t 5000 -- 'Locking in 5 seconds'"'' + ]; }; }; }