Archlinux: 优化触摸板配置

更新于2017-02-04

年后更新系统发现 xSwipe 已不能正常使用, 原来早在 2017-01-14 社区已发布公告xf86-input-libinput 将成为默认输入设备的驱动, 但 synaptics/evdev/wacom 仍旧可以使用.

查看 archlinux 的 xSwipe 包主页也发现如下评论:
xf86-input-synaptics-xswipe-git disown

没有触摸板的日子是很煎熬的, 并且, 为了一劳永逸(暂时的😢), 那就切换到 libinput 吧, 而且它也提供了 libinput-gestures 来配置手势.

安装 libinput-gestures 后要把当前用户添加到 input 用户组, 并且需要注销当前用户, 否则不生效. 它的配置文件是 $HOME/.config/libinput-gestures.conf/etc/libinput-gestures.conf, 修改完毕后即可启动测试:

sudo gpasswd -a $USER input  # 将当前用户添加到 input 用户组
vim $HOME/.config/libinput-gestures.conf # 编辑配置文件, 如果不存在该文件就从 /etc/libinput-gestures.conf 复制一份
libinput-gestures-setup start # 启动程序

主要为 libinput-gestures 新增以下配置:

gesture swipe left 4 xdotool key super+Left # 4指左划: 切换到左侧工作区
gesture swipe right 4 xdotool key super+Right # 4指右划: 切换到右侧工作区

gesture swipe left 3 xdotool key alt+Left # 3指左划: 浏览器后退
gesture swipe right 3 xdotool key alt+Right # 3指右划: 浏览器前进
gesture swipe up 3 xdotool key F5 # 3指上划: 刷新当前页面
gesture swipe down 3 xdotool key ctrl+w # 3指下划: 关闭当前页面

gesture pinch in 2 xdotool key ctrl+minus # 2指捏: 缩小
gesture pinch out 2 xdotool key ctrl+plus # 2指张: 放大

对了, 默认配置没有启用轻触, 啪啪啪的按触摸板这也是不能接受的.

首先查看输入设备列表, 得知触摸板设备 ID 是 12:

