首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xsetwacom运行良好,但不会在bash脚本中运行。

Xsetwacom运行良好,但不会在bash脚本中运行。
EN

Stack Overflow用户
提问于 2016-04-22 00:13:48
回答 1查看 774关注 0票数 1

我决定设置一个简单的bash脚本来自动设置我的Wacom平板电脑,但是我遇到了一些问题。这是文件:

代码语言:javascript
复制
#!/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脚本并运行它,就会得到以下错误:

代码语言:javascript
复制
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不需要任何根权限。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-25 02:08:34

对不起,我找到了解决办法。Xsetwacom不能快速运行所有这些命令。在脚本中添加一个sleep命令似乎可以做到这一点。这是我的新代码:

代码语言:javascript
复制
#!/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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36782554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档