mouse & keyboard sharing via LAN
Lan Mouse is a cross-platform mouse and keyboard sharing software similar to universal-control on Apple devices. It allows for using multiple PCs via a single set of mouse and keyboard. This is also known as a Software KVM switch.
Goal of this project is to be an open-source alternative to proprietary tools like Synergy 2/3, Share Mouse and other open source tools like Deskflow or Input Leap (Synergy fork).
Focus lies on performance, ease of use and a maintainable implementation that can be expanded to support additional backends for e.g. Android, iOS, ... in the future.
blazingly fast™ because it's written in rust.
Lan Mouse encrypts all network traffic using the DTLS implementation provided by WebRTC.rs. There are currently no mitigations in place for timing side-channel attacks.
Most current desktop environments and operating systems are fully supported, this includes
[!Important]
X11 currently only has support for input emulation, i.e. can only be used on the receiving end.
Sway / wlroots: Wlroots based compositors without libei support on the receiving end currently do not handle modifier events on the client side. This results in CTRL / SHIFT / ALT / SUPER keys not working with a sending device that is NOT using the
layer-shellbackendWayfire: If you are using Wayfire, make sure to use a recent version (must be newer than October 23rd) and add
shortcuts-inhibitto the list of plugins in your wayfire config! Otherwise input capture will not work.Windows: The mouse cursor will be invisible when sending input to a Windows system if there is no real mouse connected to the machine.
For more detailed information about os support see Detailed OS Support
A proof of concept for an Android / IOS Application by rohitsangwan01 can be found here. It can be used as a remote control for any device supported by Lan Mouse.
Lan Mouse can be installed from the official repositories:
pacman -S lan-mouse
The prerelease version (following main) is available on the AUR:
paru -S lan-mouse-git
Nix (OS)After enabling Terra:
dnf install lan-mouse
MacOSxattr -rd com.apple.quarantine "Lan Mouse.app"First make sure to install the necessary dependencies.
Precompiled release binaries for Windows, MacOS and Linux are available in the releases section. For Windows, the depenedencies are included in the .zip file, for other operating systems see Installing Dependencies.
Alternatively, the lan-mouse binary can be compiled from source (see below).
…
Instead of downloading from the releases, the lan-mouse binary
can be easily compiled via cargo or nix:
# compile in release mode
cargo build --release
# install lan-mouse
sudo cp target/release/lan-mouse /usr/local/bin/
# will end up in ~/.cargo/bin
cargo install lan-mouse
# you can find the executable in result/bin/lan-mouse
nix-build
Support for other platforms is omitted automatically based on the active rust toolchain.
Additionally, available backends and frontends can be configured manually via cargo features.
E.g. if only support for sway is needed, the following command produces
an executable with support for only the layer-shell capture backend
and wlroots emulation backend:
cargo build --no-default-features --features layer_shell_capture,wlroots_emulation
For a detailed list of available features, checkout the Cargo.toml
This repository includes a local git hooks directory .githooks/ with a pre-commit script that enforces formatting, lints, and tests before allowing a commit. It is optional to enable it, but it will prevent you from committing code with failing unit tests or that needs clippy/fmt fixes. To enable the hook locally:
chmod +x .githooks/pre-commit
git config core.hooksPath .githooks
The pre-commit script runs cargo fmt --all (and fails if files were modified), cargo clippy --workspace --all-targets --all-features -- -D warnings, and cargo test --workspace --all-features.
# Install dependencies
brew install libadwaita pkg-config imagemagick
cargo install cargo-bundle
# Create the macOS icon file
scripts/makeicns.sh
# Create the .app bundle
cargo bundle
# Copy all dynamic libraries into the bundle, and update the bundle to find them there
scripts/copy-macos-dylib.sh
Ubuntu and derivativessudo apt install libadwaita-1-dev libgtk-4-dev libx11-dev libxtst-dev
Arch and derivativessudo pacman -S libadwaita gtk libx11 libxtst
Fedora and derivativessudo dnf install libadwaita-devel libXtst-devel libX11-devel
Nixnix-shell .
Nix (flake)nix develop
WindowsFirst install Rust.
Then follow the instructions at gtk-rs.org
TLDR:
Build gtk from source
# install chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# install gvsbuild dependencies
choco install python git msys2 visualstudio2022-workload-vctools
# install gvsbuild with python
python -m pip install --user pipx
python -m pipx ensurepath
pipx install gvsbuild
# build gtk + libadwaita
gvsbuild build gtk4 libadwaita librsvg adwaita-icon-theme
C:\gtk-build\gtk\x64\release\bin
to the PATH environment variable. Otherwise the project will fail to build.To avoid building GTK from source, it is possible to disable the gtk frontend (see conditional compilation).
By default the gtk frontend will open when running lan-mouse.
To connect a device you want to control, simply click the Add button and enter the hostname
of the device.
On the remote device, authorize your local device for incoming traffic using the Authorize button
under the "Incoming Connections" section.
The fingerprint for authorization can be found under the general section of your local device.
It is of the form "aa:bb:cc:..."
Authorized devices can be persisted using the configuration file (see Configuration).
If the device still can not be entered, make sure you have UDP port 4242 (or the one selected) opened up in your firewall.
The cli interface can be accessed by passing cli as a commandline argument.
Use
lan-mouse cli help
to list the available commands and
lan-mouse cli <cmd> help
for information on how to use a specific command.
Daemon ModeLan Mouse can be launched in daemon mode to keep it running in the background (e.g. for use in a systemd-service).
To do so, use the daemon subcommand:
lan-mouse daemon
In order to start lan-mouse with a graphical session automatically, the systemd-service can be used:
Copy the file to ~/.config/systemd/user/ and enable the service:
cp service/lan-mouse.service ~/.config/systemd/user
systemctl --user daemon-reload
systemctl --user enable --now lan-mouse.service
[!Important] Make sure to point
ExecStart=/usr/bin/lan-mouse daemonto the actuallan-mousebinary (in case it is not under/usr/bin, e.g. when installed manually.
To automatically load clients on startup, the file $XDG_CONFIG_HOME/lan-mouse/config.toml is parsed.
$XDG_CONFIG_HOME defaults to ~/.config/.
To create this file you can copy the following example config:
[!TIP] key symbols in the release bind are named according to their names in input-event/src/scancode.rs#L172. This is bound to change
…
Where left can be either left, right, top or bottom.
In order to use a device for sending events, an input-capture backe
No open issues yet, or sync has not completed.