$ xinput  list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=12   [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                     id=13   [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)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳ Integrated Camera                         id=10   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=11   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=14   [slave  keyboard (3)]

查看触摸板设备属性:

$ xinput list-props 12
Device 'SynPS/2 Synaptics TouchPad':
        Device Enabled (139):   1
        Coordinate Transformation Matrix (141): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        libinput Tapping Enabled (274): 0
        libinput Tapping Enabled Default (275): 0
        libinput Tapping Drag Enabled (276):    1
        libinput Tapping Drag Enabled Default (277):    1
        libinput Tapping Drag Lock Enabled (278):       0
        libinput Tapping Drag Lock Enabled Default (279):       0
        libinput Tapping Button Mapping Enabled (280):  1, 0
        libinput Tapping Button Mapping Default (281):  1, 0
        libinput Accel Speed (282):     0.000000
        libinput Accel Speed Default (283):     0.000000
        libinput Natural Scrolling Enabled (284):       0
        libinput Natural Scrolling Enabled Default (285):       0
        libinput Send Events Modes Available (259):     1, 1
        libinput Send Events Mode Enabled (260):        0, 0
        libinput Send Events Mode Enabled Default (261):        0, 0
        libinput Left Handed Enabled (286):     0
        libinput Left Handed Enabled Default (287):     0
        libinput Scroll Methods Available (288):        1, 1, 0
        libinput Scroll Method Enabled (289):   1, 0, 0
        libinput Scroll Method Enabled Default (290):   1, 0, 0
        libinput Click Methods Available (291): 1, 1
        libinput Click Method Enabled (292):    1, 0
        libinput Click Method Enabled Default (293):    1, 0
        libinput Middle Emulation Enabled (294):        0
        libinput Middle Emulation Enabled Default (295):        0
        libinput Disable While Typing Enabled (296):    1
        libinput Disable While Typing Enabled Default (297):    1
        Device Node (262):      "/dev/input/event11"
        Device Product ID (263):        2, 7
        libinput Drag Lock Buttons (298):       <no items>
        libinput Horizontal Scroll Enabled (299):       1

看到 libinput Tapping 的两个配置编号分别为 274/275, 且值都为 0(禁用), 所以配置为 1 就可以启用 轻触代替点击 啦:

xinput set-prop 12 274 1

更新于 2017-02-14

发现有时在重启后 device id 或者配置编号可能发生编号, 因此可使用如下字符串版本的命令替换 id 版本:

xinput set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "libinput Tapping Enabled" 1

更新于 2017-03-26

今天晚上发现在合上笔记本盖子后发现触摸板三指手势失效(二指的放大缩小仍旧有效). 通过 libinput-debug-events 发现无法检测到三指事件了. 执行 libinput-gestures-setup restart 重启手势服务也没有效果, 但看到终端有这个错误提示:

libinput error: kernel bug: Touch jump detected and discarded.
See https://wayland.freedesktop.org/libinput/doc/1.6.3/touchpad_jumping_cursor.html for details

上面的链接提到在多点触控的触摸板上可能会发生手指触摸坐标跳跃的现象, 但这种问题应该在内核中得到解决. 如果看到有上述错误日志, 请记录相关数据并提交 bug...

Archlinux WiKi: Touchpad Synaptics--Cursor jump 小节中有提到了这个问题, 提示可能是 i8042 控制器丢失中断请求有关, 暂时还没有补丁, 但已经有开发者关注这个问题了. 普通用户可通过重新加载 psmouse 模块或者添加启动参数 i8042.nomux=1 的方式解决问题.

在尝试重新加载 psmouse 模块后问题得到解决, 于是暂时就先不管这个事情了, 待稳定重现后再说.


以下为原文.

转做 java 开发后感觉电脑越来越慢了, 于是就拿起了大学时折腾过的 Archlinux.

公司虽然要求 Windows/MacBook 安装几个客户端, 但因为没有 linux 解决方案, 也没有禁止使用 linux, 这点还是挺人性化的. 刚开始几天是下班后再切换到 Arch 下, 测试几天后就把工作环境完全切换到 Arch 下了.

在 linux 下一个很严重的问题是 触摸板太灵敏了, 稍微一碰鼠标就飞了, 并且 linux 桌面环境有特性: 当前活动窗口是鼠标所在窗口. 这两个问题/特性加起来, 是非常严重使用体验. 完全禁用触摸板又太极端了, 于是翻翻 Archlinux WiKi, 优化下触摸板配置, 虽然还达不到同事吹嘘的 MacBook 那种程度, 但也比 Windows 下好用了.

基础配置

确认自己的触摸板支持哪些特性:

$ xinput list-props "SynPS/2 Synaptics TouchPad" | grep Capabilities
        Synaptics Capabilities (325):   1, 0, 0, 1, 1, 1, 1

上面输出的 1/0 按顺序分别表示:

  • 1: 设备有物理左键;
  • 0: 设备没有物理中键;
  • 0: 设备没有物理右键;
  • 1: 设备支持两指检测;
  • 1: 设备支持三指检测;
  • 1: 设备支持配置垂直分辨率(精度);
  • 1: 设备支持配置水平分辨率(精度);

既然支持两指和三指检测, 就可以配置对应的事件了. 其中相关属性有:

  • TabButton1: 一个手指轻触触摸板;
  • TabButton2: 两个手指轻触触摸板;
  • TabButton3: 三个手指触摸触摸板;

可选值是:

  • 1: 鼠标左键;
  • 2; 鼠标中键;
  • 3; 鼠标右键;

于是就有了下面的配置:

synclient TapButton1=1 # 一个手指轻触触摸板代表点击左键
synclient TapButton2=3 # 两个手指轻触触摸板代表点击右键
synclient TapButton3=2 # 三个手指轻触触摸板代表点击中键

触摸板感应测试

当前的英文 WiKi 已经没有关于 synclient 命令 -m 参数的介绍了, 命令文档中也没有该参数的介绍, 只有中文 WiKi 里还有一点介绍. 经测试可用, 并且效果比 evtestxev 更清晰.

这里 -m 参数是用来配置每隔多少毫秒读取一次触摸板当前状态(比如触摸位置和压力). 例如:

$ synclient -m 100
    time     x    y   z f  w  l r u d m     multi  gl gm gr gdx gdy
   0.000  1053 3969   0 0  0  0 0 0 0 0  00000000
   1.802  1105 3623   0 0  0  0 0 0 0 0  00000000
   2.703  1219 4364  94 1  0  0 0 0 0 0  00000000
   2.803  1222 4377  59 1  0  0 0 0 0 0  00000000
   2.904  1215 4382   0 0  0  0 0 0 0 0  00000000
   4.606  2645 3925  64 4  0  0 0 0 0 0  00000000
   4.706  2640 3937  48 4  0  0 0 0 0 0  00000000
   4.806  2640 3937   0 0  0  0 0 0 0 0  00000000

其中:

  • x/y: 位置;
  • z: 压力;
  • f: 手指数;

这样, 如果我们对触摸板的灵敏度不满意的话, 可以通过尝试操作触摸板即快速找到自己的满意值.


掌压感应

如果在打字时鼠标乱飞, 那就需要开启和设置 掌压感应 了:

synclient PalmDetect=1  # 开启掌压感应
synclient PalmMinWidth=8 # 设定手掌与触摸板的最小接触面, 超过该值认为触摸板被手掌压到了(单位是手指宽度?)
synclient PalmMinZ=30 # 设定手掌压在触摸板上的最小压力, 超过该值认为触摸板被手掌压到了

注: PalmMinWidthPalmMinZ 需要根据自身情况调整数值大小.


xSwipe

上面提到的这些功能可被 xf86-input-synaptics 驱动支持, 然而如果想开启四指/五指检测和更多手势支持的话,
就需要安装 xf86-input-synaptics-xswipe-git 驱动了.

安装该驱动后, clone 在 GitHub 上的 xSwipe,
通过修改配置文件 eventKey.cfg 设置不同触摸板事件对应的键盘按键. 然后启动 xSwipe 即可:

perl xSwipe.pl

参考链接:

posted @ 2016-12-10 19:20  whilst  阅读(12967)  评论(0编辑  收藏  举报