Wacom is a company which produces high quality pen tablets and touchscreens. The tablets are a number one choice for Linux users since they are well supported. The Linux Wacom project provides an high quality driver and  the userland tool

xsetwacom
xsetwacom to change the settings of the tablet such as button keys or pressure sensitivity.

After reading some reviews, I decided to buy an Intuos4 M tablet for image manipulation with the GIMP. One of the reasons to choose this tablet was that it has eight buttons to which arbitrary key strokes are assignable. Each button has a little LED display besides it, which can be used to display the button assignment as a text or an icon.

After connecting the tablet to my computer (running Debian), I was able to configure the buttons with

xsetwacom
xsetwacom. However, there was no possibility to set the LED displays. The consultation of the xsetwacom documentation was fruitless. So I searched the developer’s mailing list and found a post which contained a piece of code to access the LED displays. Unfortunately, the code did not work for me, but it provided some useful information on accessing the tablet. The self-imposed challenge was to develop a little C++ application to set to LED displays.

The main features of the application are:

  • The application uses libusb to communicate with the tablet.
  • Images are converted to an appropriate format using the Magick library. This is, you can download a png/jpg image directly to the tablet, if the image has the appropriate size.
  • The application contains an icon library. These icons can be used directly for configuration the tablet display. A bunch of common icons are included in order to use without generating appropriate images.

The remaining part of this post is a little howto covering the setup and usage of the application.

