technonaturalist

image link to hive image link to ko-fi

Wacom Cintiq Companion Hybrid/13HD and associated app settings on Ubuntu Studio 16.04LTS

posted on: Sunday, 5 June 2016 @ 3:15pm in
tagged

Downloading all the things

Add the repository for Gnome Pie Menu:

sudo add-apt-repository ppa:simonschneegans/testing 
sudo apt-get update

Download helper utilities:

sudo apt-get install easystroke wmctrl xdotool gnome-pie

Download apps:

3d Coat is a proprietary product. Ubuntu Studio ships with a version of Blender and Krita but they lag at least a version behind. The shipped versions may well do the job (and be easier to upgrade) unless you specifically need something in a newer version or just like being on the latest version of everything. I stashed all of these in /usr/local as that’s on its own partition on the ssd. My home directory is on a 2Tb not-ssd. I don’t know if that’s “right and proper” for Linux but everything works, I know where it is and it theoretically shouldn’t get hosed if Ubuntu explodes and requires a complete reinstall so I don’t care.

There are instructions with installing Krita that specifically say to uninstall the previous version. Blender versions are standalone and you can have a few of them kicking around and use whichever one of them you like. However if you use the commandline or the alt+space thing to run the app, the packaged Blender will always be the one that runs. To preference the downloaded/newer one add it to the path in ~/.profiles so it looks like:

PATH="/usr/local/blender:/usr/local:$PATH"

Krita and 3dCoat will need .desktop files created for them so that they show up in the alt+space thing. The reference page I used says they can go in /usr/share/applications for multiple users or ~/.local/share/applications for a single user. I went with the latter partly because I’m the only user on my system and mostly so I wouldn’t have to sudo anything (by this stage it was an extra step I didn’t care about no matter how easy it is).

3dcoat.desktop

[Desktop Entry] 
Name=3d-coat 
Exec=/usr/local/3D-CoatV4-5/3d-coat-64 
Icon=/usr/local/3D-CoatV4-5/Icon/3D-Coat.png 
Type=Application 
Categories=Graphics;3DGraphics;

krita.desktop

[Desktop Entry] 
Name=Krita 
Exec=/usr/local/krita-3.0-x86_64.appimage 
Icon=krita 
Type=Application 
Categories=Graphics;2DGraphics;

Basic tablet setup

I have no idea where things “should” go as far as Linux is concerned. I dropped all the scripts in /usr/local/bin. For all the scripts remember to either sudo chmod a+x [filename] or right click -> properties -> make executable them.

wacom-settings.sh

#!/bin/bash 

# switch right and middle click 
xsetwacom set "Wacom ISDv5 307 Pen stylus" Button 2 3 
xsetwacom set "Wacom ISDv5 307 Pen stylus" Button 3 2 

# nib touch for right and middle click 
xsetwacom set "Wacom ISDv5 307 Pen stylus" TabletPCButton on 

# global undo, redo and modifier keys 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 2 "key +ctrl +z" 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 3 "key +shift +ctrl +z" 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 12 "key +alt" 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 11 "key +shift" 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 10 "key +ctrl" 

# screen toggle when not wanting to move ancillary hand 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 13 "key +super +z"

switcheroo.sh

#!/bin/bash 

# screen switchy 
# 
# HEAD-0 is primary display 
# HEAD-1 is the Cintiq/secondary display 
# 
# nVidia card, may be different for AMD 

if grep -q 0 ~/.wacom-mapping; 
  then xsetwacom set "Wacom ISDv5 307 Pen stylus" MapToOutput HEAD-1 
  xsetwacom set "Wacom ISDv5 307 Pen eraser" MapToOutput HEAD-1 
  xsetwacom set "Wacom ISDv5 309 Finger touch" MapToOutput HEAD-1 
  echo "1" > ~/.wacom-mapping 
else 
  xsetwacom set "Wacom ISDv5 307 Pen stylus" MapToOutput HEAD-0 
  xsetwacom set "Wacom ISDv5 307 Pen eraser" MapToOutput HEAD-0 
  echo "0" > ~/.wacom-mapping 
fi

The switcheroo script is based on a script I was using before that I had to modify as this time round it didn’t want to work for me for whatever reason.

App-specific tablet setup

Assign the keys in a bash script as above. I’ll probably be continually tweaking these til I’m done (and then I’ll remove this statement XD), they’re here as examples as currently I want the doc up so I don’t lose it).

3dc-wacom-settings.sh

#!/bin/bash 

xsetwacom set "Wacom ISDv5 307 Pad pad" Button 8 "key +w" #wireframe mode

blender-wacom-settings.sh

#!/bin/bash 

