From 67508af47d23a38e55162150d7eb77694b03814b Mon Sep 17 00:00:00 2001 From: fredrikr79 Date: Mon, 29 Sep 2025 14:43:24 +0200 Subject: [PATCH] caps lock notification --- configuration.nix | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 13934ba..421e94d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -253,7 +253,10 @@ in # Define a user account. Don't forget to set a password with ‘passwd’. users.users.${user} = { isNormalUser = true; - extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + extraGroups = [ + "wheel" + "input" + ]; # Enable ‘sudo’ for the user. initialPassword = "password"; packages = with pkgs; [ # managed by home-manager @@ -301,6 +304,8 @@ in nnn libreoffice-qt6-fresh nix-tree + evtest + dunst ] ); @@ -570,4 +575,30 @@ in }; wantedBy = [ "timers.target" ]; }; + + systemd.user.services.caps-lock-notify = { + description = "Caps lock state notification"; + script = '' + caps_state="" + prev_state="" + + while true; do + caps_state=$(${pkgs.xorg.xset}/bin/xset q 2>/dev/null | ${pkgs.gnugrep}/bin/grep "Caps Lock" | ${pkgs.gawk}/bin/awk '{print $4}' || echo "") + + if [ -n "$caps_state" ] && [ "$caps_state" != "$prev_state" ] && [ -n "$prev_state" ]; then + ${pkgs.libnotify}/bin/notify-send "Caps Lock" "$caps_state" -t 1000 + fi + + prev_state="$caps_state" + sleep 0.1 + done + ''; + serviceConfig = { + Type = "simple"; + Restart = "always"; + RestartSec = 3; + }; + wantedBy = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; + }; }