Wacom tablets on Linux

I have a Wacom Bamboo graphics tablet that I use fairly infrequently. Today, however, I wanted to use it for a small demonstration. The problem was that the official support for Linux is considerably lacking. The tablet does work with the X.org Wacom driver (xf86-input-wacom in pacman), but it doesn’t play well with multiple screens.

A diagram showing the mapping of the graphics tablet surface to both screens at once.
A demonstration of the bad aspect ratio resulting from this.

Luckily, a tool exists, named xsetwacom, to configure the device to your own display. For example, this following command maps the device to a single region:

xsetwacom --set "Wacom Bamboo stylus" MapToOutput "1920x1080+1920+120"

This, however, leads to another problem - what if the screen and the device surface don’t have the same aspect ratio, either? The command above is a direct corner-to-corner mapping.

A diagram showing the mapping of the graphics tablet surface to a single screen, with the wrong aspect ratio.
A demonstration of the aspect ratio resulting from this correction; it's better than before, but still off.

Luckily, someone has written a bash script to fix this. It essentially letter-boxes the tablet surface to match the aspect ratio of the display you choose. The script requires some manual set-up, however, which I wasn’t fond of - if your tablet has multiple inputs, such as a separate stylus and eraser, you will have to edit and set-up the script twice to configure both.

I decided to exercise my non-existent bash skills to fix this. I’ve fixed the script to work with non-VGA outputs, and also make it take the device as an argument. The new script is available on Gist. To work with it, just run mapwacom --help. This will list the available options, including ones to print the names of all available screens and Wacom devices. Unfortunately I'm too lazy to add valid error handling, so you'd better enter the screen and device names perfectly, or the script fails catastrophically. (I’ve since re-written the script almost from scratch to support better interaction.)

A diagram showing the mapping from graphics tablet surface to one screen, with the correct aspect ratio.
A demonstration of the correct aspect ratio resulting from this correction. The demonstration is the text "Hello world!" in my hand-writing..

Feel free to use the script. It might be useful to put it into your .xinitrc, so it runs whenever X does. You might need to re-run the script if you re-connect the graphics tablet, but this shouldn’t be too much of an issue.