# pie menu 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 1 "key +super +b"

krita-wacom-settings.sh

#!/bin/bash 

# pie menu 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 1 "key +super +k" 

# brush size 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 8 "key ]" # bigger brush 
xsetwacom set "Wacom ISDv5 307 Pad pad" Button 9 "key [" # smaller brush

App switching

I know I could “just alt-tab” but seeing as I can draw my way around I may as well use that if the pen happens to be in my hand. So I want to be able to switch to already open instances by drawing instead of spawning new ones (and if I want to spawn a new one that can be done in the usual fashion). The astute reader will have probably noticed that the commands to run all apps except Thunderbird (which helpfully does it by itself) are preceded by app-detect. The app-detect script is a useful little thing I based off one I found on Stack Overflow (and after several logouts and restarts trying to get various things working I now can’t find the damn thing!), which checks for a running instance of the app passed in, switches to it if there is one, or launches one if there isn’t.

app-detect

#!/bin/bash

# little script to run apps through so that it switches to a running instance of the app 
# or starts one up if there isn't
# so I can draw my way around instead of alt-tabbing

app=${1%%\ *}
pid="$(pgrep $app)" #find the process id of the app

if [ "$?" -eq "0" ];
then
  wmctrl -a "$app" #focus existing instance of app
else
  $app #fire up the app if there isn't an instance
  wmctrl -a "$app" # then focus it
fi

xdotool getactivewindow mousemove --window %1 --polar 0 0 #move cursor to middle of newly focused window
eval $(xdotool getmouselocation --shell) # get position of mouse after it's moved

# would have prefered to reuse switcheroo but buggered if I could figure out how to do that!
#
# my primary screen is 2560x1440 and screen arrangement has Cintiq going off the bottom and a fair way to the right
# use $X and width if going off side
 

if [ $Y -gt 1440 ] #if mouseY is higher than bottom of primary display
then # map stylus to Cintiq
  xsetwacom set "Wacom ISDv5 307 Pen stylus" MapToOutput HEAD-1
  xsetwacom set "Wacom ISDv5 307 Pen eraser" MapToOutput HEAD-1
  xsetwacom set "Wacom ISDv5 309 Finger touch" MapToOutput HEAD-1
  echo "1" > ~/.wacom-mapping
else # map stylus to primary display
  xsetwacom set "Wacom ISDv5 307 Pen stylus" MapToOutput HEAD-0
  xsetwacom set "Wacom ISDv5 307 Pen eraser" MapToOutput HEAD-0
  xsetwacom set "Wacom ISDv5 309 Finger touch" MapToOutput HEAD-0
  echo "0" > ~/.wacom-mapping
fi

This only works out of the box for apps that happen to have executables with sensible names like firefox and blender. 3d Coat’s was actually 3d-coat-64 which I probably could have worked with. What I did to make things work for the script was make symlinks for the executables in /usr/local/bin with the names I needed for the script (krita and 3d-coat in my case).

Gnome Pie

Yay for pie menus! Pretty easy to set up. I made one for Krita and Blender (3d Coat for whatever reason ignored commands from the pie).

Gnome Pie menu

They are keyed to super+b for Blender and super+k for Krita. Icons can be set for the pie slices (which is how the ones in the screenie got there, they don’t look like that by default). I’ll probably add to them as I go and be too lazy to update the screenshot.

Easystroke

I really, really like the gestures in OSX, however the Cintiq doesn’t work as a giant trackpad and I don’t like mice. So drawing my way around is the next best thing. Easystroke is reasonably self-explanatory to set up. I used ctrl as one of the triggers (press the trigger when starting the stroke, let go while doing the stroke so the keypress isn’t passed on with the stroke command). Would have preferred to use super but that was not responsive for whatever reason. My gestures are currently as follows:

list of Easystroke gestures I made for Ubuntu Studio 16.04

Had to modify the quit gesture to be shift+ctrl+q for Chromium and Hangouts (drop down the Applications fieldset, click Add Program/Group, then click on the application you need to do special things for and then you can modify/add gestures just for that app). Even though the quit command is ctrl+q in Blender, the gesture won’t trigger it for some reason.

Additionally, 3d Coat is a pain. I’m not sure what it does but the tablet can’t be in Mode Relative (ie acting like a mouse) while it’s open, you can’t draw strokes over the top of it (they glitch horribly and don’t work).

Bonus screenie on the empty desktop showing off wallpapers made by Quadrapop (on Cintiq) and Rico Cilliers (on main display) rather than all the crap currently piled on the other one because someone requested it (I believe the comment was along the lines of “screenshots or it didn’t happen” XD)

Ubuntu 16.04 dual monitor screenshot