Tablet Hardware Buttons
Not all 2-in-1 convertibles feature the same amount of buttons, some even output different scancodes/keycodes as well due to their functions' being changed.
For the X41 Tablet, there are 8 buttons in total: the power button with a sliding lock, a Ctrl-Alt-Del shortcut button, a Screen Rotation button, a Tablet shortcut menu button, an Escape button, an Enter button, and the Page up and down buttons.
The X60 Tablet and the X61 Tablet were given a reduced set of buttons, likely for the purpose of cutting down on costs. So far, there are 5 buttons in total: the power button with a sliding lock, a Ctrl-Alt-Del shortcut button, the Escape button, and a circular directional pad.
The X200 Tablet, X201 Tablet, and the X201i Tablet had the same amount of buttons as the X60 Tablet and the X61 Tablet. However, the directional pad was removed in favor of a padlock button that seems to do nothing (doesn't generate a scancode and doesn't affect the other buttons' operations). Due to the directional pad's removal, the buttons were once again changed in functionality. While the power button and its sliding lock remained the same, the other buttons were not functionally identical. For example, the Ctrl-Alt-Del shortcut function was replaced with a 180-degree rotate function, and the Escape button's functionality was replaced with a portrait/landscape switch function. The last button that was modified was the Tablet shortcut menu button, which now launches the ThinkVantage toolbox as opposed to a special tablet menu.
The X220 Tablet, X220i Tablet, X230 Tablet, and the X230i Tablet were given a reduction in buttons again, possibly to reduce cost. It was worse than the previous generation's 5-button set, as they all had only 3 buttons: the power button with no sliding lock, a 180-degree rotate button, and the portrait/landscape switch button.
The hardware buttons (except power) are recognized by the standard atkbd kernel driver which emits the following scancodes:
|Key||X41 Tablet Scancode||X60 Tablet Scancode||X61 Tablet Scancode||X200 Tablet Scancode||X201 Tablet
X201i Tablet Scancode
X220i Tablet Scancode
X230i Tablet Scancode
|Ctrl-Alt-Del (Unlabeled)||0x67||NA||0x67||0xe0 0x12||0x67||NA||NA|
The utility setkeycodes can be used to map these scancodes to keycodes. Read
$ man setkeycodes for usage.
For example, the following command will map the page up and page down buttons to their respective keys:
# setkeycodes 6e 109 6d 104
Configuration with xbindkeys
The xbindkeys utility can be used to bind actions to the buttons once they have key codes (which they have by default in Debian). This example is for an X200 Tablet running Debian Wheezy, but should be applicable to other models and distributions. For support status, see the Tablet Screen Rotation Support page.
First create a default ~/.xbindkeysrc file with this command:
$ xbindkeys --defaults > ~/.xbindkeysrc
This file will contain the key bindings for each key, and the commands associated with them. More information on the file can be found on ArchWiki's Xbindkeys page.
Next, use the
$ xbindkeys -k command to generate the bindings to add to it. When the command is run, a window with a white background will appear. Select it and press the key you wish to bind. It will close and the binding will be printed to the terminal. For example (for the button):
"(Scheme function)" m:0x0 + c:161 NoSymbol
Copy and paste this into your ~/.xbindkeysrc file, replacing "(Scheme function)" with the command you wish to execute when the button is pressed.
A ~/.xbindkeysrc for an X200 Tablet might look like this:
# (Automatically generated documentation) # ... #Tablet Rotate button (run rotate script) "~/scripts/rotate.sh" # Replace the line above with the path to the script m:0x0 + c:161 NoSymbol #Tablet Toolbox button (show cellwriter) "cellwriter --show-window" m:0x0 + c:149 NoSymbol
This file binds the cellwriter input panel.button to a bash script that rotates the display (see below), and the button to the
The bindings will only work while
$ xbindkeys is running, however. Most desktop environments have a GUI to run commands at login. In Gnome 3, this is the Startup Applications app.
Screen rotation script
The example ~/.xbindkeysrc file above references a bash script that performs screen rotation. This is listed below:
#!/bin/bash tablet="Serial Wacom Tablet stylus" # Get the current orientation of the tablet rotate=$(xsetwacom get "$tablet" Rotate) # Work out the next tablet and screen orientations (rotating clockwise) case "$rotate" in none) nextRotate="cw" nextOrient="right" ;; cw) nextRotate="half" nextOrient="inverted" ;; half) nextRotate="ccw" nextOrient="left" ;; ccw) nextRotate="none" nextOrient="normal" ;; esac # Rotate the screen xrandr -o $nextOrient # Rotate the tablet xsetwacom set "$tablet" Rotate $nextRotate
Save this as a text file with the extension .sh somewhere on your system, mark it executable with
$ chmod +x <path to script>, and put the path in your ~/.xbindkeysrc, on the appropriate line.
You may have to replace "Serial Wacom Tablet stylus" with the name of your Wacom tablet. You can find this with the
$ xsetwacom list devices command.
For more information regarding these buttons, see the How to get special keys to work page.