MouseTouch

Multitouch gestures for the Magic Mouse
on Linux.

MouseTouch is a small userspace driver that reads the finger positions the Apple Magic Mouse already reports and replays them as touchpad gestures your desktop understands. Workspace swipes with the native animation, pinch zoom, configurable taps, and a GTK settings app. Nothing patched in the kernel or compositor.

Wayland COSMIC · GNOME · KDE · niri · Sway · Hyprland Rust daemon GTK4 / libadwaita settings MIT

Out of the box

Defaults you get right after installing. Every tap and swipe can be remapped to a shortcut, a mouse button or a command, globally or per application.

2 fingers · swipe left/right
Switch workspace
Animated, follows your fingers, settles with release velocity.
2 fingers · pinch
Native pinch zoom
In apps that support it: browsers, image and document viewers.
2 fingers · double tap
Show workspaces
Super+W on COSMIC, Super on GNOME.
3 fingers · tap
Show all applications
App library / app grid (Super+A).
1 finger · scroll & clicks
Unchanged, but cleaner
The backwards jump a scroll often starts with is filtered out.
Per application
Scoped rules
E.g. 2-finger swipes = back/forward in the browser only.

Install

Every method below installs both parts: the mousetouch driver (a per-user systemd service) and the mousetouch-settings app. The settings app is optional and needs GTK 4, libadwaita and PyGObject from your distribution.

One line, any distro

Picks the newest release, verifies the checksum, installs the .deb or .rpm where there is one and the static binary elsewhere. Needs sudo.

curl -fsSL https://raw.githubusercontent.com/Devace-93/mousetouch/main/get.sh | sh

Packages

Download the .deb for your architecture from the releases page (amd64 or arm64). It enables the user service for everyone and starts it for logged-in users. The settings app's GTK dependencies come in as Recommends.

sudo apt install ./mousetouch_<version>_amd64.deb

Download the .rpm from the releases page. Enables and starts the user service like the .deb.

sudo dnf install ./mousetouch-<version>.x86_64.rpm

Settings app dependencies on Fedora: python3-gobject gtk4 libadwaita.

Builds from the main branch. Settings app dependencies are optional: python-gobject gtk4 libadwaita.

yay -S mousetouch-git
systemctl --user enable --now mousetouch

Homebrew on Linux. The formula ships the binaries; follow the printed caveats to install the udev rule once (needs sudo), then start the service.

brew install Devace-93/tap/mousetouch
brew services start mousetouch

Imperative install into your profile:

nix profile install github:Devace-93/mousetouch

Or declaratively on NixOS, which also loads uinput, installs the udev rule and the user service:

# flake.nix inputs
mousetouch.url = "github:Devace-93/mousetouch";

# configuration.nix
imports = [ mousetouch.nixosModules.default ];
services.mousetouch.enable = true;

Binary only. Install the udev rule, modules-load file and user service from packaging/ in the repository by hand afterwards.

cargo install mousetouch

mousetouch-<version>-<arch>-linux.tar.gz from the releases page contains the static binary, the settings app and the udev/systemd/desktop files. Or let the installer do exactly that:

curl -fsSL https://raw.githubusercontent.com/Devace-93/mousetouch/main/get.sh | MOUSETOUCH_FORCE_TARBALL=1 sh

Needs a Rust toolchain. install.sh builds the release binary, installs it to /usr/local with the udev rule, modules-load file, desktop entry and settings app, and enables the per-user service.

git clone https://github.com/Devace-93/mousetouch
cd mousetouch
./install.sh

Remove it again with ./uninstall.sh (--purge also deletes the config).

Requirements

  • A Magic Mouse connected over Bluetooth (the cable only charges on Linux), bound to the in-tree hid-magicmouse module. The DKMS build works too.
  • /dev/uinput (standard) and systemd for the per-user service.
  • A Wayland compositor with libinput touchpad gestures: COSMIC, GNOME, KDE, niri, Sway, Hyprland, …
  • For the settings app: Python 3, PyGObject, GTK 4, libadwaita (python3-gi gir1.2-gtk-4.0 gir1.2-adw-1 on Debian/Ubuntu/Pop!_OS).

After installing

  1. If the mouse was already paired, re-pair it or run sudo udevadm trigger so the udev rule applies.
  2. Check the daemon: systemctl --user status mousetouch.
  3. Swipe left/right with two fingers. Done.
Methods that do not run a package hook (tarball, Homebrew, cargo) print the one-off systemctl --user enable --now mousetouch step.

Settings app

A GTK4 / libadwaita app, installed alongside the driver by every method above. Launch MouseTouch from the app menu or run it from a terminal:

mousetouch-settings

It edits ~/.config/mousetouch/config.toml, which the daemon reloads on save. No restart needed.

What you can change

  • Workspace swipe: direction, sensitivity, 3 or 4 synthetic fingers, horizontal or both axes (GNOME).
  • Pinch zoom on/off and aggressiveness.
  • One-finger scroll: notches vs smooth, speed, start-direction filter.
  • Tap timing and lift-speed detection.
  • Rules: tap / double tap / swipe × fingers → key combo, mouse button, command, toggle or cycle, optionally only for one application.
Prefer a text editor? The config file is plain TOML with comments. See the configuration reference.

How it works

The Magic Mouse reports every finger on its surface, but desktops ignore that because the device is a mouse. MouseTouch bridges the gap in userspace.

1
Grab & re-emit
Takes the mouse's evdev node and re-emits motion, buttons and wheel through a virtual mouse, so everything keeps working.
2
Decode fingers
Reads finger positions from the raw HID reports (/dev/hidrawN), with an evdev multitouch fallback.
3
Replay as a touchpad
Two fingers sideways become a 4-finger touchpad swipe; spreading fingers become a pinch. The compositor runs its own animation.
4
Fire actions
Taps and discrete swipes trigger keys, buttons or commands, optionally scoped to the focused app.

Troubleshooting

mousetouch probe                 # is the mouse seen, with touch axes?
mousetouch watch                 # live finger positions
mousetouch demo-swipe left 40    # replay a synthetic 4-finger swipe
journalctl --user -fu mousetouch
SymptomCheck
No device foundMouse must be on Bluetooth and bound to hid-magicmouse.
Swipe goes the wrong wayFlip Direction in the settings app, or set touchpad natural scrolling explicitly.
Nothing happens on swipeThe desktop must handle 4-finger (or 3-finger) touchpad swipes and not disable touchpads while a mouse is connected.
Permission deniedMake sure the udev rule is installed, or add yourself to the input group.
app rules never fireRun with -v and look for "focus tracking via". GNOME exposes no toplevel protocol, so app rules never match there.

More in the README, or open an issue.