From a92bf7ec6cb2342a4ff290d72fed6611abf11420 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Tue, 29 Nov 2016 00:31:53 -0500 Subject: [PATCH] Add example systemd jobs --- misc/dvorak.service | 9 +++++++++ misc/dvorak_systemd.sh | 12 ++++++++++++ misc/kbwait.service | 9 +++++++++ misc/kbwait_systemd.sh | 16 ++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 misc/dvorak.service create mode 100755 misc/dvorak_systemd.sh create mode 100644 misc/kbwait.service create mode 100755 misc/kbwait_systemd.sh diff --git a/misc/dvorak.service b/misc/dvorak.service new file mode 100644 index 0000000..90756d0 --- /dev/null +++ b/misc/dvorak.service @@ -0,0 +1,9 @@ +[Unit] +Description=Dvorak Daemon + +[Service] +ExecStart=/root/dvorak_systemd.sh +StartLimitInterval=0 + +[Install] +WantedBy=default.target diff --git a/misc/dvorak_systemd.sh b/misc/dvorak_systemd.sh new file mode 100755 index 0000000..87ac8c2 --- /dev/null +++ b/misc/dvorak_systemd.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +kbs='' +for input in $(ls /dev/input/event*) +do + if udevadm info -q property $input | grep ID_INPUT_KEYBOARD + then + udevadm info -a $input | grep 'keymapper input device' || kbs="$kbs $input" + fi +done + +exec /usr/bin/env python2 /usr/lib/uinput-mapper/input-read -d -k /etc/uinput-mapper/keymap.py $kbs diff --git a/misc/kbwait.service b/misc/kbwait.service new file mode 100644 index 0000000..5cbed34 --- /dev/null +++ b/misc/kbwait.service @@ -0,0 +1,9 @@ +[Unit] +Description=kbwait Dvorak Daemon +After=dvorak.service + +[Service] +ExecStart=/root/kbwait_systemd.sh + +[Install] +WantedBy=default.target diff --git a/misc/kbwait_systemd.sh b/misc/kbwait_systemd.sh new file mode 100755 index 0000000..34bcec4 --- /dev/null +++ b/misc/kbwait_systemd.sh @@ -0,0 +1,16 @@ +#!/bin/bash +inotifywait -m -q -e create -e delete --include '.*event[0-9]+' --format '%e-%w%f' /dev/input/ | while read event +do + +# CREATE-/dev/input/event16 +if echo "$event" | grep '^CREATE-' +then + input="$(echo "$event" | sed 's/^CREATE-//')" + # if it's us, ignore + udevadm info -a "$input" | grep 'keymapper input device' && continue + # if it's not a keyboard, ignore + udevadm info -q property "$input" | grep ID_INPUT_KEYBOARD || continue +fi + +systemctl restart dvorak +done