Monday, February 29, 2016

"Unbreak" Wacom Intuos CTL-480 on Linux Mint 17.3

With the 17.3 update of Linux Mint, the GUI that allow to set parameters for the Wacom CTL-480 broke (it doesn't recognize it anymore), but the CLI "xsetwacom" still works fine.
In my previous article i already had pointed that the GUI wasn't perfect, now it's worse ...
The only thing i need (for now) is to switch between Absolute and Relative modes for the stylus. So this will be the only thing i'll cover here (for now).
Let's workaround with a shell script that auto-switches between modes at each launch.

Xsetwacom commands
How to... by hand?

To display wacom devices attached there is the following piece of code:
xsetwacom --list devices

On my side, this outputs the following:
Wacom Intuos S Pen stylus        id: 14 type: STYLUS    
Wacom Intuos S Pen eraser        id: 15 type: ERASER    
Wacom Intuos S Pad pad           id: 16 type: PAD

To get the mode for the stylus:
xsetwacom get "Wacom Intuos S Pen stylus" mode

To set Relative mode for the stylus:
xsetwacom set "Wacom Intuos S Pen stylus" mode relative

The script
The power of sed
As the output of "xsetwacom --list devices" is longer than the string needed for the set command, let's trim it with sed: (the following command allows variation in the device name, as when the tablet is connected with the wireless module it has "(WL)" in its name.
Note that the gap after the used name is variable (it is made of zero or more space(s) and one indentation, the sed command takes care of that)

Then the script will check for the mode and switch between both!

To launch the script, refer to my old post about m505 remapping script.
The potential updates to this script will be available on my github.