Skip to content

Larry57/LogiKMSwitch

Repository files navigation

LogiKMSwitch

Note: This project is experimental. It was built to address a specific need: synchronizing keyboard/mouse switching across multiple computers with Logitech multi-host devices.

If you're on Windows, PowerToys solves this problem much more elegantly with its Mouse Without Borders feature. It provides seamless keyboard and mouse sharing across up to four computers -- more efficiently than even Logitech Options/Flow, since both keyboard and mouse follow perfectly between connected machines.

LogiKMSwitch remains useful for Linux users or setups where PowerToys is not an option.

Synchronize Logitech multi-host device switching. When you switch your keyboard to another computer, your mouse follows automatically -- and vice versa.

The Problem

Logitech MX keyboards and mice both support Easy-Switch (up to 3 hosts), but there's no way to synchronize them. Switching your keyboard to another computer leaves your mouse behind.

Logitech Flow only works with a limited set of devices and requires both computers to be on the same network. LogiKMSwitch works with any Logitech device that supports HID++ 2.0 and Easy-Switch -- including older or budget models where Flow is not available.

How It Works

LogiKMSwitch communicates with Logitech devices via the HID++ 2.0 protocol over Bluetooth. It monitors the ChangeHost feature (0x1814) on each device and, when one switches, commands the other to follow.

+---------------+                    +----------------+
|   Keyboard    |<---- HID++ 2.0 --->|                |
|   (MX Keys)   |                    |  LogiKMSwitch  |
+---------------+                    |                |
+---------------+                    |  Detects       |
|     Mouse     |<---- HID++ 2.0 --->|  switches &    |
| (MX Anywhere) |                    |  syncs both    |
+---------------+                    +----------------+

An instance of LogiKMSwitch must run on each computer for round-trip synchronization:

  • When device A switches to Computer 2, the instance on Computer 1 detects it and commands device B to follow.
  • When you switch back, the instance on Computer 2 handles the reverse.

Features

  • Automatic device sync -- keyboard switch triggers mouse follow (and vice versa)
  • System tray icon with status display
  • Settings UI (native window on Windows, TUI on Linux)
  • CLI configuration overrides
  • Cross-platform (Windows + Linux)

Supported Devices

Any Logitech device with HID++ 2.0 and the ChangeHost feature (0x1814), including:

  • Keyboards: MX Keys, MX Keys S, MX Keys Solar+, K380, K780, Craft, Ergo K860...
  • Mice: MX Master series, MX Anywhere series, Lift, Pebble, M720, M750...

Tested with MX Keys Solar+ and MX Anywhere 2 over Bluetooth.

Installation

Pre-built Binaries

Download the latest release from the Releases page.

Windows:

  1. Download LogiKMSwitch-windows-x64-vX.Y.Z.zip
  2. Extract the archive
  3. Run logikmswitch.exe

Linux:

  1. Download LogiKMSwitch-linux-x64-vX.Y.Z.tar.gz
  2. Extract: tar xzf LogiKMSwitch-linux-x64-*.tar.gz
  3. Run ./logikmswitch

Build from Source

Requires the Rust toolchain.

Windows:

cargo build --release

Binary at target/release/logikmswitch.exe.

Linux:

sudo apt-get install libudev-dev libgtk-3-dev libappindicator3-dev
cargo build --release

Binary at target/release/logikmswitch.

Linux Setup

Udev Rules (Required)

LogiKMSwitch needs access to Logitech HID devices. Without udev rules, you would need to run as root.

sudo cp 99-logikmswitch.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

Log out and back in for the uaccess changes to take effect.

The udev rule grants access to all Logitech HID devices (vendor ID 046d) for the logged-in user.

Usage

Run the binary -- a tray icon appears in the notification area showing the current sync status. Right-click the tray icon for options including Settings and Quit.

Settings

Open settings via:

  • Right-click tray icon -> Settings
  • Run with --settings flag

CLI Flags

Flag Description
--poll-interval <MS> Polling interval in milliseconds (default: 50)
--break-delay <MS> Break-after-switch delay in milliseconds (default: 500)
--device <PID> Monitor specific device by product ID (hex, e.g., B34E)
--console Enable logging output
--config <PATH> Custom config file path
--list-devices List connected Logitech HID++ devices and exit
--settings Open settings UI

Examples

# List connected devices
logikmswitch --list-devices

# Run with logging enabled
logikmswitch --console

# Monitor a specific device only
logikmswitch --device B34E

# Use a custom config file
logikmswitch --config /path/to/config.toml

Configuration

LogiKMSwitch uses a TOML config file at ~/.LogiKMSwitch/config.toml (auto-created on first run).

# Start with sync enabled
sync_enabled = true

# Polling interval in ms (lower = more responsive, higher = less CPU)
poll_interval_ms = 50

# Break-after-switch delay in ms (pause before allowing the next switch)
break_after_switch_ms = 500

CLI flags override config file values. See config.example.toml for a full example including device filtering.

Support the Project

LogiKMSwitch is free and open source. If you find it useful, consider supporting development:

Technical Details

  • Protocol: HID++ 2.0 over Bluetooth (long reports, 20 bytes, report ID 0x11)
  • HID interface: Usage page 0xFF43 (vendor-specific, supports read+write on BLE)
  • Feature discovery: Root feature (0x0000) resolves ChangeHost (0x1814) to its runtime index
  • Architecture: Per-device reader threads with command channels, break-after-switch debounce
  • Cross-platform: Built with the hidapi crate -- Windows and Linux compatible
  • Tray icon: tray-icon + winit on Windows, GTK on Linux

License

MIT License -- see LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages