Alsan / libinput-gestures-macos

A libinput sidecar to emulate macOS touchpad gestures.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libinput-gestures-macos

Emulates macOS-style swipes for forward and backward.

On Linux, libinput will normally interpret this as horizontal scrolling, which isn't wrong, but if you're like me, the muscle memory to switch from two fingers to three fingers can be hard. This program will track horizontal scrolling activity and calculate the velocity of the scrolling event, triggering actions when it quantifies the scrolling as a full-fledged swipe.

warning

This program is very rough, totally hard-coded, and is designed purely (right now) to emulate macOS two-finger swipes, nothing more.

- Hard-coded to send alt+Right or alt+Left for left and right swipes, respectively. - Hard-coded to a specific nput device. (My touchpad on my particular laptop.) - Hard-coded velocity threshold. (This is likely fine for most people, though.)

Requires xdotool to actually send the commands to the OS.

Please note that, my version of this libinput-gestures-macos is based on Tobz's implementation, with some bug fix, configuration settings, refactoring.

This is my first time coding in Rust, the code might not clean and optimal enough.

tech specs

Based on the input crate to parse libinput events, and mio and tokio to asynchronously listen to the libinput data.

usage

  1. Checkout the project.
git clone https://github.com/alsan/libinput-gestures-macos
cd libinput-gestures-macos
  1. Build and run the project. (You need Rust for this.)
cargo build --release
target/release/libinput-gestures-macos
  1. Figure out which input device is your touchpad. This will be a /dev/input/eventXX device.

    For the reason of the event id will change on every reboot, we need to use the symlink generated by the system instead.

    First of all, we can find the event id by using evtest (lookup the device you want and the /dev/input/eventXX event id is listed at the left). Then use ls -lah /dev/input/by-path to find out which symlink is point to the right event id.

  2. Create a config file under $XDG_CONFIG_HOME/libinput-gestures-macos (that would be in $HOME/.config/ in most recent linux system) named config.ini, the content would be similar to the example config in example directory of the source.

  3. Switch to another window -- a browser is ideal obviously -- and you should be able to two-finger swipe to go forwards and backwards.

  4. Making this run on system boot, etc, is an exercise left to the reader.

open source

PRs welcome for any improvements. MIT license, so do whatever you want.

About

A libinput sidecar to emulate macOS touchpad gestures.

License:MIT License


Languages

Language:Rust 100.0%