我决定设置一个简单的bash脚本来自动设置我的Wacom平板电脑,但是我遇到了一些问题。这是文件:
#!/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
如果我手动输入这些命令,它们可以正常工作,没有错误,但是一旦我将它们放入bash脚本并运行它,我就会收到以下错误:
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!
第一个命令列出了可用的设备(以确保它已连接),其他命令是设置按钮并映射到我的显示器。我已经确保拼写正确,并且命令写得正确,但它仍然不起作用。使用sudo
也无济于事。 xsetwacom
不需要任何root权限。
答案 0 :(得分:0)
对不起,我找到了解决方案。 Xsetwacom无法快速运行所有这些命令。向脚本添加sleep
命令似乎可以解决问题。这是我的新代码:
#!/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