How I set up my drawing tablet on Sway 2021-06-21 on Kenneth Dodrill's blog

Update: originally this guide was using swaymsg directly to set things up in my Sway config. You can easily set up inputs directly in the config - there is a section for it. My mistake on that.

I recently switched from GNOME to Sway. It has been a big change, but it's something I've wanted to do for awhile now. Sway uses Wayland, which means xsetwacom is not something you can use. xsetwacom is the typical command line tool to set up input devices in Xorg, including drawing tablets. In Wayland, we have libinput, "a library that provides a full input stack for display servers...". Because Sway is using libinput, we can easily use swaymsg to set things up.

To get some info on your devices using libinput, you can run these commands:

libinput list-devices

Using this command, you'll see all the input devices that libinput can interact with. Keep in mind that not all input devices are supported, especially in the case of drawing tablets. I have a Huion tablet and everything works except for the buttons on the pad (I think I remember reading that this is a bug in either Sway or libinput).

libinput debug-tablet

With this one, we can see how the pad responds to pressure when drawing. It's not required, I just thought it was neat.

So how do we change things? Using swaymsg. To start, let's map the tablet pen to one monitor.

swaymsg input type:tablet_tool map_to_output <monitor>

Here we use swaymsg to tell sway-input that for any input of type tablet_tool (the pen in our case), map it to output <monitor>.

If we run man sway-input, we can see that this is a valid setting.

Likewise, we can use man sway-input to set anything else we need. I'm left-handed, so I enable that.

swaymsg input type:tablet_tool left_handed enabled

Now I can flip my tablet and draw more comfortably.

To make these settings persistent, put them in your Sway config file, near where the input section is (there should be an example).

input type:tablet_tool {
      map_to_output <monitor>
      left_handed enabled