Giter VIP home page Giter VIP logo

ponde's Introduction

Ponde

Crates.io CI

Pointing device configuration daemon for Wayland and X11 using libinput and uinput.

It can do the similar configiration as xf86-input-libinput.

Motivation

In Wayland, xf86-input-libinput is not available, and the pointing device settings are different for each compositor. Gnome Wayland allows the same settings as xf86-input-libinput, but does not allow mapping of buttons, nor does it allow per-device settings.

I wrote this program to solve these problem.

Install

$ cargo install ponde

Usage

$ sudo ponde /path/to/config.yaml

Configuration example

Example configuration is here:

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

Configuration properties

  • match_rule
    • name: Specifies device name to match.
  • accel_profile: Sets the pointer acceleration profile to the given profile. Permitted values are adaptive, flat. Not all devices support this option or all profiles. If a profile is unsupported, the default profile for this device is used. For a description on the profiles and their behavior, see the libinput documentation.
  • accel_speed: Sets the pointer acceleration speed within the range [-1, 1]
  • button_mapping: Sets the logical button mapping for this device.
  • left_handed: Enables left-handed button orientation, i.e. swapping left and right buttons.
  • middle_emulation: Enables middle button emulation. When enabled, pressing the left and right buttons simultaneously produces a middle mouse button click.
  • natural_scrolling: Enables or disables natural scrolling behavior.
  • rotation_angle: Sets the rotation angle of the device to the given angle, in degrees clockwise. The angle must be between 0.0 (inclusive) and 360.0 (exclusive).
  • scroll_button: Designates a button as scroll button. If the button is logically down, x/y axis movement is converted into scroll events.
  • scroll_button_lock: Enables or disables the scroll button lock. If enabled, the scroll_button is considered logically down after the first click and remains down until the second click of that button. If disabled (the default), the scroll_button is considered logically down while held down and up once physically released.

Systemd user service

To run as a systemd user service, you need to give permission to ordinary users to manipulate /dev/uinput.

Write the following in /etc/modules-load.d/uinput.conf to explicitly load the uinput kernel module at OS boot:

uinput

Write the following udev rule in /etc/udev/rules.d/99-uinput.rules to grant permission to the input group to read/write /dev/uinput when the uinput kernel module is loaded (you can change it to another group if you prefer):

KERNEL=="uinput", ACTION=="add", GROUP="input", MODE="0660"

Make the user belong to the input group:

% sudo gpasswd -a input $USER

Write the following systemd user service configuration in ~/.config/systemd/user/ponde.service:

[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

Enable ponde.service and reboot:

% systemctl --user daemon-reload
% systemctl --user enable ponde.service
% sudo systemctl reboot

Avoid conflicts with Wayland compositor and X11 settings

The events output by ponde to uinput become input events for the Wayland compositor and X11. In other words, they are affected by these settings. Especially affected is accel_profile, which libinput sets to adaptive by default, so if nothing is set, double acceleration will occur.

You can avoid this problem by setting the following:

For gnome:

$ gsettings set org.gnome.desktop.peripherals.mouse accel-profile flat

For X11:

# /etc/X11/xorg.conf.d/90-ponde.conf
Section "InputClass"
  Identifier "Ponde"
  MatchProduct "ponde"
  Driver "libinput"
  Option "AccelProfile" "flat"
EndSection

Limitation

Trackpad cannot be configured. This is intentionally disallowed because libinput converts multiple finger swipes into gesture events and the original input cannot be restored.

License

MIT

ponde's People

Contributors

buzztaiki avatar dependabot[bot] avatar

Stargazers

David M. Golembiowski avatar Mykola Orliuk avatar

Watchers

 avatar James Cloos avatar  avatar

ponde's Issues

crashed by malloc(): unaligned fastbin chunk detected 3

It was worked until recently, why...

$ gdb -q --args ./target/debug/ponde config.yaml
Reading symbols from ./target/debug/ponde...
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/taiki/dev/src/github.com/buzztaiki/ponde/target/debug/ponde.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) run
Starting program: /home/taiki/dev/src/github.com/buzztaiki/ponde/target/debug/ponde config.yaml
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
malloc(): unaligned fastbin chunk detected 3

