$ show feschber/lan-mouse
Lan Mouse is a cross-platform software KVM switch that enables sharing a single mouse and keyboard across multiple computers on a local network, inspired by Apple's Universal Control. It is implemented as a Rust daemon with a GTK4/Libadwaita GUI frontend and a CLI interface, supporting Linux (Wayland, X11), macOS, and Windows. Communication between peers uses DTLS/TLS encryption with self-signed certificate fingerprint authentication over UDP/TCP. Input capture and emulation are abstracted via traits with platform-specific backends (libei, layer-shell, X11, CoreGraphics, Windows input APIs), and client discovery relies on mDNS/DNS. The architecture features a central service orchestrator managing capture, emulation, state, and IPC with the frontend over Unix sockets (or TCP on Windows). The codebase demonstrates solid Rust practices, async patterns with Tokio, and clean trait design for platform abstraction. While functionally complete, there are known caveats around compositor support, scancode mappings, and some memory leaks, reflecting ongoing development effort.
The LLM identified 3 files worth highlighting for reuse:
Provides a comprehensive mapping between Linux and Windows scancodes for keyboard events. Defines platform-specific enums (LinuxEvdevScancode, WindowsSetKey) and conversion functions. This component is isolated, handles platform translation logic, and could be reused in any project needing keyboard scancode normalization across operating systems.
Defines a compact binary protocol (ProtoEvent) for peer-to-peer communication with custom encode/decode macros. The event types cover pointer and keyboard actions. This crate is self-contained, uses TryFrom/Into for conversion, and can be extracted for other network-based input sharing projects.
Implements ClientManager using a slab allocator for O(1) client ID allocation and lookup. Manages client state (address, connection ID, hooks) with shared mutability (Rc<RefCell<Slab>>). While coupled to the daemon's types, the slab-based ID management pattern is a reusable technique for any service needing efficient client registries.