From 185781a4e2b1357e9def17a097a11a9a7ac0a5b5 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 6 Apr 2021 18:27:38 +0000 Subject: [PATCH] home: wm: i3: add binding to toggle xautolock --- home/wm/i3.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/home/wm/i3.nix b/home/wm/i3.nix index f81d881..7c29c8b 100644 --- a/home/wm/i3.nix +++ b/home/wm/i3.nix @@ -218,6 +218,25 @@ in "${modifier}+Shift+space" = "mode floating"; "${modifier}+0" = ''mode "${shutdownMode}"''; } + (lib.optionalAttrs config.my.home.wm.screen-lock.enable { + "${modifier}+x" = + let + systemctlUser = "${pkgs.systemd}/bin/systemctl --user"; + notify = "${pkgs.libnotify}/bin/notify-send -u low " + + "-h string:x-canonical-private-synchronous:xautolock-toggle"; + toggleXautolock = pkgs.writeScript "toggle-xautolock" '' + #!/bin/sh + if ${systemctlUser} is-active xautolock-session.service; then + ${systemctlUser} stop --user xautolock-session.service + ${notify} "Disabled Xautolock" + else + ${systemctlUser} start xautolock-session.service + ${notify} "Enabled Xautolock" + fi + ''; + in + "exec ${toggleXautolock}"; + }) ]; keycodebindings =