Program received signal SIGABRT, Aborted.
0x00007ffff7d3734c in __pthread_kill_implementation () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7d3734c in __pthread_kill_implementation () at /usr/lib/libc.so.6
#1  0x00007ffff7cea4b8 in raise () at /usr/lib/libc.so.6
#2  0x00007ffff7cd4534 in abort () at /usr/lib/libc.so.6
#3  0x00007ffff7d2b397 in __libc_message () at /usr/lib/libc.so.6
#4  0x00007ffff7d4133c in  () at /usr/lib/libc.so.6
#5  0x00007ffff7d447ec in _int_malloc () at /usr/lib/libc.so.6
#6  0x00007ffff7d45752 in malloc () at /usr/lib/libc.so.6
#7  0x00007ffff7d480d0 in strdup () at /usr/lib/libc.so.6
#8  0x00007ffff7f27631 in  () at /usr/lib/libudev.so.1
#9  0x00007ffff7f2e07e in  () at /usr/lib/libudev.so.1
#10 0x00007ffff7f2e206 in  () at /usr/lib/libudev.so.1
#11 0x00007ffff7f31d3f in  () at /usr/lib/libudev.so.1
#12 0x00007ffff7f3245f in udev_monitor_receive_device () at /usr/lib/libudev.so.1
#13 0x00007ffff7f04db9 in  () at /usr/lib/libinput.so.10
#14 0x00007ffff7edcde7 in libinput_dispatch () at /usr/lib/libinput.so.10
#15 0x00005555556276df in input::context::Libinput::dispatch (self=0x7fffffffdd48) at /home/taiki/.cargo/registry/src/github.com-1ecc6299db9ec823/input-0.7.0/src/context.rs:333
#16 0x00005555555936bc in ponde::app::App::event_loop (self=0x7fffffffe138) at src/app.rs:42
#17 0x00005555555b3225 in ponde::main () at src/main.rs:30

CI

It is better to build and test with CI.

udev rule does not apply after boot

I set udev rule as the following:

# /etc/udev/rules.d/99-uinput.rules
# allow input group to access uinput
KERNEL=="uinput", GROUP="input", MODE="0660"

It was set up with reference to https://wiki.archlinux.org/title/Wiimote.

After boot, ponde cannot get write permission of uinput device /dev/uinput:

Apr 13 13:13:47 echo ponde[1461]: Error: failed to create sink device
Apr 13 13:13:47 echo ponde[1461]: Caused by:
Apr 13 13:13:47 echo ponde[1461]:     0: io error: Permission denied (os error 13)
Apr 13 13:13:47 echo ponde[1461]:     1: Permission denied (os error 13)
Apr 13 13:13:47 echo systemd[1451]: ponde.service: Main process exited, code=exited, status=1/FAILURE
Apr 13 13:13:47 echo systemd[1451]: ponde.service: Failed with result 'exit-code'.```

I looked at a permission of /dev/uinput is not changed:

❯❯ ls -l /dev/uinput
crw-------+ 1 root root 10, 223 Apr 13 14:48 /dev/uinput

I tried to run ponde with sudo, ponde works well:

❯❯ sudo ~/.cargo/bin/ponde ~/.config/ponde/config.yaml
grab matched device: event8 (Kensington Expert Wireless TB Mouse)
grab matched device: event21 (- GameBall)

Then, the uinput permissions change:

❯❯ ls -l /dev/uinput
crw-rw----+ 1 root input 10, 223 Apr 13 14:48 /dev/uinput

After that, it work without using sudo:

❯❯ systemctl restart --user ponde.service
Apr 13 23:58:31 echo systemd[1451]: Started Pointing device configurationd daemon.
Apr 13 23:58:31 echo ponde[52619]: grab matched device: event8 (Kensington Expert Wireless TB Mouse)
Apr 13 23:58:31 echo ponde[52619]: grab matched device: event21 (- GameBall)

It is very painful for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.