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:
- 支持
3
,4
指 - 支持
left:
,right:
,up:
,down:
四个方向
- 支持
- 捏合
pinch:
- 支持
2
,3
,4
指 - 支持
in:
,out:
两个方向
- 支持
- 旋转
rotate:
- 支持
2
,3
,4
指 - 支持
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
介绍
- xdotool 主页
在xdotool中的按键名:
参考:https://gitlab.com/cunidev/gestures/-/wikis/xdotool-list-of-key-codes
常用:ctrl、shift、alt、BackSpace、Tab、Home、Left、Up、Right、Down、Page_Up、Page_Down、Print、
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
添加到开机启动:
然后就大功告成了。