summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2015-07-31 13:19:34 +0200
committerJan Pokorný <jpokorny@redhat.com>2015-07-31 13:19:34 +0200
commit67f5e4154d6b4f7ee54a64662d6824600f1d1b59 (patch)
treeb0b5f97847a52922f944a732c576fe2e82b1081e
downloaduudev-67f5e4154d6b4f7ee54a64662d6824600f1d1b59.tar.gz
uudev-67f5e4154d6b4f7ee54a64662d6824600f1d1b59.tar.xz
uudev-67f5e4154d6b4f7ee54a64662d6824600f1d1b59.zip
Initial version
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--README1
-rwxr-xr-xuudev.sh95
2 files changed, 96 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..0491e77
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+Please see <https://bugzilla.redhat.com/show_bug.cgi?id=1248074#c3>.
diff --git a/uudev.sh b/uudev.sh
new file mode 100755
index 0000000..882adde
--- /dev/null
+++ b/uudev.sh
@@ -0,0 +1,95 @@
+#/bin/bash
+
+# uudev.sh
+# Stupid configure-by-modification udev rule engine for ordinary users as udev
+# is not and will not be user-friendly even though there is hardly any
+# conceptual obstacle: <https://bugzilla.redhat.com/show_bug.cgi?id=1248074>.
+#
+# Search for "CUSTOM SECTION" as a modification start point.
+# You may also need to tweak udevadm monitor invocation at the bottom.
+#
+# Copyright 2015 jpokorny@fedoraproject.org
+# Distributed under terms of GPLv2 license
+
+exec <&-
+set -eu
+
+declare holdtime=10
+
+main() {
+ local line
+ declare ACTION=
+ declare BUSNUM=
+ declare DEVNAME=
+ declare DEVNUM=
+ declare DEVPATH=
+ declare DEVTYPE=
+ declare INTERFACE=
+ declare MAJOR=
+ declare MINOR=
+ declare MODALIAS=
+ declare PRODUCT=
+ declare SEQNUM=
+ declare SUBSYSTEM=
+ declare TYPE=
+
+ while read line; do
+ #echo "LINE: ${line}"
+ case "${line}" in
+ # important lines
+ ACTION=*) ;&
+ BUSNUM=*) ;&
+ DEVNAME=*) ;&
+ DEVNUM=*) ;&
+ DEVPATH=*) ;&
+ DEVTYPE=*) ;&
+ INTERFACE=*) ;&
+ MAJOR=*) ;&
+ MINOR=*) ;&
+ MODALIAS=*) ;&
+ PRODUCT=*) ;&
+ SEQNUM=*) ;&
+ SUBSYSTEM=*) ;&
+ TYPE=*) ;&
+ __MARK__=__SENTINEL__)
+ #echo "local ${line}"
+ declare ${line}
+ ;;
+ # skip lines
+ KERNEL*) ;&
+ *monitor\ will\ print\ the\ received\ events\ for*)
+ ;;
+ *)
+ # for some reason a backspace is present in the "empty line"
+ # denoting end of event block
+ python -c "from sys import exit; exit ([ord(c) for c in r'''${line}'''] == [10])" \
+ && { systemd-cat -t uudev <<< "unrecognized ${line}"; continue; } \
+ || :
+ declare script=
+ case "${PRODUCT}" in
+ "")
+ ;;
+# CUSTOM SECTION BEGIN
+ 58f/9410/122*)
+ script="${HOME}/.udev/keyboard"
+ ;;
+# CUSTOM SECTION END
+ *)
+ systemd-cat -t uudev <<< "unhandled PRODUCT: ${PRODUCT}"
+ ;;
+ esac
+ test -z "${script}" && continue || :
+ test -x "${script}" || { systemd-cat -t uudev <<< "access error: ${script}"
+ continue; }
+ test "$(($(stat -c %X -- "${script}") + holdtime))" -lt "$(date +%s)" \
+ || { systemd-cat -t uudev <<< "skipping possibly repeated action: ${script}:${ACTION}"
+ continue; }
+ systemd-cat -t uudev <<< "executing: ${script} ${ACTION}"
+ touch -a "${script}"
+ ${script} ${ACTION} || systemd-cat -t uudev <<< "error executing: ${script} ${ACTION}"
+ ;;
+ esac
+ done < <(script -q -c 'udevadm monitor -s usb/usb_interface -kp')
+}
+
+main