From: Stefan Huber Date: Wed, 5 Feb 2014 10:11:38 +0000 (+0100) Subject: udev: Add usb_xprofile script and rule X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=5ee2e40e8c04dd179fd6c5dfcc5f5e15c6d01843;p=shutils.git udev: Add usb_xprofile script and rule --- diff --git a/udev/rules.d/99-keyboards.rules b/udev/rules.d/99-keyboards.rules new file mode 100644 index 0000000..cda6fc3 --- /dev/null +++ b/udev/rules.d/99-keyboards.rules @@ -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 index 0000000..fc599e5 --- /dev/null +++ b/udev/scripts/usb_xprofile.sh @@ -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