Recently Written · git

xinput-persistence

xinput for mouse or keyboard configurations that work when disconnected or on boot.

git clone https://github.com/equwal/xinput-persistence

Log | Files | Refs


README.org (1998 bytes)

1 - Note: this thing barely works -
2 * xinput persistence for all devices
3 Typically when trying to setup a keymap, mouse, or other xinput device, the
4 command is not persistent at boot! Nor is it persistent when the device is
5 temporarily disconnected. The solution is to either use a sleep function (which
6 is annoying to the user, and wastes resources), or to monitor udev. Here I chose
7 to monitor udev for all devices.
8 
9 * Installation
10 
11 First, you need to know the last portion of each device's name, a portion of the
12 device path, and the name of the property you want to watch for. Find these out
13 like this:
14 #+BEGIN_SRC sh
15 # Plugin the device
16 $ xinput
17 ...
18 ...DeathAdder Elite id=...
19               ^^^^
20              Need the last portion of this name.
21 #+END_SRC
22 
23 #+BEGIN_SRC sh
24 # Unplug the device
25 $ udevadm monitor
26 ...
27 
28 # Now plug it in
29 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)
30                                ^^^^^^^^^^
31                               Need a string from here, like 'usb'
32 # I used usb for my devices
33 
34 #+END_SRC
35 
36 Now that you have those, modify commands.conf from my personal choices:
37 
38 #+BEGIN_SRC sh
39 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'
40 monitor.pl -a 'add' -n 'device name #2' -d 'usb or other part of the path' -c1 'no-id-required command'
41 #+END_SRC
42 
43 Perl will insert the ID of the xinput device if -c2 is specified, and it will be
44 placed between the c1 and c2 commands. Commands that do not need the xinput id
45 can omit -c2.
46 
47 Finally, install it
48 #+BEGIN_SRC sh
49 ~# cd ~/xinput-persistence
50 ~/xinput-persistence# ./install.pl
51 #+END_SRC
52 You can have as many devices as required, just add a new monitor.pl command to
53 the file.  The program will fork each one. There is no need to reinstall when
54 adding new lines. Start with =$ monitor=.
55 
56 Make sure to add =/usr/bin/monitor= to your startup scripts.