0x00
这里使用的是libinput-gestures
,依赖xdotool(模拟鼠标/键盘输入)
sudo pacman -S libinput-gestures xdotool
sudo pacman -S libinput xf86-input-libinput
配置libinput文件(文件名字视情况而定,我的是40-libinput.conf)
sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/40-libinput.conf
下面是文件中touchpad部分的配置:
Section "InputClass"
Identifier "touchpad"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
Option "Tapping" "on"
Option "ButtonMapping" "1 3 0 4 5 6 7"
Option "TappingButtonMap" "lmr"
Option "DisableWhileTyping" "on"
Option "TappingDrag" "on"
EndSection
详细参数和解释见libinput man page: based on X.Org input dirver,解释下几个重要的配置参数:
Option “Tapping” “on”:手指点击touchpad发送鼠标点击事件
Option “TappingButtonMap” “lmr”:1个手指点击对应鼠标左键
,2个手指点击对应鼠标中键
,3个鼠标点击对应鼠标右键
。
Option “ButtonMapping” “1 3 0 4 5 6 7″,按钮映射,详情见libinput#Button_Mapping,这里笔者关闭了3指对应的左键。
Option “DisableWhileTyping” “on”:打字时不检测touchpad事件,防止用户不小心触碰touchpad引起不必要的影响。
Option “TappingDrag” “on”:开启点击拖拽。
0x01
添加当前用户到用户组
sudo gpasswd -a $USER input
复制文件
cp /etc/libinput-gestures.conf ~/.config/
编辑~/.config/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指张: 放大
0x02
启动
libinput-gestures-setup start
END