Add example systemd jobs

This commit is contained in:
Travis Burtrum 2016-11-29 00:31:53 -05:00
parent 1dcc695e63
commit a92bf7ec6c
4 changed files with 46 additions and 0 deletions

9
misc/dvorak.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=Dvorak Daemon
[Service]
ExecStart=/root/dvorak_systemd.sh
StartLimitInterval=0
[Install]
WantedBy=default.target

12
misc/dvorak_systemd.sh Executable file
View File

@ -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

9
misc/kbwait.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=kbwait Dvorak Daemon
After=dvorak.service
[Service]
ExecStart=/root/kbwait_systemd.sh
[Install]
WantedBy=default.target

16
misc/kbwait_systemd.sh Executable file
View File

@ -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