Xsetwacom 工作正常,但不会 运行 在 bash 脚本中
Xsetwacom works fine, but won't run inside a bash script
我决定设置一个简单的 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 权限。
抱歉大家,我找到了解决办法。 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
我决定设置一个简单的 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 权限。
抱歉大家,我找到了解决办法。 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