Ubuntu 下基於 fusuma 的觸控板多指觸控實現

Ubuntu 本身是不能實現兩指以上的觸控操作的,但是我們可以通過 fusuma 來實現它。


github 地址:https://github.com/iberianpig/fusuma

1. Fusuma 簡介

Fusuma是多點觸控手勢識別器。這個gem使您的linux能夠識別滑動捏合並向它們分配命令。
襖(Fusuma)指的是在日本家庭中用來隔開房間的推拉門。
在這裏插入圖片描述

2. Fusuma 特性

  • 使用RubyGems輕鬆安裝。
  • 在YAML中定義手勢和動作。
  • 可設置手勢識別靈敏度(閾值、間隔)。
  • 可用於重新連接外部觸摸板的自動添加設備。
  • 基於插件系統的手勢識別擴展。

3. Fusuma 安裝

1.授予讀取觸摸板設備的權限

提示:您使用的用戶必須加入INPUT組才能使用Fusuma 閱讀觸摸板,這一步就是將當前用戶加入INPUT組。

sudo gpasswd -a $USER input

2.安裝libinput-tools

需要libinput 1.0版或更高版本。

sudo apt-get install libinput-tools

3.安裝Ruby

Fusuma在Ruby中運行.

sudo apt-get install ruby

4.安裝 Fusuma

sudo gem install fusuma

5.安裝xdotool(可選)

用於發送快捷方式。

sudo apt-get install xdotool

如果觸摸板在GNOME中不工作,通過運行以下命令,確保將觸摸板事件發送到GNOME桌面:

gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled

4. Fusuma 使用

4.1 啓動 Fusuma

fusuma

如果遇到ERROR -- : Touchpad is not found可以試試運行:

sudo fusuma

4.2 更新 Fusuma

sudo gem update fusuma

5. 自定義手勢映射

通過編輯~/.config/fusuma/config.yml來自定義手勢映射。

如果~/.config/fusuma目錄尚不存在,則需要創建該目錄。

mkdir -p ~/.config/fusuma        # create config directory
sudo gedit ~/.config/fusuma/config.yml # edit config file.

5.1 可用的手勢

  • swipe:
    • 支持34
    • 支持 left:, right:, up:, down: 四個方向
  • 捏合 pinch:
    • 支持234
    • 支持 in:, out:兩個方向
  • 旋轉 rotate:
    • 支持234
    • 支持clockwise:,counterclockwise:兩個方向

5.2 例子

默認設置

swipe:
  3:
    left:
      command: "xdotool key alt+Right" # History forward 
    right:
      command: "xdotool key alt+Left" # History back
    up:
      command: "xdotool key super" # Activity
    down:
      command: "xdotool key super" # Activity
  4:
    left:
      command: "xdotool key ctrl+alt+Down" # Switch to next workspace
    right:
      command: "xdotool key ctrl+alt+Up" # Switch to previous workspace
    up:
      command: "xdotool key ctrl+alt+Down" # Switch to next workspace
    down:
      command: "xdotool key ctrl+alt+Up" # Switch to previous workspace
pinch:
  in:
    command: "xdotool keydown ctrl click 4 keyup ctrl" # Zoom in
  out:
    command: "xdotool keydown ctrl click 5 keyup ctrl" # Zoom out

PS: 重啓後設置生效。

5.3 xdotool介紹

6. Fusuma 插件

6.1 Fusuma 插件的作用

  • 添加新手勢或組合。
  • 特定Linux發行版的功能。
  • 爲每個應用程序設置不同的手勢

6.2 Fusuma 插件的安裝

Fusuma插件遵循fusuma-plugin-XXXXX命名約定,託管在RubyGems上。

6.3 Fusuma 可用插件

插件名 功能
fusuma-plugin-sendkey 模擬鍵盤事件
fusuma-plugin-wmctrl 管理窗口和工作區
fusuma-plugin-keypress 在按多個鍵時檢測手勢
fusuma-plugin-tap 檢測點擊和按住手勢

7. Fusuma 開機啓動

參考:https://blog.csdn.net/Small_Dong_0_o/article/details/83342228

7.1 創建Fusuma 應用

cd /usr/share/applications &&
sudo touch fusuma.desktop

此時你就可以在/usr/share/applications看到fusuma.desktop的圖標了:
在這裏插入圖片描述
接下來我們就需要編輯這個應用(保持在當前目錄):

cd /usr/share/applications &&
sudo gedit fusuma.desktop

填入以下內容:

[Desktop Entry]
Encoding=UTF-8
Name=fusuma
Comment=fusuma
# 你的fusuma的路徑,可通過終端命令 `which fusuma`找到
Exec=/usr/local/bin/fusuma
# 這裏是你的fusuma的圖標,隨便找一個就行
Icon=/usr/share/icons/fusuma.png
# 軟件打開時是否啓動終端,這裏選擇false
Terminal=false  
StartupNotify=false
Type=Application
Categories=Application;Development;

在這裏插入圖片描述
你可以雙擊圖標打開軟件,可以打開則安裝成功。
在這裏插入圖片描述

7.2 設置開機啓動

打開tweak,如果沒有在軟件商店中搜索安裝:
在這裏插入圖片描述
fusuma添加到開機啓動:
在這裏插入圖片描述
然後就大功告成了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章