Windows-style middle-click autoscroll for Linux.
A lightweight, zero-dependency background daemon written in C that brings seamless middle-click autoscrolling to both X11 and Wayland.
Warning
Beta Release / Under Active Development
linux-mid-scroll is currently in active beta. While it runs purely in userspace and is designed with kernel-level fail-safes, hardware quirks across different laptop touchpads and mice may exist. If you encounter any issues or have feedback, please open an Issue or pull request!
- Windows-Style Click-Toggle: Click the middle button (or laptop gesture) once to anchor the cursor; move your mouse or slide your finger across the trackpad to scroll dynamically.
- Accidental Click Prevention (Click Consumption): Clicking any button or tapping the trackpad deactivates autoscroll immediately. The dismissing click is consumed so you never accidentally click links, close tabs, or move text cursors.
- Built for Both Desktop Mice & Laptop Touchpads:
- Mice: Uses standard middle click (
BTN_MIDDLE). - Touchpads / Laptops:
- Three-Finger Tap: Native Windows Precision Touchpad gesture (
BTN_TOOL_TRIPLETAP). - Left + Right Click Chord: Click left and right buttons simultaneously to toggle autoscroll (for laptop trackpads without physical middle buttons).
- Three-Finger Tap: Native Windows Precision Touchpad gesture (
- Mice: Uses standard middle click (
- High-Resolution Smooth Scrolling: Supports kernel 5.0+ high-resolution wheel events (
REL_WHEEL_HI_RES/REL_HWHEEL_HI_RES) for buttery-smooth scrolling. - Ultra-Lightweight & Efficient:
- Written in clean C11.
- Consumes 0.00% CPU while idle (sleeps on kernel hardware interrupts).
- Uses only ~30 KB to 50 KB of private RAM.
- Zero runtime dependencies beyond standard
glibcandpthreads.
- Display Server Agnostic: Operates at the kernel input subsystem layer (
evdev&uinput), working identically across X11, Wayland, GNOME, KDE Plasma, Sway, Hyprland, etc.
- Linux kernel with
/dev/uinputenabled (default on virtually all modern distributions) gccandmake- User membership in the
inputgroup (sudo usermod -aG input $USER)
git clone https://github.com/sakibreza229/linux-mid-scroll.git
cd linux-mid-scroll
makeRun directly in foreground to test with your hardware:
sudo ./build/midscroll-binInstall the binary, udev rules, and systemd service:
sudo make installEnsure your user is in the input group:
sudo usermod -aG input $USER
sudo udevadm control --reload-rules && sudo udevadm triggerLog out and back in once (to apply group membership), then enable and start the user service:
systemctl --user enable --now midscroll.serviceTo view live logs:
journalctl --user -u midscroll -fTo cleanly stop the service and remove all installed files:
systemctl --user stop midscroll.service
sudo make uninstallConfiguration follows standard precedence (lowest to highest):
Compiled defaults ~/.config/midscroll/config.conf MIDSCROLL_* Environment Variables
You can copy the provided example configuration file:
mkdir -p ~/.config/midscroll
cp midscroll.conf.example ~/.config/midscroll/config.conf| Key | Environment Variable | Default | Description |
|---|---|---|---|
DEADZONE_RADIUS |
MIDSCROLL_DEADZONE_RADIUS |
40 |
Radius in pixels around anchor before scrolling starts |
SENSITIVITY |
MIDSCROLL_SENSITIVITY |
1.0 |
Global speed multiplier |
MAX_SPEED |
MIDSCROLL_MAX_SPEED |
45 |
Maximum scroll speed cap (units/tick) |
CURVE |
MIDSCROLL_CURVE |
quadratic |
Acceleration curve: linear, quadratic, cubic, or smoothstep |
EMULATE_MIDDLE |
MIDSCROLL_EMULATE_MIDDLE |
1 |
1 = Enable 3-finger tap & Left+Right chord for laptops; 0 = physical middle button only |
AXIS_LOCK |
MIDSCROLL_AXIS_LOCK |
both |
both, vertical_only, horizontal_only, or dominant_snap |
INVERT_V |
MIDSCROLL_INVERT_V |
1 |
Vertical scroll direction (1 = normal, -1 = inverted) |
INVERT_H |
MIDSCROLL_INVERT_H |
1 |
Horizontal scroll direction (1 = normal, -1 = inverted) |
TICK_HZ |
MIDSCROLL_TICK_HZ |
60 |
Scroll injection update rate in Hz |
USE_HIRES_WHEEL |
MIDSCROLL_USE_HIRES_WHEEL |
1 |
1 = Attempt high-resolution wheel events first |
DEVICE_PATH |
MIDSCROLL_DEVICE_PATH |
"" (auto) |
Explicit path like /dev/input/event3 (skips auto-detection) |
- Device Discovery & Scoring: Automatically scans
/dev/input/event*nodes and scores pointer devices. It intelligently selects desktop mice (BTN_MIDDLE) or laptop touchpads (BTN_LEFT+BTN_TOOL_TRIPLETAP). - Exclusive Hardware Grab: Takes an exclusive grab (
EVIOCGRAB) on the physical pointer so raw middle-clicks or drag gestures aren't forwarded directly to the desktop. - Virtual Pointer Device: Creates a virtual mouse via
/dev/uinputthat re-emits standard pointer movements, clicks, and synthetic scroll events. - Anchor & Velocity Calculation: When autoscroll is activated, physical cursor coordinates freeze in place, and displacement relative to the anchor calculates scroll speed based on the selected acceleration curve.
- Kernel Fail-Safe Protection: The device grab is strictly tied to the open file descriptor in the Linux kernel. If the daemon stops, exits, or is terminated (
kill -9), the kernel immediately and automatically drops the grab and restores full native mouse control.
Contributions, feedback, and hardware reports are warmly welcomed!
- Hardware Testing: Test on various laptop trackpads (Synaptics, ELAN, ALPS, Apple) and desktop mice across different Linux distros (Arch, Debian, Ubuntu, Fedora, NixOS).
- Packaging: Help create packages for popular package managers (
AUR/PKGBUILD,.deb,.rpm,COPR, Flatpak). - Feature Ideas:
- Visual HUD / on-screen scroll anchor icon (Wayland layer-shell / X11 overlay).
- Dynamic config hot-reloading (without service restart).
- Momentum / inertia scrolling on release.
- Code Optimization: Help refine input chording and edge-case handling.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add some amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
This project is licensed under the MIT License.