Coder Social home page Coder Social logo

syngesture's Introduction

Syngestures: Linux Multi-Touch Protocol Userland Daemon

syngestures is a utility providing multi-gesture support for various Linux touchpad/trackpad drivers implementing the Linux Multi-Touch Protocol, such as xf86-input-synaptics. Read more about syngesture, the impetus for its development, and how it fits into the X11/Wayland evdev/libinput ecosystem in the release announcement

Purpose and Design

syngestures is a daemon (background application) that listens for input events generated by your touchpad or trackpad and detects when multi-touch gestures are performed. It can be configured (globally or on a per-user level) to carry out user-defined actions when specific gestures are recognized (with support for unique configurations per-device if you have multiple touchpads installed).

It may be used alone or, more commonly, in conjunction with desktop environment/display server integration/driver - we recommend using it with xf86-input-synaptics under X11 for the most responsive and "natural" cursor movement and acceleration.

Dependencies

Pre-built syngesture binaries are statically compiled and have no runtime dependencies. Building syngestures from source normally creates a dependency on libevdev, which should already be installed if you're on any modern Linux distribution.

Security Considerations

Depending on your system configuration, you may need to either add a udev rule or make sure your user account is a member of a particular group in order to use syngestures without root privileges - see the "Troubleshooting" section below for details. It is not recommended to run syngestures as root or under sudo since syngestures allows running arbitrary commands in response to touch gestures.

Refer to the troubleshooting section below for more information.

Installation

Packages containing pre-built binaries for various systems are available for tagged syngestures releases and can be obtained from GitHub (see the sidebar on the right).

syngestures is written in rust and requires a working copy of the rust toolchain and a functional C compiler in order to build from source. It can be compiled and installed by checking out a copy of the source code and building with cargo, the rust package manager:

git clone https://github.com/mqudsi/syngesture.git
cd syngesture
cargo install --path .

alternatively, it may be downloaded, built, and installed directly via cargo:

cargo install syngestures

