From 3b9c625b6446b4f68fc8c5d737bb7b4a40a363be Mon Sep 17 00:00:00 2001 From: ckie <25263210+ckiee@users.noreply.github.com> Date: Thu, 23 Dec 2021 22:38:44 +0200 Subject: [PATCH] xsession: add xplugd service to accompany setxkbmap (#2450) This fixes #1638; xplugd will restart setxkbmap if a new keyboard is plugged in to ensure it is also configured correctly. --- modules/xsession.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/xsession.nix b/modules/xsession.nix index 35e517a02..7ba9b54e9 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -126,6 +126,29 @@ in { in "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${toString args}"; }; }; + + xplugd = { + Unit = { + Description = "Rerun setxkbmap.service when I/O is changed"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { + Type = "forking"; + ExecStart = let + script = pkgs.writeShellScript "xplugrc" '' + case "$1,$3" in + keyboard,connected) + systemctl --user restart setxkbmap.service + ;; + esac + ''; + in "${pkgs.xplugd}/bin/xplugd ${script}"; + }; + }; }; targets = {