udev: Add usb_xprofile script and rule
authorStefan Huber <shuber@sthu.org>
Wed, 5 Feb 2014 10:11:38 +0000 (11:11 +0100)
committerStefan Huber <shuber@sthu.org>
Wed, 5 Feb 2014 10:11:38 +0000 (11:11 +0100)
udev/rules.d/99-keyboards.rules [new file with mode: 0644]
udev/scripts/usb_xprofile.sh [new file with mode: 0755]

diff --git a/udev/rules.d/99-keyboards.rules b/udev/rules.d/99-keyboards.rules
new file mode 100644 (file)
index 0000000..cda6fc3
--- /dev/null
@@ -0,0 +1 @@
+ACTION=="add", ENV{ID_INPUT_KEYBOARD}=="1", RUN+="/etc/udev/scripts/usb_xprofile.sh /dev/$name"
diff --git a/udev/scripts/usb_xprofile.sh b/udev/scripts/usb_xprofile.sh
new file mode 100755 (executable)
index 0000000..fc599e5
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. /usr/local/bin/getXenv.inc
+getXconsole
+
+if [ -n "$XUSER" ]; then
+       USER_HOME=$(getent passwd $XUSER | cut -d: -f6)
+       FN="$USER_HOME/.usb_xprofile"
+       if [ -f "$FN" ]; then
+               (
+                       # Give X time to hear about the new keyboard
+                       sleep 0.5
+                       su $XUSER -c "/bin/sh \"$FN\""
+               ) &
+       fi
+fi