The missing Klipper command line
Project description
klipper-repl
The missing Klipper command line.
klipper-repl is a command line reimplementation of the browser-based G-Code
console implemented by Klipper frontends like Fluidd
and Mainsail. Its features include:
- Automatic reconnection if Klipper restarts or is unavailable
- Scripting support
- Multiple G-Code commands per line -- use
,as a separator - Syntax highlighting for both G-Code and user-defined macros
- Tab autocompletion for user-defined macros
- M112 emergency stop processing
- Support for multiple printers via GNU Parallel
Installing
Via a Nix flake
If you have the Nix package manager, this package is
available as a Nix flake. An example
flake.nix for a host running Klipper is:
{
inputs = {
nix-doom-emacs.url = "github:unjordy/klipper-repl";
};
outputs = {
self,
nixpkgs,
klipper-repl,
...
}: {
nixosConfigurations.klipperHost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{
environment.systemPackages = [
klipper-repl.packages.${system}.default
];
}
];
};
};
}
You can also run klipper-repl without installing it using
nix run github:unjordy/klipper-repl
Via pip
pip install klipper-repl
Usage
Running interactively
Assuming klipper-repl is running on the same host you're currently logged
into, and that your Klipper API
socker is located at /run/klipper/api, you can get an interactive G-Code REPL
with:
klipper-repl /run/klipper/api
Usage in scripts
You can evaluate one line of G-Code as follows. Note that you can use the ,
character to incorporate multiple G-Code commands into one line, and that G-Code
is case-insensitive (but generally gets converted to uppercase by Klipper).
klipper-repl /run/klipper/api g28, screws_tilt_calculate
Emergency stop
Typing the command m112 into klipper-repl will immediately discard the rest
of the command buffer and send an emergency stop signal to Klipper.
Running remotely
klipper-repl doesn't provide any of its own facilities for operating on remote
systems. Instead, install klipper-repl on each of your Klipper hosts and use
ssh to run it remotely. For example, to get a remote interactive REPL:
ssh klipper@klipper-host -t klipper-repl /run/klipper/api
Note that the -t argument to ssh allocates a TTY for klipper-repl, which
it needs to properly render its prompt.
For convenience, it's recommended to create a shell function or script that runs
klipper-repl for a specific Klipper host and socket. For example:
#!/usr/bin/env bash
ssh klipper@klipper-host -t klipper-repl /run/klipper/api $@
Save this as something like klipper-host-repl and mark it executable, and you
can use it exactly like you would klipper-repl.
Sending commands to multiple printers
You can combine klipper-repl with GNU
Parallel to run G-Code commands across
multiple printers and multiple Klipper hosts. GNU Parallel is an incredibly
flexible way to run multiple commands simultaneously and I highly recommend
reading its manual, but an example of using it with klipper-repl to control
multiple printers is:
parallel klipper-repl /run/klipper/api-{} ::: printer1 printer2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file klipper_repl-0.2.0.tar.gz.
File metadata
- Download URL: klipper_repl-0.2.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/6.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36a3385e7b4d7e56eb0302d3676d752033e9d5aca88f6578bf443bb28486b0c4
|
|
| MD5 |
be7568694a930e4cc4cc72b06a0f76a9
|
|
| BLAKE2b-256 |
798beb41bc50bdb3dbcd60e13de069e63e230f1584f188ff8dc81d73bede77c8
|
File details
Details for the file klipper_repl-0.2.0-py3-none-any.whl.
File metadata
- Download URL: klipper_repl-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/6.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
635f252c13a2e9e723fb804bf6736848d69663ef879c4d28f5ca69a3809a8df8
|
|
| MD5 |
143f4980fe7542c71d69171ba2d152ed
|
|
| BLAKE2b-256 |
62b2c4329742885f53b900ffed0efe1ffd4e05eb68932a1ec738ecb9dab3e0bc
|