文章大纲
在 i3 中,触控板轻触是没有响应的,必须点按才行,在 Gnome 或 KDE 等其它桌面环境中要设置触控板点按是非常容易的,但是在 i3 环境下,会麻烦一些。
通过命令的方式设置
xinput
是用于配置或测试输入设备的工具。
我当前使用的是 fedora , 默认没有安装 xinput
软件包,需要手动安装一下:
sudo dnf install xinput -y
安装完成后,直接运行 xinput
可以看到系统当前所有的输入设备:
xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ELAN067A:00 04F3:3197 Touchpad id=9 [slave pointer (2)]
⎜ ↳ ELAN067A:00 04F3:3197 Mouse id=10 [slave pointer (2)]
⎜ ↳ TPPS/2 JYT_Synaptics 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)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ sof-hda-dsp Headphone id=11 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
↳ ThinkPad Extra Buttons id=14 [slave keyboard (3)]
其中 id 为 9 的就是触控板 Touchpad 。
查看触控板的参数设置:
xinput list-props 9
Device 'ELAN067A:00 04F3:3197 Touchpad':
Device Enabled (189): 1
Coordinate Transformation Matrix (191): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Tapping Enabled (317): 1
libinput Tapping Enabled Default (318): 0
libinput Tapping Drag Enabled (319): 1
libinput Tapping Drag Enabled Default (320): 1
libinput Tapping Drag Lock Enabled (321): 0
libinput Tapping Drag Lock Enabled Default (322): 0
libinput Tapping Button Mapping Enabled (323): 1, 0
libinput Tapping Button Mapping Default (324): 1, 0
libinput Natural Scrolling Enabled (325): 0
libinput Natural Scrolling Enabled Default (326): 0
libinput Disable While Typing Enabled (327): 1
libinput Disable While Typing Enabled Default (328): 1
libinput Scroll Methods Available (329): 1, 1, 0
libinput Scroll Method Enabled (330): 1, 0, 0
libinput Scroll Method Enabled Default (331): 1, 0, 0
libinput Click Methods Available (332): 1, 1
libinput Click Method Enabled (333): 1, 0
libinput Click Method Enabled Default (334): 1, 0
libinput Middle Emulation Enabled (335): 0
libinput Middle Emulation Enabled Default (336): 0
libinput Accel Speed (337): 0.000000
libinput Accel Speed Default (338): 0.000000
libinput Accel Profiles Available (339): 1, 1, 1
libinput Accel Profile Enabled (340): 1, 0, 0
libinput Accel Profile Enabled Default (341): 1, 0, 0
libinput Accel Custom Fallback Points (342): <no items>
libinput Accel Custom Fallback Step (343): 0.000000
libinput Accel Custom Motion Points (344): <no items>
libinput Accel Custom Motion Step (345): 0.000000
libinput Accel Custom Scroll Points (346): <no items>
libinput Accel Custom Scroll Step (347): 0.000000
libinput Left Handed Enabled (348): 0
libinput Left Handed Enabled Default (349): 0
libinput Send Events Modes Available (302): 1, 1
libinput Send Events Mode Enabled (303): 0, 0
libinput Send Events Mode Enabled Default (304): 0, 0
Device Node (305): "/dev/input/event6"
Device Product ID (306): 1267, 12695
libinput Drag Lock Buttons (350): <no items>
libinput Horizontal Scroll Enabled (351): 1
libinput Scrolling Pixel Distance (352): 15
libinput Scrolling Pixel Distance Default (353): 15
libinput High Resolution Wheel Scroll Enabled (354): 1
其中 libinput.Tapping Enabled
和 libinput.Tapping Enabled Default
就是管理触控板轻触的配置,当前都是 0
,将其设置为 1
进行启用:
xinput set-prop 9 317 1
xinput set-prop 9 318 1
现在就可以通过触控板进行轻触了,但是重启配置就会丢失。
设置开机自动设置
可以编写一个脚本 $HOME/.config/i3/touchpad.sh
:
#!/bin/bash
deviceid=`xinput | grep "Touchpad" | awk -F" " {'print $6'} | awk -F"=" {'print $2'}`
propid=`xinput list-props ${deviceid} | grep "libinput Tapping Enabled (" | awk -F" " {'print $4'}`
propid=${propid:1:3}
xinput set-prop ${deviceid} ${propid} 1
在 i3 的配置中设置为开机自动执行:
exec --no-startup-id $HOME/.config/i3/touchpad.sh