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
Metadata
Release files for klipper-repl 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| klipper_repl-0.2.0.tar.gz | 5.3 kB | Without provenance | Details for klipper_repl-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| klipper_repl-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for klipper_repl-0.2.0-py3-none-any.whl |
Total release size: 24.3 kB
Release files / klipper_repl-0.2.0.tar.gz
| Download URL | klipper_repl-0.2.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36a3385e7b4d7e56eb0302d3676d752033e9d5aca88f6578bf443bb28486b0c4
|
|
BLAKE2b-256 checksum How to use checksums |
798beb41bc50bdb3dbcd60e13de069e63e230f1584f188ff8dc81d73bede77c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.11 Linux/6.3.0
|
Release files / klipper_repl-0.2.0-py3-none-any.whl
| Download URL | klipper_repl-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
635f252c13a2e9e723fb804bf6736848d69663ef879c4d28f5ca69a3809a8df8
|
|
BLAKE2b-256 checksum How to use checksums |
62b2c4329742885f53b900ffed0efe1ffd4e05eb68932a1ec738ecb9dab3e0bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.11 Linux/6.3.0
|
Security for klipper-repl 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.