Automatically Map Wacom Devices to a Display

2 minute read

If you’re a GNU/Linux user who relies on Wacom tablets, you know how crucial it is to configure your devices correctly for optimal performance. If you often switch between display outputs, reconfiguring your Wacom devices can feel tedious. Fortunately, there’s a way to streamline this process with a simple command alias.

What Is This Command?

The command we’ll discuss allows you to quickly map your Wacom devices to a specific display output (like HDMI-1) with just a single command. Here’s the alias:

1alias wacom="declare WACOM_RESULT=($(xsetwacom list devices | cut -f2 | cut -d' ' -f2)); xsetwacom --set "'${WACOM_RESULT[0]}'" MapToOutput HDMI-1; xsetwacom --set "'${WACOM_RESULT[1]}'" MapToOutput HDMI-1;"

Breaking It Down

Let’s take a closer look at what this command does:

1. Creating an Array:

declare WACOM_RESULT=($(...)) creates an array called WACOM_RESULT that stores the names of your Wacom devices.

2. Listing Devices:

The command xsetwacom list devices retrieves a list of all connected Wacom devices. For example, running this command might yield:

1Wacom Cintiq 16 Pen stylus      	id: 9	type: STYLUS
2Wacom Cintiq 16 Pen eraser      	id: 17	type: ERASER

Note: The id of each device may change over time. By dynamically incorporating this into the alias, we ensure that it remains up-to-date without requiring manual maintenance.

3. Processing Output:

The output is piped through cut commands to extract just the relevant identifiers for your devices. In this case, it grabs the device names “Wacom Cintiq 16 Pen stylus” and “Wacom Cintiq 16 Pen eraser”.

4. Mapping to Output:

The final part of the command maps each Wacom device to the specified display output, HDMI-1 in this case.

To check which monitors are available and what they are labelled, run:

1xrandr --listactivemonitors

Why Use This Alias?

  • Efficiency: Instead of manually configuring your devices every time, you can simply type wacom in your terminal.
  • Flexibility: If you ever need to change the display output, you can easily modify the alias to fit your needs.

How to Set It Up

  1. Open Your Terminal.
  2. Edit Your Shell Configuration: Depending on your shell, you’ll need to add this alias to your .bashrc, .bash_profile, or .zshrc file.
  3. Reload Your Shell: After saving the changes, run source ~/.bashrc (or the equivalent for your shell) to apply the changes.
  4. Use the Alias: Now, whenever you need to map your Wacom devices, just type wacom!

Conclusion

This simple command alias can save you time and hassle in your daily workflow - especially if your monitor configuration changes through the day - allowing you to focus on more important tasks.