Building the application from source

  1. In order to compile the source code, the development packages of libusb and Magick++ libraries must be present on the system. Furthermore,  g++ and make.are mandatory. Under Debian Squeeze, the respective packages can be installed with the following command:
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    sudo apt-get install g++ make libusb-1.0-0-dev libmagick++-dev<div class="fusion-fullwidth fullwidth-box fusion-builder-row-1 hundred-percent-fullwidth non-hundred-percent-height-scrolling" style="--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-overflow:visible;--awb-flex-wrap:wrap;"><div class="fusion-builder-row fusion-row"><div class="fusion-layout-column fusion_builder_column fusion-builder-column-0 fusion_builder_column_1_1 1_1 fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height" style="--awb-bg-size:cover;--awb-margin-bottom:0px;"><div class="fusion-column-wrapper fusion-flex-column-wrapper-legacy">[</div></div></div></div>
    sudo apt-get install g++ make libusb-1.0-0-dev libmagick++-dev<div class="fusion-fullwidth fullwidth-box fusion-builder-row-1 hundred-percent-fullwidth non-hundred-percent-height-scrolling" style="--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-overflow:visible;--awb-flex-wrap:wrap;"><div class="fusion-builder-row fusion-row"><div class="fusion-layout-column fusion_builder_column fusion-builder-column-0 fusion_builder_column_1_1 1_1 fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height" style="--awb-bg-size:cover;--awb-margin-bottom:0px;"><div class="fusion-column-wrapper fusion-flex-column-wrapper-legacy">[</div></div></div></div>
    sudo apt-get install g++ make libusb-1.0-0-dev libmagick++-dev
    [
  2. Download the source code, open a terminal window and extract the archive with the following command:.
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    tar xzf wacom-intuos4-led.tar.gz
    tar xzf wacom-intuos4-led.tar.gz
    tar xzf wacom-intuos4-led.tar.gz
  3. Change into the
    Intuos4-LED/src
    Intuos4-LED/src folder:
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    cd Intuos4-LED/src
    cd Intuos4-LED/src
    cd Intuos4-LED/src
  4. Invoke make to start the compilation:[cc lang=”text”]make[/cc] If the compilation is successful, then the folder contains two executables named
    intuos4-led-check
    intuos4-led-check and
    intuos4-led-config
    intuos4-led-config. The first one can be used to check whether the tablet works, The second one is the application to configure the tablet’s LED displays.

Test whether the tablet works

Execute the following command and watch the LED displays of the tablet:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo ./intuos4-led-check
sudo ./intuos4-led-check
sudo ./intuos4-led-check

The LED displays should pass a little sequence of images and end up with a  button labelling from “Button 1” to “Button 8”.

Setting the LEDs of the tablet

Note: The application cannot communicate with the tablet via the generic USB interface if the wacom driver module is loaded into the kernel. Hence, the module must be unloaded before setting the LEDs and reloaded afterwards. Concretely, the setup passes the following steps:

  1. Unload the wacom module:
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    sudo rmmod wacom
    sudo rmmod wacom
    sudo rmmod wacom
  2. Configure the LEDs with 
    intuos4-led-config
    intuos4-led-config
  3. Reload the wacom module:
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    sudo modprobe wacom
    sudo modprobe wacom
    sudo modprobe wacom
  4. Configure the tablet with 
    xsetwacom
    xsetwacom

There are two ways to assign an image to an particular LED:

  • Use a predefined image icon
  • Use a png/jpg image with a size of 64 × 32 pixels

To determine the names of the predefined icons, execute

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
./intuos4-led-config --list
./intuos4-led-config --list
./intuos4-led-config --list

To assign the icon “Tux” to the display besides button 2, execute

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo ./intuos4-led-config --icon Tux --button 2
sudo ./intuos4-led-config --icon Tux --button 2
sudo ./intuos4-led-config --icon Tux --button 2

Per default, the setup is done for a right-handed tablet orientation, i.e. with the buttons located on the left side. The perform a left-handed setup (buttons on the right side), the

--lefthanded
--lefthanded switch can be used.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo ./intuos4-led-config --lefthanded--icon Tux --button 2
sudo ./intuos4-led-config --lefthanded--icon Tux --button 2
sudo ./intuos4-led-config --lefthanded--icon Tux --button 2

The image

icon-debian.png
icon-debian.png is assigned to the display of button 3 with the following command:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo ./intuos4-led-config --image icon-debian.png --button 3
sudo ./intuos4-led-config --image icon-debian.png --button 3
sudo ./intuos4-led-config --image icon-debian.png --button 3

The folder icons contains example images including the image 

icon-debian.png
icon-debian.png.

Generation of text icons

Using ImageMagick it is quite simple to create new text icons using the script

text-icon.sh
text-icon.sh:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#! /bin/bash
TEXTFONT=/usr/share/fonts/truetype/msttcorefonts/Arial.ttf
convert -background black -fill white -size 64x32 -pointsize 14
-gravity center -font $TEXTFONT
label:"$1" icon-$2.png
#! /bin/bash TEXTFONT=/usr/share/fonts/truetype/msttcorefonts/Arial.ttf convert -background black -fill white -size 64x32 -pointsize 14 -gravity center -font $TEXTFONT label:"$1" icon-$2.png
#! /bin/bash

TEXTFONT=/usr/share/fonts/truetype/msttcorefonts/Arial.ttf

convert -background black -fill white -size 64x32 -pointsize 14
-gravity center  -font $TEXTFONT
label:"$1" icon-$2.png

The script is located in the icons folder of the source distribution. In order to work, the MSTTCorefonts package must be installed. By calling

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
./text-icon.sh Copy copy
./text-icon.sh Copy copy
./text-icon.sh Copy copy

the icon

icon-copy.png
icon-copy.png with the text “Copy” is generated. The result is a png image of size 64×32 pixels:

Instead of Arial, you can use any (installed) truetype font by altering the

TEXTFONT
TEXTFONT variable in the above script.

A shell script for automated tablet configuration

The following script is an example for the automated setup of the tablet. Feel free to adapt for your needs.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#! /bin/bash
# Device name of the tablet retrieved from xsetwacom
DEVICE="Wacom Intuos4 6x9 pad"
# Path to the tablet config application
LEDCMD=./intuos4-led-config
sudo modprobe -r wacom
sudo $LEDCMD --button 1 --icon Undo
sudo $LEDCMD --button 2 --icon Redo
sudo $LEDCMD --button 3 --icon ZoomIn
sudo $LEDCMD --button 4 --icon ZoomOut
sudo $LEDCMD --button 5 --icon Save
sudo $LEDCMD --button 6 --icon Alt
sudo $LEDCMD --button 7 --icon Ctrl
sudo $LEDCMD --button 8 --icon ArrowUp
sudo modprobe wacom
sleep 1
xsetwacom --set "$DEVICE" Button 2 "key ctrl y"
xsetwacom --set "$DEVICE" Button 3 "key ctrl z"
xsetwacom --set "$DEVICE" Button 8 "key plus"
xsetwacom --set "$DEVICE" Button 9 "key minus"
xsetwacom --set "$DEVICE" Button 10 "key ctrl s"
xsetwacom --set "$DEVICE" Button 11 "key alt"
xsetwacom --set "$DEVICE" Button 12 "key ctrl"
xsetwacom --set "$DEVICE" Button 13 "key shift"
#! /bin/bash # Device name of the tablet retrieved from xsetwacom DEVICE="Wacom Intuos4 6x9 pad" # Path to the tablet config application LEDCMD=./intuos4-led-config sudo modprobe -r wacom sudo $LEDCMD --button 1 --icon Undo sudo $LEDCMD --button 2 --icon Redo sudo $LEDCMD --button 3 --icon ZoomIn sudo $LEDCMD --button 4 --icon ZoomOut sudo $LEDCMD --button 5 --icon Save sudo $LEDCMD --button 6 --icon Alt sudo $LEDCMD --button 7 --icon Ctrl sudo $LEDCMD --button 8 --icon ArrowUp sudo modprobe wacom sleep 1 xsetwacom --set "$DEVICE" Button 2 "key ctrl y" xsetwacom --set "$DEVICE" Button 3 "key ctrl z" xsetwacom --set "$DEVICE" Button 8 "key plus" xsetwacom --set "$DEVICE" Button 9 "key minus" xsetwacom --set "$DEVICE" Button 10 "key ctrl s" xsetwacom --set "$DEVICE" Button 11 "key alt" xsetwacom --set "$DEVICE" Button 12 "key ctrl" xsetwacom --set "$DEVICE" Button 13 "key shift"
#! /bin/bash

# Device name of the tablet retrieved from xsetwacom
DEVICE="Wacom Intuos4 6x9 pad"
# Path to the tablet config application
LEDCMD=./intuos4-led-config

sudo modprobe -r wacom
sudo $LEDCMD --button 1 --icon Undo
sudo $LEDCMD --button 2 --icon Redo
sudo $LEDCMD --button 3 --icon ZoomIn
sudo $LEDCMD --button 4 --icon ZoomOut
sudo $LEDCMD --button 5 --icon Save
sudo $LEDCMD --button 6 --icon Alt
sudo $LEDCMD --button 7 --icon Ctrl
sudo $LEDCMD --button 8 --icon ArrowUp
sudo modprobe wacom

sleep 1

xsetwacom --set "$DEVICE" Button 2 "key ctrl y"
xsetwacom --set "$DEVICE" Button 3 "key ctrl z"
xsetwacom --set "$DEVICE" Button 8 "key plus"
xsetwacom --set "$DEVICE" Button 9 "key minus"
xsetwacom --set "$DEVICE" Button 10  "key ctrl s"
xsetwacom --set "$DEVICE" Button 11 "key alt"
xsetwacom --set "$DEVICE" Button 12 "key ctrl"
xsetwacom --set "$DEVICE" Button 13 "key shift"

Note: The script was tested with

xsetwacom
xsetwacom version 0.11.0. If you use a different version, please check the xsetwacom man page for the correct syntax.