- Note: this thing barely works -
Typically when trying to setup a keymap, mouse, or other xinput device, the command is not persistent at boot! Nor is it persistent when the device is temporarily disconnected. The solution is to either use a sleep function (which is annoying to the user, and wastes resources), or to monitor udev. Here I chose to monitor udev for all devices.
First, you need to know the last portion of each device’s name, a portion of the device path, and the name of the property you want to watch for. Find these out like this:
# Plugin the device
$ xinput
...
...DeathAdder Elite id=...
^^^^
Need the last portion of this name.# Unplug the device
$ udevadm monitor
...
# Now plug it in
UDEV [2607.521415] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.2/0003:1532:005C.003C/input/input137/input137::numlock (leds)
^^^^^^^^^^
Need a string from here, like 'usb'
# I used usb for my devices
Now that you have those, modify commands.conf from my personal choices:
monitor.pl -a 'add' -n 'device name #1' -d 'usb or other part of the path' -c1 'xinput ' <id inserted here> -c2 ' rest of command'
monitor.pl -a 'add' -n 'device name #2' -d 'usb or other part of the path' -c1 'no-id-required command'Perl will insert the ID of the xinput device if -c2 is specified, and it will be placed between the c1 and c2 commands. Commands that do not need the xinput id can omit -c2.
Finally, install it
~# cd ~/xinput-persistence
~/xinput-persistence# ./install.plYou can have as many devices as required, just add a new monitor.pl command to
the file. The program will fork each one. There is no need to reinstall when
adding new lines. Start with $ monitor.
Make sure to add /usr/bin/monitor to your startup scripts.