在 i3wm 中如何像 Win10 一样使用触控板切换工作区? - 知乎
2021-11-21 13:31:45 Author: zhuanlan.zhihu.com(查看原文) 阅读量:45 收藏

实现效果

  1. 四指左右滑动切换桌面,上滑全屏,下滑切换到第九个桌面,因为 i3wm 没有隐藏窗口的功能,相当于间接实现了吧
  2. 三指上下左右滑动切换焦点

实现方法

这里我们需要用到 libinput-gestures

安装方法:

Arch 系
yay -S libinput-gestures

其他发行版自行 Google

安装好后

sudo gpasswd -a $USER input 
获取触控板的权限

然后最好重启一下

cp /etc/libinput-gestures.conf ~/.config/libinput-gestures.conf 
创建当前用户的配置文件

这里我们需要先修改一下 i3wm 的快捷键

# win+数字切换工作区,第二次返回之前的工作区
workspace_auto_back_and_forth yes
# 循环切换工作区
bindsym $mod+Tab workspace next
bindsym $mod+Shift+Tab workspace prev

然后修改 libinput-gestures.conf

在最后添加下代码即可

gesture swipe left  4 xdotool key  Super+Shift+Tab
gesture swipe right 4 xdotool key  Super+Tab
gesture swipe up    4 xdotool key  Super+f
gesture swipe down  4 xdotool key  Super+9

gesture swipe left  3 xdotool key  Super+Left
gesture swipe right 3 xdotool key  Super+Right
gesture swipe up    3 xdotool key  Super+Up
gesture swipe down  3 xdotool key  Super+Down

应该很浅显易懂吧,更多手势操作可以自行查看文档:

然后输入

libinput-gestures-setup autostart 
设置开机自启
libinput-gestures-setup start 
运行该程序
libinput-gestures-setup restart 
重启该程序,更新配置

顺便要说一下,可能有些人的触控板没有使用自然滚动,导致滑动方向与页面滚动方向相反,手势操作的方向也会反过来,这个要注意一下

如何修改呢,这里我简单说一下

修改 /etc/X11/xorg.conf.d/40-libinput.conf

可能文件名有些不一样

在最后添加以下代码,可以自然滚动,单击为左键,双击为右键,三击为中键

Section "InputClass"
    Identifier "touchpad"
    Driver "libinput"
    MatchIsTouchpad "on"
    Option "Tapping" "on"
    Option "NaturalScrolling" "true"
    Option "ClickMethod" "clickfinger"
EndSection

ok了,希望这篇文章能对大家有所帮助


文章来源: https://zhuanlan.zhihu.com/p/116957768
如有侵权请联系:admin#unsafe.sh