To build a version that logs events to the terminal for debugging (required for filing any issues on GitHub), you will need to use cargo install syngestures --features logging (or if you've cloned the git repo, cd into the directory and use cargo install --path . --features logging instead).

Configuration

syngesture is configured via one or more TOML configuration files, a sample file is included in this repository. Configuration files may be installed at a machine level to /usr/local/etc/syngestures.toml or with multiple per-device configuration files installed to /usr/local/etc/syngestures.d/*.toml, or at a user level with a configuration file at $HOME/.config/syngestures.toml or multiple per-device configuration files installed to $HOME/.config/syngestures.d/*.toml. Multiple files are supported and concatenated, with user configuration files for the same input device overriding system configuration files w/ the same path.

Note that if you are running syngestures as a system service or as root, you can only use the global configuration paths (not the ones starting with $HOME).

The basic format of the configuration file is as follows, with a [[device]] node per input device implementing the MT protocol:

[[device]]
device = "/dev/input/by-path/pci-0000:00:15.0-platform-i2c_designware.0-event-mouse"
gestures = [
	# Navigate next
	{ type = "swipe", direction = "right", fingers = 3, execute = "xdotool key alt+Right" },
	# Navigate previous
	{ type = "swipe", direction = "left", fingers = 3, execute = "xdotool key alt+Left" },
	# Next desktop/workspace
	{ type = "swipe", direction = "right", fingers = 4, execute = "xdotool key Super_L+Right" },
	# Previous desktop/workspace
	{ type = "swipe", direction = "left", fingers = 4, execute = "xdotool key Super_L+Left" },
]

The value of device should be a stable path to your touchpad, it can often be found by looking at the output of dmesg. Wayland users may substitute the usage of xdotool for whatever alternative supports their display server/compositor/window manager.

The value of each gesture's type may be either swipe or tap; a numeric fingers parameter from 1 to 5 is required in both cases, but an additional direction (being one of right, left, up, or down) is required in case of swipe.

Troubleshooting

If you get an error like the following when using syngestures (the path to the device depends on the path you've set up in syngestures.toml):

/dev/input/by-path/pci-0000:00:15.0-platform-i2c_designware.0-event-mouse: Permission denied (os error 13)

then your account does not have sufficient privileges to open the input device and listen for events. Running syngestures as root (sudo syngestures) avoids this error but is not a recommended solution as syngestures can run arbitrary commands in response to gestures, and you certainly don't want those to run with root privileges.

Typically working around this correctly is as easy as adding your account to the input group and rebooting, but we can find out for sure by figuring out which group owns the input device (the touchpad).

Start by using realpath against the path of the device in your syngestures.toml or from the error message, e.g. from the error message above:

$ realpath /dev/input/by-path/pci-0000:00:15.0-platform-i2c_designware.0-event-mouse
/dev/input/event4

As you can see from the output, in this case our /dev/input/by-path/... device is actually a symlink to another device, so /dev/input/event4 is the actual path we need to check ownership for. We'll use ls -al to find out who actually owns it:

$ ls -al /dev/input/event4
crw-rw---- 1 root input 13, 68 Feb 11 16:16 /dev/input/event4

(You can do this in one go with ls -al $(realpath <original path>) instead, if you prefer.)

Here the third column is the owning user (root) and the fourth column is the owning group (input) - what we were looking for. We need to add our account to this group to give us permission to open the input device and listen for gestures, replacing input in the code below with the owning group from your ls -al output if it's something different:

$ sudo usermod -aG input $(whoami)

You must reboot before this change will take effect. You can then try running syngestures again and see what happens.

License

syngestures is developed and maintained by Mahmoud Al-Qudsi and released as open source under the MIT license, Copyright Mahmoud Al-Qudsi (c) 2020-2023.

syngesture's People

Contributors

mqudsi avatar pckilgore avatar

Stargazers

脏寒 avatar  avatar Austin Sherron avatar Nikit Singh avatar Chuck Lantz avatar Sergio Mattei avatar Daniel Cestari avatar João Pinto avatar Matti1733 avatar  avatar  avatar stib avatar Kamil avatar Since™️  avatar  avatar  avatar Evgeny avatar Drew Peterson avatar Mon avatar Oliver avatar  avatar  avatar  avatar Santiago Fraire Willemoes avatar  avatar Ron Wolf avatar join "eyes on Rafah" avatar Colin Allen avatar Jaremy Creechley avatar Code. avatar Chenye Zhou avatar Yesterday17 avatar 3BD avatar Stefan avatar Joe Downs avatar Saheed Adeleye avatar Petros Kataras avatar Daniel Papp avatar Lyoneel avatar Taalaybek Eshenov avatar GAURAV avatar Radek Maciaszek avatar Adan Alvarado avatar Mouad Boulahdoud avatar Jesse Boyer  avatar Korjavin Ivan avatar iogrt avatar Keith Yemelianovskyi avatar Timoyoungster avatar Borber avatar David Hilton avatar Marc Partensky avatar HE HUA avatar  avatar  avatar  avatar Meriç Aşkın avatar Zeyu Jiang avatar Code_PhantomPain avatar  avatar Vladimir Zorin avatar Sandorex avatar 吴天铭 avatar hackartist avatar Kevin Kuriakose avatar tdrobbin avatar  avatar Lindsey Esch avatar Deepak Cherian avatar  avatar Roman Volosatovs avatar 爱可可-爱生活 avatar  avatar Pavlos avatar inci avatar Yevhen Ts. avatar Raphaël Thériault avatar Read Sprabery avatar  avatar David Wood avatar Wyoming avatar Nathanael McDaniel avatar Brad Lugo avatar Bendeguz Seres avatar  avatar Andrew Kaiser avatar yofri avatar Tamim Arafat avatar James MacKinnon avatar [account locked] avatar Jacob Mischka avatar Mark Mulder avatar Joe George avatar Tristan de Cacqueray avatar Renato Schmidt avatar Dejan Ranisavljevic avatar seclorum avatar  avatar Peter avatar Arvin Foroutan avatar

Watchers

Abhik Khanra avatar  avatar Caleb Hyde avatar  avatar 3y6uz avatar begin-theadventure avatar

syngesture's Issues

How to set the sticky bit on evtest

Hi,
Not an issue, more of a call for support :)
I'm trying to make syngestures work on Ubuntu 20.10 but I'm stuck at the evtest sticky bit part: could you precise what command do I need to run to set it? I thought you could only set it on a file, what would be the path to the evtest executable then?
Thanks a lot for your help!

Magic Mouse 1 support?

Can it work with Apple Magic Mouse 1? I tried to install it on ubuntu 22.10, but got this:

# ./syngestures 
thread '<unnamed>' panicked at 'index out of bounds: the len is 5 but the index is 7', /home/andrey/.cargo/registry/src/github.com-1ecc6299db9ec823/syngestures-1.0.1/src/events.rs:304:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', /home/andrey/.cargo/registry/src/github.com-1ecc6299db9ec823/syngestures-1.0.1/src/main.rs:154:23

Maybe it was wrong to use /dev/input/event9 as a device, but it's the only thing in /dev/input which corresponds to this mouse.

Thank You

Seriously thank you so much. Coming from a sway user this is amazing, and the fact its rusty is the proverbial cherry on top of the best cake ever.

SUID bit documentation

I'm not a os guru but did you mean SUID bit on evtest, e.g., chmod u+s not the sticky bit chmod +t?

The latter works, the former does not (and sorta makes sense that it doesn't to me).

Also, minor thing since the executed commands appear arbitrary, but xdotool was an additional dependency requirement for me just testing the out of the box config.

Other than that, this worked really well! Thanks!

can't add permanent configuration

  • Firstly I want to thank you, this is the only gestures software that worked on my laptop, I tried libinput-gestures, touchegg, fusuma with libinput drivers but none of these worked.

How to add a fixed event

  • each time I restart my laptop I find that syngestures is not working, even though a process is running in the background.
  • The problem is the device=path, this is my configuration file:
[[device]]
device = "/dev/input/event25"
<SNIP>
  • every time the laptop restarts the event number of the touchpad changes, so I changed it to /dev/input/event* but this error happens
    image

evtest: No such file or directory

Trying to use this on a GalliumOS (based on XUbuntu).

When I run:
syngestures
I get:
evtest: No such file or directory

Although, I have evtest installed with apt

which evtest
/usr/bin/evtest

Also noting that evtest runs on my system just fine.

evtest is also accessible from the root user, running syngestures as root does not help.

Any ideas?
Thanks,
Justin

Finetune sensitivity and treshold

I am wondering if, and how, we could finetune sensitivity and treshold of the gestures?
I am using this lib for the one and only purpose to bring two finger gestures (history back and forward) into gnome.

For some reason all other developers insist it is "impossible" to detect a horizontal two-finger gesture, however your implementation clearly proves otherwise, which is why I use it.

However, it is uncontrollable :D

  • it navigates back and forward way too fast, and uncontrollably (because the treshold is so little)
  • there are no finetune options in the config, as opposed to fusuma or just generally synaptics, which I am otherwise used to, and using actively along this very repo here.

Can you let me know if it is possible to finetune geseture treshold and sensitivity just for the gestures implemented in the syngestures?

My config is very simple as I need just the two finger swipes, the rest I do in fusuma (and synaptics):

##
# Part of a full "MacOS on Gnome X experience setting"
# Here we control only two finger gestures (navigation back and forward)
# Requires syngestures https://github.com/mqudsi/syngesture/
#
# Other settings and controls done with:
# Fusuma https://github.com/iberianpig/fusuma, xdotool
# libinput-three-finger-gestures https://github.com/marsqing/libinput-three-finger-drag
# synaptics https://wiki.archlinux.org/title/Touchpad_Synaptics
# Kinto https://github.com/rbreaves/kinto
# Xorg
##
[[device]]
device = "/dev/input/by-path/pci-0000:04:00.1-usb-0:5:1.2-event-mouse"# Edit as required
gestures = [
	# Navigate next
	{ type = "swipe", direction = "right", fingers = 2, execute = "xdotool key alt+Left" },
	# Navigate previous
	{ type = "swipe", direction = "left", fingers = 2, execute = "xdotool key alt+Right" },
]

It would be daft to have something like treshold and even acceleration settings for each of the commands.

Lowering/changing sensitivity

I'm finding this is causing unwanted gestures in some cases - e.g. I have two-finger back/forward configured, but I also use two finger scrolling; it frequently triggers a back or forward action when I finish my scroll action. I'm not sure how much of this is syngesture's responsibility vs one of the lower level systems. Any pointers to where I can tweak this behaviour?

Great program by the way!

Remove evtest dependency

As part of the initial proof-of-concept, I opted into using evtest (directly installable at least on Debian/Ubuntu/etc via apt install evtest) to read the input events coming out of the touchpad's libevdev device and parse the output.

In the name of reducing dependencies and minimizing friction for adoption, we should switch to directly opening the touchpad /dev/whatever device node and reading the input events directly rather than spawning an evtest instance and parsing the results. This would presumably additionally bring down the already virtually nil CPU usage by removing the regex matching that takes place when a gesture is in progress.

The value of device should be a stable path to your touchpad

I appreciate what you are doing. I am a non-technical person. After using libinput, I switched back to synaptics driver. And you are the only one working on and publishing software to give gestures support to synaptics. However I am having difficulty figuring out "The value of device should be a stable path to your touchpad". Can you make "Syngesture" recognize automatically 'the value of device". I understand it is too much of an ask, erstwhile hoping you could find a way to do it.

Shantanu

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.