From ba6d0ee9183469bb0b9c9d90bd46e1c5b7ee8614 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 4 Apr 2026 16:09:33 +0100 Subject: [PATCH] home: wm: screen-lock: use 'writeShellApplication' More robust implementation of the notifier. --- modules/home/wm/screen-lock/default.nix | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/home/wm/screen-lock/default.nix b/modules/home/wm/screen-lock/default.nix index ac6851c..208e529 100644 --- a/modules/home/wm/screen-lock/default.nix +++ b/modules/home/wm/screen-lock/default.nix @@ -2,13 +2,19 @@ let cfg = config.my.home.wm.screen-lock; - notificationCmd = - let - duration = toString (cfg.notify.delay * 1000); - notifyCmd = "${lib.getExe pkgs.libnotify} -u critical -t ${duration}"; - in - # Needs to be surrounded by quotes for systemd to launch it correctly - ''"${notifyCmd} -- 'Locking in ${toString cfg.notify.delay} seconds'"''; + lockNotifier = pkgs.writeShellApplication { + name = "lock-notifier"; + runtimeInputs = [ + pkgs.libnotify + ]; + text = '' + duration=${toString cfg.notify.delay} + notify-send \ + -u critical \ + -t "$((duration * 1000))" -- \ + "Locking in $duration seconds" + ''; + }; in { config = lib.mkIf cfg.enable { @@ -24,7 +30,7 @@ in "-notify" "${toString cfg.notify.delay}" "-notifier" - notificationCmd + (lib.getExe lockNotifier) ]; }; };