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