使触摸板敲击(不是按压)时也产生左键事件
1sudo apt install xserver-xorg-input-synaptics
2sudo vim /etc/X11/xorg.conf.d/50-synaptics.conf
在文件中添加以下内容
1Section "InputClass"
2 Identifier "touchpad catchall"
3 Driver "synaptics"
4 MatchIsTouchpad "on"
5
6 Option "TapButton1" "1" #单指敲击产生左键事件
7 Option "TapButton2" "2" #双指敲击产生中键事件
8 Option "TapButton3" "3" #三指敲击产生右键事件
9
10 Option "VertEdgeScroll" "on" #滚动操作:横向、纵向、环形
11 Option "VertTwoFingerScroll" "on"
12 Option "HorizEdgeScroll" "on"
13 Option "HorizTwoFingerScroll" "on"
14 Option "CircularScrolling" "on"
15 Option "CircScrollTrigger" "2"
16
17 Option "EmulateTwoFingerMinZ" "40" #精确度
18 Option "EmulateTwoFingerMinW" "8"
19 Option "CoastingSpeed" "20" #触发快速滚动的滚动速度
20
21 Option "PalmDetect" "1" #避免手掌触发触摸板
22 Option "PalmMinWidth" "3" #认定为手掌的最小宽度
23 Option "PalmMinZ" "200" #认定为手掌的最小压力值
24EndSection
键入时禁止触摸板
键入时禁止触摸板可以避免焦点变化,影响当前的输入。 对于使用 startx 来启动的桌面系统,可以修改其 .xinitrc 初始化配置文件来完成:
1syndaemon -t -k -i 2 -d &
其中的 -i 2
表示两秒空闲,即键盘事件后的两秒内不允许响应触摸板 Tap。更多信息请参照手册页:
1man syndaemon
外接鼠标时禁用触摸板
在 arch linux 中,使用 udev 监测硬件的热拔插,通过修改其规则文件,来响应外接鼠标事件,从而禁用和启用触摸板。如下的规则文件,调用了 synclient。
1#file: /etc/udev/rules.d/01-touchpad.rules
2ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/harttle/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=1"
3ACTION=="remove", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/harttle/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=0"
注意:该文件中每个操作必须单独一行,可以使用 \
来折行;SUBSYSTEM
与 KERNEL
指定了设备 /dev/input/mouse[0-9]
(archwiki的中文页面中此处有误,我会找时间去修改)。了解更多 udev rules
语法:https://wiki.archlinux.org/index.php/Udev
开机时鼠标检测
PS/2
鼠标在开机时不会触发 udev
规则。我们做一个桌面环境的启动脚本,在 .xinitrc
,profile
中调用,或者放在 KDE
的 Autostart
中:
1#!/bin/bash
2ids=`ls /dev/input/by-id | grep -E '.*-mouse'`
3[ "$ids" ] && synclient TouchpadOff=1
除另有声明外,本博客文章均采用 知识共享 (Creative Commons) 署名 4.0 国际许可协议 进行许可。转载请注明原作者与文章出处。