Wayland-compatible keyboard and Mouse Sharing in Linux with RKVM

· 3 min read
Wayland-compatible keyboard and Mouse Sharing in Linux with RKVM

I've been a Symless Synergy user for a very long time to get keyboard and mouse to work cross-platform between Windows, Linux, and MacOS systems. Much as I have made great use of it through the years, it hasn't fully kept up with the times, having only experimental Wayland support and less than seamless operation in modern Linux distributions.

Prior to my recent switchover to Linux on both my gaming system and music system (they share the same desk), I made use of Mouse Without Borders from the Windows 11 PowerToys. However, it is not yet cross-platform.

Poking around the internet I eventually turned up RKVM, a virtual KVM written in Rust that (while it only works in Linux) monitors input events at a low level and doesn't concern itself with the display manager layer. Now that I've rid myself of Windows, RKVM fits my use case.

Host Setup

As the keyboard and mouse are attached to my gaming system, it will be the host/server in this setup. I've given it a statically-assigned IPv4 address and a local DNS name on my router to make it easy to connect to.

# Install prerequisites, assuming Ubuntu/Debian
sudo apt-get install libevdev-dev cargo clang

# Prepare repository
git clone https://github.com/htrefil/rkvm
cd rkvm
git checkout 0.6.1  # this is the latest version as of this writeup

# Build RKVM
cargo build --release

# Install RKVM binaries and systemd scripts
sudo cp target/release/rkvm-server /usr/bin/
sudo cp target/release/rkvm-certificate-gen /usr/bin/
sudo cp systemd/rkvm-server.service /usr/lib/systemd/system/

# Prepare certificates and configuration
# Be sure to change set your own values in the commands below
sudo mkdir /etc/rkvm
sudo rkvm-certificate-gen -i STATIC_IP_ADDRESS -D NUMBER_OF_DAYS /etc/rkvm/certificate.pem /etc/rkvm/key.pem
sudo cp example/server.toml /etc/rkvm/server.toml

# Lock down permissions on private files
sudo chmod o-rwx /etc/rkvm/key.pem
sudo chmod o-rwx /etc/rkvm/server.toml

You'll then need to (sudo) edit the server.toml file to include your key-combination preferences and password. For this you can use nano, vim, or your editor of choice. Make a note of the password chosen so you can set clients to use the same.

You'll also need to copy the public /etc/rkvm/certificate.pem file to a location accessible via the client system(s) such as a network share or a USB drive.

Now that your host is set up, you can enable and start its systemd service:

sudo systemctl enable rkvm-server
sudo systemctl start rkvm-server

Client Setup

Here, we'll start by creating the necessary paths and copying in the public certificate file:

sudo mkdir /etc/rkvm
sudo cp CERTIFICATE_FILE_LOCATION/certificate.pem /etc/rkvm

Next, we'll repeat the fetching and compilation steps from before and install the client files:

# Install prerequisites, assuming Ubuntu/Debian
sudo apt-get install libevdev-dev cargo clang

# Prepare repository
git clone https://github.com/htrefil/rkvm
cd rkvm
git checkout 0.6.1  # this is the latest version as of this writeup

# Build RKVM
cargo build --release

# Install RKVM binaries and systemd scripts
sudo cp target/release/rkvm-client /usr/bin/
sudo cp systemd/rkvm-client.service /usr/lib/systemd/system/

# Copy in configuration file
sudo cp example/client.toml /etc/rkvm/client.toml
sudo chmod o-rwx /etc/rkvm/client.toml

Now (sudo) edit the /etc/rkvm/client.toml file to set the server address on your LAN and the common password you defined on the server. Once that's done, we're ready to start up the client:

sudo systemctl enable rkvm-client
sudo systemctl start rkvm-client

Once that's done, you should be able to press the hotkey combination you defined on the server which should move the mouse and keyboard inputs over to the client system. If not, double-check that you've properly defined the server address, that the port isn't firewalled on the host system, and that your hotkey combination is what you believe it to be.

You can also use sudo systemctl status rkvm-server or the same for rkvm-client to check the logs for errors.

Related Articles