RAprogramm/logi-mx

Blazing fast Logitech MX series mouse driver and configuration tool for Linux

โ˜… 8Forks 1RustGitHub โ†—Compare

README

logi-mx

CI codecov AUR version AUR votes AUR version (bin) AUR votes (bin) License: MIT REUSE Rust Version

Blazing fast Logitech MX series mouse driver and configuration tool for Linux

๐Ÿ“Š Code Coverage Graphs

Sunburst

The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.

Sunburst

Grid

Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.

Grid

Icicle

The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.

Icicle

Professional-grade, production-ready HID++ driver written in pure Rust with zero-cost abstractions.

MX Master 3S Hardware Overview

Buttons and Controls

The MX Master 3S features 7 programmable buttons and 2 scroll wheels:

Primary Buttons:

  • Left Click
  • Right Click
  • Middle Click (scroll wheel press)

Navigation Buttons:

  • Forward Button (thumb area)
  • Back Button (thumb area)

Special Function Buttons:

  • Gesture Button (thumb area) - Enables gesture-based navigation
  • Mode-Shift Button (behind scroll wheel) - Switches scroll wheel modes
  • Easy-Switch Button (bottom) - Multi-device connection switching

Scroll Wheels:

  • Main Scroll Wheel - MagSpeed electromagnetic scrolling

    • Supports ratchet mode (line-by-line) and free-spin mode
    • SmartShift automatic mode switching based on scroll speed
    • Hi-res scrolling (up to 1000 lines per second)
    • Horizontal tilt capability
  • Thumb Wheel (side) - Secondary scroll control

    • Horizontal scrolling by default
    • Customizable for volume, brightness, or other functions
    • Tactile feedback with precise control
Sensor Specifications

DPI Range: 200-8000 in 50 DPI increments

  • Default: 1000 DPI
  • Configurable up to 8000 DPI for high-precision work
  • 8K DPI optical sensor with tracking on glass surfaces
Gesture System

The Gesture Button enables directional gestures:

  • Up gesture - Configurable action
  • Down gesture - Configurable action
  • Left gesture - Configurable action (default: browser back)
  • Right gesture - Configurable action (default: browser forward)
  • Diagonal gestures - Advanced customization

Each gesture can trigger:

  • Keyboard shortcuts
  • Application switching
  • Desktop navigation
  • Custom key combinations
SmartShift Wheel Technology

Automatic ratchet-to-free-spin transition:

  • Ratchet Mode: Precise line-by-line scrolling for documents
  • Free-Spin Mode: Fast navigation through long pages
  • Auto-disengage threshold: 1-255; higher values need more scroll force to switch to free-spin mode
    • Lower values: Easier transition to free-spin
    • Higher values: More force required for free-spin
Power and Connectivity

Battery:

  • Up to 70 days on full charge
  • Quick charge: 3 hours of use from 1-minute charge
  • USB-C charging port

Connection Options:

  • Logi Bolt USB receiver
  • Bluetooth Low Energy 5.0+
  • Multi-device support (up to 3 devices)

Features

Click to expand

High Performance

  • Zero-cost abstractions
  • Async I/O with tokio
  • Minimal memory allocations

Professional Quality

  • HID++ 2.0 protocol implementation
  • Comprehensive error handling with masterror
  • 95%+ test coverage
  • Enterprise-grade reliability

Rich Functionality

  • DPI configuration (200-8000 in 50 DPI increments)
  • SmartShift auto-disengage tuning (threshold 1-255)
  • Hi-res scroll control
  • Battery monitoring with charge level
  • Gesture support (4 directions: up, down, left, right)
  • Button remapping stored in configuration (wire-level reprogramming in development)
  • Daemon with system tray integration
  • GTK4/libadwaita GUI
  • Automatic device discovery on Bolt receiver slots

Supported Devices

  • Logitech MX Master 3S (USB, Bluetooth, Bolt receiver)
  • MX Master 3S for Business

Current Implementation Status

Implemented:

  • DPI adjustment (200-8000)
  • SmartShift configuration
  • Hi-res scroll enable/disable (inversion not yet applied to hardware)
  • Battery status monitoring
  • Daemon with udev hotplug and automatic config application
  • GTK4/libadwaita GUI
  • Automatic device discovery (no hardcoded receiver slot)

Configured but not yet applied on the wire:

  • Button remapping and gestures (stored in ~/.config/logi-mx.toml; HID++ ReprogControls reprogramming is in development)
  • Hi-res scroll inversion

In Development:

  • Wire-level button reprogramming (HID++ 0x1B04)
  • Enhanced gesture system with visual feedback
  • Mode-shift button configuration
  • Per-application profiles
  • Macro recording and playback
  • UI gesture configuration interface

Planned:

  • Diagonal gesture support
  • Gesture animations and visual indicators
  • Smart Actions (multi-step workflows)
  • Application-specific button mappings
  • Profile switching per workspace
  • Cloud profile synchronization

Native vs Daemon Mode

The mouse can operate in two modes:

Native Mode (Default Linux Drivers)

When the daemon is stopped, your mouse uses the default Linux HID drivers:

  • Basic mouse movement and clicks work normally
  • Scroll wheel functions at default speed
  • No configuration or customization available

Daemon Mode (logi-mx)

When the daemon is running, you get full control:

Feature Native Mode Daemon Mode
Basic mouse movement โœ… โœ…
Button clicks โœ… โœ…
Scroll wheel โœ… โœ…
Custom DPI โŒ โœ…
SmartShift โŒ โœ…
Hi-res scrolling โŒ โœ…
Button remapping โŒ ๐Ÿšง (config stored, wire reprogramming in development)
Battery monitoring โŒ โœ…
Per-app settings โŒ ๐Ÿšง (planned)

Starting the daemon:

systemctl --user start logi-mx-daemon.service

Stopping the daemon:

systemctl --user stop logi-mx-daemon.service

When you stop the daemon, all custom settings are reset and the mouse reverts to standard Linux behavior.

Architecture

Click to expand
logi-mx/
โ”œโ”€โ”€ driver/     # Core HID++ protocol library
โ”œโ”€โ”€ daemon/     # Background service
โ”œโ”€โ”€ cli/        # Command-line interface
โ””โ”€โ”€ ui/         # GTK4/libadwaita GUI

Installation

Click to expand

Arch Linux (Recommended)

# From AUR
paru -S logi-mx
# or
yay -S logi-mx

# Add your user to input group (required for scroll speed multiplier)
sudo usermod -aG input $USER

# Enable and start daemon
systemctl --user enable --now logi-mx-daemon

# Logout and login for group changes to take effect

From crates.io

# Install Rust toolchain if needed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install binaries
cargo install logi-mx --locked

# Setup udev rules
sudo curl -o /etc/udev/rules.d/90-logi-mx.rules \
  https://raw.githubusercontent.com/RAprogramm/logi-mx/main/90-logi-mx.rules
sudo udevadm control --reload-rules && sudo udevadm trigger

# Add your user to input group (required for scroll speed multiplier)
sudo usermod -aG input $USER

# Install systemd service
mkdir -p ~/.config/systemd/user
curl -o ~/.config/systemd/user/logi-mx-daemon.service \
  https://raw.githubusercontent.com/RAprogramm/logi-mx/main/logi-mx-daemon.service
systemctl --user enable --now logi-mx-daemon

# Logout and login for group changes to take effect

From Source

git clone https://github.com/RAprogramm/logi-mx
cd logi-mx

# Build release
cargo build --release

# Install binaries
cargo install --path cli --locked
cargo install --path daemon --locked
cargo install --path ui --locked

# Setup udev rules and permissions
sudo cp 90-logi-mx.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

# Add your user to input group (required for scroll speed multiplier)
sudo usermod -aG input $USER

# Install systemd service
mkdir -p ~/.config/systemd/user
cp logi-mx-daemon.service ~/.config/systemd/user/
systemctl --user enable --now logi-mx-daemon

# Logout and login for group changes to take effect

Dependencies

Arch Linux:

sudo pacman -S rust hidapi systemd gtk4 libadwaita dbus

Ubuntu/Debian:

sudo apt install cargo libhidapi-dev libudev-dev libgtk-4-dev libadwaita-1-dev libdbus-1-dev

Hyprland Configuration

For Hyprland users, add these window rules to ~/.config/hypr/hyprland.conf for optimal UI experience:

# Logitech MX Master 3S Configuration Window
windowrulev2 = float, title:(Logitech MX Master 3S)
windowrulev2 = center, title:(Logitech MX Master 3S)

Reload Hyprland config:

hyprctl reload

Usage

Click to expand

CLI

# Get device info
logi-mx info

# Set DPI
logi-mx set dpi 1600

# Configure SmartShift
logi-mx set smartshift --enabled --threshold 20

# Enable hi-res scroll
logi-mx set hires --enabled

# Get battery status
logi-mx battery

Configuration File

Location: ~/.config/logi-mx.toml

[[devices]]
name = "MX Master 3S"
dpi = 1000

[devices.smartshift]
enabled = true
threshold = 20

[devices.hiresscroll]
enabled = true
inverted = false

[devices.buttons.ThumbGesture]
Gestures = [
    { direction = "Up", mode = "OnRelease", action = { Keypress = { keys = ["KEY_UP"] } } },
    { direction = "Down", mode = "OnRelease", action = { Keypress = { keys = ["KEY_DOWN"] } } },
    { direction = "Left", mode = "OnRelease", action = { Keypress = { keys = ["KEY_LEFTCTRL", "KEY_LEFT"] } } },
    { direction = "Right", mode = "OnRelease", action = { Keypress = { keys = ["KEY_LEFTCTRL", "KEY_RIGHT"] } } },
]

Note: button and gesture entries are loaded and stored by the daemon, but wire-level reprogramming (HID++ 0x1B04) is still in development.

HID++ Protocol

Click to expand

This driver implements the Logitech HID++ 2.0 protocol:

  • Packet Types: Short (7 bytes), Long (20 bytes)
  • Feature Discovery: Dynamic feature table querying
  • Error Handling: Comprehensive error mapping with retry logic
  • Device Communication: Async I/O with timeout support

Key Features Implemented

Feature ID Name Description
0x0000 Root Protocol version, feature discovery
0x0005 Device Name Get device name
0x1000 Battery Status Legacy battery info
0x1004 Unified Battery Modern battery interface
0x2201 Adjustable DPI Sensor DPI control
0x2110 SmartShift Ratchet/free-spin control
0x2121 Hi-Res Wheel High-resolution scrolling

Acknowledgments

Click to expand
  • Logitech for HID++ protocol documentation
  • Solaar project for protocol insights
  • logiops for feature reference

Contributors

RAprogrammdependabot[bot]github-actions[bot]

Issues