6 个版本
0.1.5 | 2022 年 5 月 5 日 |
---|---|
0.1.4 | 2022 年 4 月 22 日 |
0.1.3 | 2022 年 3 月 15 日 |
#608 在 Unix API
31KB
678 行
Ponde
基于 libinput 和 uinput 的 Wayland 和 X11 指点设备配置守护进程。
它可以执行与 xf86-input-libinput 类似的配置。
动机
在 Wayland 中,xf86-input-libinput 不可用,而指点设备设置对每个合成器都不同。Gnome Wayland 允许与 xf86-input-libinput 相同的设置,但不允许按钮映射,也不允许按设备设置。
我编写了这个程序来解决这些问题。
安装
$ cargo install ponde
使用方法
$ sudo ponde /path/to/config.yaml
配置示例
示例配置在此
devices:
- match_rule:
name: Kensington Expert Wireless TB Mouse
accel_profile: flat
scroll_button: BTN_SIDE
scroll_button_lock: true
- match_rule:
name: "- GameBall"
accel_profile: flat
scroll_button: BTN_MIDDLE
scroll_button_lock: false
- match_rule:
name: Logitech M570
accel_profile: flat
scroll_button: BTN_EXTRA
scroll_button_lock: false
button_mapping:
BTN_SIDE: BTN_MIDDLE
配置属性
match_rule
name
:指定要匹配的设备名称。
accel_profile
:将指针加速度配置文件设置为给定配置文件。允许的值是adaptive
,flat
。并非所有设备都支持此选项或所有配置文件。如果配置文件不受支持,则使用该设备的默认配置文件。有关配置文件及其行为的描述,请参阅 libinput 文档。accel_speed
:设置指针加速度速度,范围为 [-1, 1]button_mapping
:设置此设备的逻辑按钮映射。left_handed
:启用左手按钮方向,即交换左右按钮。middle_emulation
:启用中间按钮模拟。启用时,同时按下左右按钮会产生中间鼠标按钮点击。natural_scrolling
:启用或禁用自然滚动行为。rotation_angle
:将设备的旋转角度设置为给定的角度,单位为顺时针度。角度必须在 0.0(包含)和 360.0(不包含)之间。scroll_button
:指定一个按钮作为滚动按钮。如果按钮逻辑上处于按下状态,则将 x/y 轴移动转换为滚动事件。scroll_button_lock
:启用或禁用滚动按钮锁定。如果启用,则在第一次点击后将scroll_button
视为逻辑上按下,并在该按钮的第二次点击后保持按下状态。如果禁用(默认),则在物理释放后,scroll_button
被视为逻辑上按下。
Systemd 用户服务
要将程序作为systemd用户服务运行,您需要允许普通用户操作 /dev/uinput
。
在 /etc/modules-load.d/uinput.conf
中写入以下内容,以便在系统启动时显式加载 uinput 内核模块
uinput
在 /etc/udev/rules.d/99-uinput.rules
中写入以下 udev 规则,以便在 uinput 内核模块加载时授予 input
组读取/写入 /dev/uinput
的权限(如果您愿意,可以更改为其他组)
KERNEL=="uinput", ACTION=="add", GROUP="input", MODE="0660"
将用户添加到 input
组
% sudo gpasswd -a input $USER
在 ~/.config/systemd/user/ponde.service
中写入以下 systemd 用户服务配置
[Unit]
Description=Pointing device configurationd daemon
[Service]
Type=simple
ExecStart=%h/.cargo/bin/ponde %h/.config/ponde/config.yaml
Restart=always
[Install]
WantedBy=default.target
启用 ponde.service
并重新启动
% systemctl --user daemon-reload
% systemctl --user enable ponde.service
% sudo systemctl reboot
避免与Wayland组合器和X11设置冲突
ponde输出给uinput的事件成为Wayland组合器和X11的输入事件。换句话说,它们受这些设置的影响。特别是受影响的是 accel_profile
,libinput默认将其设置为自适应,因此如果未设置,将发生双倍加速。
您可以通过以下方式避免此问题
对于 gnome
$ gsettings set org.gnome.desktop.peripherals.mouse accel-profile flat
对于 X11
# /etc/X11/xorg.conf.d/90-ponde.conf
Section "InputClass"
Identifier "Ponde"
MatchProduct "ponde"
Driver "libinput"
Option "AccelProfile" "flat"
EndSection
限制
无法配置触摸板。这是有意不允许的,因为libinput将多个手指滑动转换为手势事件,原始输入无法恢复。
许可证
MIT
依赖项
~8.5MB
~161K SLoC