現如今大部分筆記本觸摸板都支持多指操作,手勢操作。目前Windows和macOS都對觸摸板手勢有很好的支持,尤其是macOS的手勢操作簡直好用的不得了。但對於Linux,默認情況下可能只支持簡單的幾種操作(點擊,雙指滾動)。有沒有可以讓Linux也支持觸摸板手勢呢?最近在折騰Linux的過程中發現還是有辦法實現一些手勢功能的,雖然達不到macOS那麼豐富,但是到Windows那種級別還是可以的。
使用libinput-gestures
從archlinuxcn
或者aur
安裝libinput-gestures
yay -S libinput-gestures
Libinput-gestures是一個實用程序,可從觸摸板讀取libinput手勢並將其映射到在配置文件中配置的手勢。可以將每個手勢配置爲激活一個Shell命令,該命令通常是xdotool命令,用於操作桌面/窗口/應用程序鍵盤組合和命令。默認已經支持了一些常用的手勢比如左右滑動在瀏覽器前進/後退,上下滑動切換工作區,但由於Linux桌面的多樣性,默認手勢並不好用,我們可以自定義手勢來實現一些常用操作。
配置自定義手勢
首先拷貝默認配置/etc/libinput-gestures.conf
到~/.config/libinput-gestures.conf
。
自定義手勢支持滑
、涅
,以及手指數量。比如swipe up
就是上滑,swipe up 3
就是三指上滑,後面再跟上我們要執行的命令即可。
# Each gesture line has 3 [or 4] arguments separated by whitespace:
#
# action motion [finger_count] command
#
# where action and motion is either:
# swipe up
# swipe down
# swipe left
# swipe right
# swipe left_up
# swipe left_down
# swipe right_up
# swipe right_down
# pinch in
# pinch out
# pinch clockwise
# pinch anticlockwise
我的配置
下面是我在KDE Plasma桌面環境下,定義的一些常用手勢,可供參考。
# 三指上滑展示所有桌面
gesture swipe up 3 xdotool key ctrl+F8
# 三指下滑顯示桌面
gesture swipe down 3 xdotool key super+d
# 三指左滑後退
gesture swipe left 3 xdotool key alt+Right
# 三隻右滑前進
gesture swipe right 3 xdotool key alt+Left
# 四指上滑顯示應用程序面板(自定義的快捷鍵)
gesture swipe up 4 xdotool key ctrl+super+a
# 四指下滑顯示所有窗口
gesture swipe down 4 xdotool key ctrl+F10
# 四指左滑切換到右邊桌面
gesture swipe left 4 xdotool key ctrl+super+Right
# 四指右滑切換左邊桌面
gesture swipe right 4 xdotool key ctrl+super+Left
啓動
libinput-gestures-setup start|stop|restart|autostart|autostop|status
參考
Arch Wiki
libinput-gestures GitHub詳細介紹
告別命令行/使用嚮導安裝Arch Linux
KDE Plasma桌面美化macOS like
Arch Linux桌面環境(Xfce4)安裝教程
Xfce4桌面環境美化
Arch Linux桌面特效(Xfce4)使用compiz
Linux 如何利用多工作區來提升效率/Xfce4