| Crates.io | jetkvm_client |
| lib.rs | jetkvm_client |
| version | 1.0.0 |
| created_at | 2025-10-15 08:05:11.588589+00 |
| updated_at | 2025-10-17 22:06:54.524278+00 |
| description | A client for JetKVM over WebRTC. |
| homepage | https://github.com/nilp0inter/jetkvm_client |
| repository | https://github.com/nilp0inter/jetkvm_client |
| max_upload_size | |
| id | 1883887 |
| size | 326,727 |
jetkvm_client is a Rust client library for interacting with JetKVM devices using WebRTC and JSON‑RPC. It provides functionality to authenticate with a JetKVM device, set up a WebRTC PeerConnection with a DataChannel, and send various input events (keyboard and mouse) as well as receive notifications (such as screen resolution updates) from the device.
This is a fork of the original jetkvm_control by David Horner. Thank you for your work!
The goal of this library is to be able to do programatically whatever a jetkvm user can do via the web interface.
Install via cargo
cargo install jetkvm_client
Clone the Repository
git clone https://github.com/nilp0inter/jetkvm_client.git
cd jetkvm_client
Running the Project You can build and run the project with Cargo:
cargo run -- -H 192.168.1.100 -P mypassword
The jetkvm_client executable provides a powerful command-line interface for interacting with your JetKVM device. It uses a subcommand-based system, and you can chain multiple commands together in a single execution, similar to xdotool.
All output is a JSON Lines stream, where each line is a JSON object representing the result of a command. This makes it easy to parse the output in scripts.
jetkvm_client [GLOBAL_OPTIONS] COMMAND_1 [ARGS] COMMAND_2 [ARGS] ...
These options control the connection to the JetKVM device and must be provided before any commands.
-H, --host <HOST>: The host address of the JetKVM device.-P, --password <PASSWORD>: The password for authentication.-p, --port <PORT>: The port number to use (default: 80).-a, --api <API>: The API endpoint (default: /webrtc/session).-v, --verbose: Enable verbose logging.Get the device ID:
cargo run -- -H 10.4.1.194 -P password get-device-id
Output:
{"result":"JTD22510012"}
Chain multiple commands:
This example gets the device ID and then sends a ping.
cargo run -- -H 10.4.1.194 -P password get-device-id ping
Output:
{"result":"JTD22510012"}
{"result":{"jsonrpc":"2.0","result":{},"id":1}}
Send text to the remote machine:
cargo run -- -H 10.4.1.194 -P password sendtext "Hello, JetKVM!"
Output:
{"result":{"status":"ok"}}
The api is subject to change. This project adheres to the "Semantic Versioning" standard.
example code for rust:
let config = JetKvmConfig {
host: "192.168.1.100".to_string(),
port: "80".to_string(),
api: "/webrtc/session".to_string(),
password: "mypassword".to_string(),
ca_cert_path: "cert.pem".to_string(),
no_auto_logout: false,
};
let mut client = JetKvmRpcClient::new(config);
if let Err(err) = client.connect().await {
error!("Failed to connect to RPC server: {:?}", err);
std::process::exit(1);
}
// open notepad and say Hello World, copy and paste.
send_windows_key(&client).await.ok();
sleep(Duration::from_millis(100)).await;
rpc_sendtext(&client, "notepad").await.ok();
sleep(Duration::from_millis(100)).await;
send_return(&client).await.ok();
sleep(Duration::from_millis(100)).await;
rpc_sendtext(&client, "Hello World").await.ok();
sleep(Duration::from_millis(100)).await;
send_ctrl_a(&client).await.ok();
sleep(Duration::from_millis(100)).await;
send_ctrl_x(&client).await.ok();
sleep(Duration::from_millis(100)).await;
send_ctrl_v(&client).await.ok();
sleep(Duration::from_millis(100)).await;
send_return(&client).await.ok();
sleep(Duration::from_millis(100)).await;
send_ctrl_v(&client).await.ok();
This project is licensed under the MIT License. See LICENSE for details.
Contributions are welcome! Please submit a pull request or open an issue to discuss changes.
The library now supports capturing screenshots from the WebRTC video stream:
# Capture a screenshot (uses default or detected resolution)
jetkvm_client -H 192.168.1.100:80 -P mypassword screenshot --output screenshot.png
# Capture with specific resolution
jetkvm_client -H 192.168.1.100:80 -P mypassword screenshot --output screenshot.png --width 1920 --height 1080
# Run the screenshot example
cargo run --example screenshot -- 192.168.1.100:80 mypassword screenshot.png
use jetkvm_client::jetkvm_rpc_client::{JetKvmRpcClient, SignalingMethod};
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut client = JetKvmRpcClient::new(
"192.168.1.100:80".to_string(),
"mypassword".to_string(),
"/webrtc/session".to_string(),
false,
SignalingMethod::Auto,
);
client.connect().await?;
client.wait_for_channel_open().await?;
// Wait for video track to be established
sleep(Duration::from_secs(2)).await;
// Capture screenshot
let (width, height) = {
let size = client.screen_size.lock().await;
size.unwrap_or((1920, 1080))
};
client.video_capture
.save_screenshot_as_png("screenshot.png", width, height)
.await?;
client.shutdown().await;
Ok(())
}
The screenshot functionality works by:
The video feed is received through WebRTC's media stream, similar to how the TypeScript web client displays video.