None of the answers here worked for me, and the options I wanted to set could not be specified in xorg.conf
:
$ xsetwacom -x get 'Wacom Intuos PT S Pad pad' button 1
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
I ended up having to start the script with a systemd service triggered by a udev rule:
$ cat /etc/udev/rules.d/99-wacom.rules
SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="056a", ENV{ID_MODEL_ID}=="0302", TAG+="systemd"
Vendor and model id can be found running lsusb
with the device plugged in.
To reload udev rules:
$ udevadm control --reload-rules
$ udevadm trigger
The TAG+="systemd"
enables other systemd services (system or user) to depend on the device (registers it as a device unit, see man systemd.device
). To find the name of the device unit run udevadm monitor
and plug in the tablet. I get
UDEV [2918.098423] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3 (usb)
...
To check that systemd is picking it up do
$ systemctl status /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/
● sys-devices-pci0000:00-0000:00:1d.0-usb2-2\x2d1-2\x2d1.3.device - CTH-480 [Intuos Pen & Touch (S)]
Loaded: loaded
Active: active (plugged) since Mon 2016-06-20 11:14:20 UYT; 29min ago
Device: /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3
So the device unit is sys-devices-pci0000:00-0000:00:1d.0-usb2-2\x2d1-2\x2d1.3.device
, and it can be used in the systemd service unit
$ cat .config/systemd/user/wacom.service
[Service]
Type=forking
Restart=no
ExecStart=/path/to/wacom-pad-button-setup
[Install]
WantedBy=default.target
WantedBy=sys-devices-pci0000:00-0000:00:1d.0-usb2-2\x2d1-2\x2d1.1.device
WantedBy=sys-devices-pci0000:00-0000:00:1d.0-usb2-2\x2d1-2\x2d1.2.device
WantedBy=sys-devices-pci0000:00-0000:00:1d.0-usb2-2\x2d1-2\x2d1.3.device
There is one device unit per usb port.
Then enable and reload the unit with systemctl --user enable wacom.service
and systemctl --user daemon-reload
.
The script still needs to sleep a bit for xsetwacom to find the device, and to set $DISPLAY
and $XAUTHORITY
. Type=oneshot
works fine when plugging it in, but it doesn't run it if the device was already plugged in when booting the computer. That is why I needed to use a user service instead of a system one, and why the unit also has WantedBy=default.target
. The problem with oneshot is that it was blocking startx. Type=forking
and Restart=no
tells systemd not to wait for the script's forked process to exit, so the script can then sleep in the background waiting for Xorg to start.
$ cat bin/wacom-pad-button-setup
#!/bin/rc
{
sleep 2
if (~ $DISPLAY ()) {
DISPLAY=:0
XAUTHORITY=/home/spelufo/.Xauthority
}
xsetwacom set 'Wacom Intuos PT S Pad pad' button 9 'button +3 -3'
xsetwacom set 'Wacom Intuos PT S Pad pad' button 8 'button +4 -4'
xsetwacom set 'Wacom Intuos PT S Pad pad' button 3 'button +1 -1'
xsetwacom set 'Wacom Intuos PT S Pad pad' button 1 'button +2 -2'
} &
\x
to\\x
in the service file. My WantedBy's looked like this in the end:WantedBy=sys-devices-pci0000\:00-0000\:00\:14.0-usb1-1\\x2d4.device
and now they are triggered... before they didnt. – Jan Jan 13 '17 at 09:07