Galen Asphaug Galen Asphaug - 7 months ago 20
Bash Question

Xsetwacom works fine, but won't run inside a bash script

I decided to set up a simple bash script that would automatically setup my Wacom tablet, but I'm having some issues. Here's the file:

#!/bin/bash

#Used to setup my Wacom Tablet (Intous Draw)
xsetwacom --list
echo "Setting up Wacom Tablet..."
sudo modprobe -r wacom
sudo modprobe -r wacom_w8001
sudo modprobe wacom
sudo modprobe wacom_w8001
echo "Configuring pen buttons..."
xsetwacom set "Wacom Intuos S 2 Pen stylus" Button 2 key +space
echo "Configuring tablet buttons..."
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 1 key +ctrl z -ctrl
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 3 key +ctrl
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 8 key +ctrl +shift z -shift -ctrl
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 9 key +alt +shift +ctrl k -ctrl -shift - alt
echo "Mapping tablet to DVI-0..."
xsetwacom set "Wacom Intuos S 2 Pen stylus" MapToOutput DVI-0
echo "Done!"
exit 0


If I enter these commands manually, they work fine, no errors, but once I put them into a bash script and run it, I get the following errors:

Wacom Intuos S 2 Pen stylus id: 13 type: STYLUS
Wacom Intuos S 2 Pad pad id: 14 type: PAD
Setting up Wacom Tablet...
Configuring pen buttons...
Cannot find device 'Wacom Intuos S 2 Pen stylus'.
Configuring tablet buttons...
Cannot find device 'Wacom Intuos S 2 Pad pad'.
Cannot find device 'Wacom Intuos S 2 Pad pad'.
Cannot find device 'Wacom Intuos S 2 Pad pad'.
Cannot find device 'Wacom Intuos S 2 Pad pad'.
Mapping tablet to DVI-0...
Cannot find device 'Wacom Intuos S 2 Pen stylus'.
Done!


The first command lists the available devices (to make sure it's connected), and the others are to setup the buttons and map to my monitor. I've made sure that the spelling is correct, and that the commands are written correctly, but it still doesn't work. Using
sudo
doesn't help either.
xsetwacom
doesn't need any root permissions.

Answer

Sorry all, I found the solution. Xsetwacom can't run all of these commands rapidly. Adding a sleep command to the script seemed to do the trick. Here's my new code:

#!/bin/bash

#Used to setup my Wacom Tablet (Intous Draw)
echo "Setting up Wacom Tablet..."
sudo modprobe -r wacom
sudo modprobe -r wacom_w8001
sudo modprobe wacom
sudo modprobe wacom_w8001
echo "Configuring pen buttons..."
sleep 0.1
xsetwacom set "Wacom Intuos S 2 Pen stylus" Button 2 key +space
echo "Configuring tablet buttons..."
sleep 0.1
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 1 key +ctrl z -ctrl
sleep 0.1
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 3 key +ctrl
sleep 0.1
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 8 key +ctrl +shift z -shift -ctrl
sleep 0.1
xsetwacom set "Wacom Intuos S 2 Pad pad" Button 9 key +alt +shift +ctrl k -ctrl -shift - alt
echo "Mapping tablet to DVI-0..."
sleep 0.1
xsetwacom set "Wacom Intuos S 2 Pen stylus" MapToOutput DVI-0
echo "Done!"
exit 0