连接输入设备后启动自定义脚本


0

我有一个Genius平板电脑,当我将它连接到USB时,我需要重新映射它上面的一些按钮。通过以下命令完成重新映射:

xinput set-button-map 'Genius EasyPen M610X' 0 0 0 0 0 0 0 1 3 2

我正在使用udev来调用这样的脚本:

#!/bin/bash

sleep 10
/usr/bin/xinput set-button-map 'Genius EasyPen M610X' 0 0 0 0 0 0 0 1 3 2

该脚本工作正常,udev在插入设备时调用脚本,但是不执行带有xinput的行。 Dmesg和syslog没有说错误,也使用udevadm测试设备...没有错误传递。有任何想法吗? 谢谢。


1
你能发布输出吗? udevd --debug-trace --verbosestrace -p pid_of_udevd -f -e trace=open,exec
thisfeller

嗨,谢谢你的回复,输出太长,但是有两行说明了脚本的错误 [212.579522] [2321] spawn_read: '/usr/local/bin/tablet.sh'(err) 'Unable to connect to X server' [212.580112] [2321] spawn_wait: '/usr/local/bin/tablet.sh' [2326] exit with return code 1
Jan

你在使用debian吗?
thisfeller

我正在使用debian像发行版Linux mint 13
Jan

Answers:


0

最有可能的问题是用脚本调用脚本 DISPLAY 环境变量未设置。该变量告诉X程序它们应该连接到哪个显示器。在致电之前尝试添加以下内容 xinput

export DISPLAY=:0

例如:

% export DISPLAY=:0
% xinput ...
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.