Forwarding arbitrary input devices over SSH
This repository has been archived on 2019-12-03. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2019-11-21 23:48:56 +11:00
COPYING Initial commit 2019-11-18 01:20:02 +11:00
forward.py Use unclutter to hide mouse cursor 2019-11-21 23:45:49 +11:00
README.md Update README.md 2019-11-21 23:48:56 +11:00

input-over-ssh

Mouse and keyboard forwarding over SSH, using xinput and xdotool, with relative mouse movement. A useful adjunct to VNC in situations where relative mouse movement is important, e.g. 3D video games.

Dependencies

  • Client (sending the mouse and keyboard of this device)
    • xinput – to monitor mouse and keyboard
    • unclutter from unclutter-xfixes-git – to hide cursor
  • Server (mouse and keyboard sent to this device)
    • xdotool – to send mouse and keyboard events

Configuration

In forward.py, MOUSEHOLD_X and MOUSEHOLD_Y define the location at which the mouse cursor will be centered. Each frame, the client-side cursor will be reset to this position to measure relative movement. If MOUSEHOLD_W and MOUSEHOLD_H are non-zero, a Tkinter window of the given dimensions will be drawn around that location to prevent clicks interfering with other applications.

DEVICE_MOUSE and DEVICE_KEYBOARD give the names of the keyboard and mouse devices to monitor, as shown in the output of xinput list.

Usage

To run the script, pipe the output to SSH, ensuring that Python output is unbuffered using the -u flag:

python -u forward.py | ssh hostname.example.com bash

To exit, simply press Ctrl+Q.

Combining with VNC

This setup is easily combined with VNC in view-only mode to provide a full GUI experience.

On the host, disable the CursorPosUpdates/CursorShapeUpdates VNC extensions to force the server to directly render the cursor. For x11vnc, simply pass the -nocursorpos -nocursorshape flags.

On the client, enable view-only mode to prevent conflict between the VNC client and input-over-ssh. For TigerVNC vncviewer, simply pass the ViewOnly=1 flag.

Then run input-over-ssh as usual, and you should be able to control the remote cursor. This provides a lightweight, open-source alternative to services like Steam Remote Play.