您的位置:首页 > 运维架构 > Linux

在Linux系统中关闭触摸板

2014-05-04 13:43 337 查看
0x01 用xinput关闭触摸板

Ubuntu对笔记本的支持已经做的很到位了,但是还是会有些这样那样的问题。比如说我这款 Dell 14TR-4528 ,就不能关闭触摸板。这样在打字的时候就会很捉急,于是我想了个办法关闭触摸板。

我们需要xinput这个工具,可以从源安装。安装之后在终端输入xinput,就会出现当前的x设备列表。

james@james-PC ~ % xinput
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ USB Mouse                               	id=11	[slave  pointer  (2)]
⎜   ↳ USB Mouse                               	id=12	[slave  pointer  (2)]
⎜   ↳ PS/2 Generic Mouse                      	id=15	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
↳ Power Button                            	id=6	[slave  keyboard (3)]
↳ Video Bus                               	id=7	[slave  keyboard (3)]
↳ Video Bus                               	id=8	[slave  keyboard (3)]
↳ Power Button                            	id=9	[slave  keyboard (3)]
↳ Sleep Button                            	id=10	[slave  keyboard (3)]
↳ Laptop_Integrated_Webcam_HD             	id=13	[slave  keyboard (3)]
↳ AT Translated Set 2 keyboard            	id=14	[slave  keyboard (3)]
↳ Dell WMI hotkeys                        	id=16	[slave  keyboard (3)]


可以看到有几个mouse,找到你想禁用的设备,然后就可以

xinput disable [Device Name]


例如我的:

xinput disable "PS/2 Generic Mouse"


0x02 怎么找到要关闭的设备呢

用下面的命令:

james@james-PC ~ % xinput list-props "PS/2 Generic Mouse"
Device 'PS/2 Generic Mouse':
Device Enabled (135):	0
Coordinate Transformation Matrix (137):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (265):	0
Device Accel Constant Deceleration (266):	1.000000
Device Accel Adaptive Deceleration (267):	1.000000
Device Accel Velocity Scaling (268):	10.000000
Device Product ID (254):	2, 1
Device Node (255):	"/dev/input/event8"
Evdev Axis Inversion (269):	0, 0
Evdev Axes Swap (271):	0
Axis Labels (272):	"Rel X" (145), "Rel Y" (146)
Button Labels (273):	"Button Left" (138), "Button Middle" (139), "Button Right" (140), "Button Wheel Up" (141), "Button Wheel Down" (142)
Evdev Middle Button Emulation (274):	0
Evdev Middle Button Timeout (275):	50
Evdev Third Button Emulation (276):	0
Evdev Third Button Emulation Timeout (277):	1000
Evdev Third Button Emulation Button (278):	3
Evdev Third Button Emulation Threshold (279):	20
Evdev Wheel Emulation (280):	0
Evdev Wheel Emulation Axes (281):	0, 0, 4, 5
Evdev Wheel Emulation Inertia (282):	10
Evdev Wheel Emulation Timeout (283):	200
Evdev Wheel Emulation Button (284):	4
Evdev Drag Lock Buttons (285):	0


这样就可以看到这个设备的属性了,找到 Device Node 这一行,上面写着 "/dev/input/event8"。

既然他都这么写了,那就去 /dev/input 这个目录里,看看确实有event8这个东西,用管理员权限cat它,动动触摸板,看看有没有动静。如果是你找的设备,就会出现好多乱码。如果没反映就换一个试试,找到为止。

sudo cat /dev/input/event8


0x03 更方便地开关触摸板

#!/bin/bash

DeviceName="PS/2 Generic Mouse"
statu=$(xinput list-props "$DeviceName" | grep "Device Enabled" | awk '{print $4}')

if [ $statu == 1 ] ; then
xinput disable "$DeviceName"
else
xinput enable "$DeviceName"
fi


这个脚本会检测你的触摸板是否已经开启,如果开启了就关闭,关闭了就开启。

不过你要改改DeviceName这个变量,把它改成自己的设备名字。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: