Skip to main content

CLI tool for KVM control — thin client for serial-hid-kvm

Project description

cli-serial-hid-kvm

CLI tool for KVM control — thin client for serial-hid-kvm.

Architecture

┌──────────┐       TCP        ┌─────────────────┐     USB/HDMI     ┌───────────┐
│  shkvm   │ ──────────────── │ serial-hid-kvm  │ ──────────────── │ Target PC │
│  (CLI)   │    port 9329     │   (server)      │   CH9329 + Cap   │           │
└──────────┘                  └─────────────────┘                  └───────────┘

The CLI connects to a running serial-hid-kvm server over TCP. The server handles all hardware interaction (USB HID via CH9329 and HDMI capture). OCR is performed locally by the CLI using Tesseract.

Prerequisites

  • serial-hid-kvm server running with --headless --api (or with GUI + API enabled)
  • Tesseract OCR installed for ocr and exec commands
  • Python 3.10+

Installation

pip install cli-serial-hid-kvm

Or for development:

git clone https://github.com/sunasaji/cli-serial-hid-kvm.git
cd cli-serial-hid-kvm
pip install -e .

Quick Start

# Start the KVM server (on the machine connected to target PC)
serial-hid-kvm --headless --api

# Use shkvm from any machine that can reach the server
shkvm info                          # check connection
shkvm type "ls -la{enter}"          # type on target PC
shkvm capture -o screen.jpg         # take screenshot
shkvm ocr                           # read screen text
shkvm exec "echo hello" -w 2        # run command and read output

Command Reference

Keyboard

Command Description
shkvm type TEXT [-d MS] [-r] Type text with optional char delay. Supports inline tags: {enter}, {tab}, {ctrl+c}, {0xNN}. Whitelist-based: unknown {content} passes through literally. -r (raw mode) disables tags, \n → Enter
shkvm key KEY [-m MOD] Send single key press. -m can be repeated: -m ctrl -m shift
shkvm keys JSON [-d MS] Send key sequence from JSON array

Mouse

Command Description
shkvm move X Y [-r] Move cursor (absolute, or relative with -r)
shkvm click [-b BUTTON] [-x X] [-y Y] Click (default: left)
shkvm drag X1 Y1 X2 Y2 [-b BUTTON] Drag from start to end
shkvm scroll AMOUNT Scroll wheel (+up, -down)

Screen

Command Description
shkvm capture [-o FILE] [--base64] Save screenshot or output base64 to stdout
shkvm ocr Capture + OCR, print text to stdout
shkvm exec CMD [-w SEC] Type command, Enter, wait, then OCR

Device Management

Command Description
shkvm info Show device info (JSON)
shkvm devices List capture devices
shkvm set-device DEV Switch capture device by index or path
shkvm set-resolution W H Set capture resolution

Global Options

Option Description
-H, --host HOST KVM server host (overrides SHKVM_API_HOST)
-p, --port PORT KVM server port (overrides SHKVM_API_PORT)

Configuration

All settings can be configured via environment variables:

Variable Default Description
SHKVM_API_HOST 127.0.0.1 KVM server host
SHKVM_API_PORT 9329 KVM server port
SHKVM_OCR_CMD (auto-detect) Path to Tesseract binary
SHKVM_CAPTURE_LOG_DIR ~/.local/share/cli-serial-hid-kvm/captures Capture log directory (set to empty string to disable)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli_serial_hid_kvm-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_serial_hid_kvm-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file cli_serial_hid_kvm-0.1.0.tar.gz.

File metadata

  • Download URL: cli_serial_hid_kvm-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cli_serial_hid_kvm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b46010b0c9c36e88f28e6173c4a46c04bc0163e05510619bf96abd5aaaaa4cd
MD5 9211163346f5d909cd354edc2e786ee1
BLAKE2b-256 4993855b6b98ae7352df8f08cc5f0739a6ab6fb033e005ea26802891824a9570

See more details on using hashes here.

Provenance

The following attestation bundles were made for cli_serial_hid_kvm-0.1.0.tar.gz:

Publisher: release.yml on sunasaji/cli-serial-hid-kvm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cli_serial_hid_kvm-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cli_serial_hid_kvm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3503a583ec071c5afcc16796bea47f00ec2e11051b694e95d91ffa2d8aec1ee8
MD5 878154dc9fcda8aa5c593c48a5f63ec9
BLAKE2b-256 9efb76a6358020b81038ff0d4ed613a88bdd0a7d45d096dae47b304d0909c4aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for cli_serial_hid_kvm-0.1.0-py3-none-any.whl:

Publisher: release.yml on sunasaji/cli-serial-hid-kvm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page