I have been working recently on support for an official “Klipper extension system” (aka an official “plugin” system). This has been discussed a few times before (for example, Possible Klipper "plugins" instead of macros? ).
This is still in a “proposal” and “development” state. However, I do have an initial software implementation. Klipper patches at:
And an example extension at:
This code is in a very early state. The main goal at this point is to test the high-level concepts.
There are two major goals of the extension system:
- Make it easy for users to find, install, version, and update common Klipper enhancements provided by the community.
- Define a clear programming interface between Klipper and these extensions to reduce the chance of errors. In particular, to reduce the chance of things breaking as new software updates become available.
There are two initial targets for the extension system: a) make it possible to batch up “macro config includes” into an easily deployed and versioned extension; and b) to make it possible for an extension to define new G-Code commands that are implemented in a general purpose programming language (ie, not limited to Jinja2). As time goes on, the goal will be to continue to add new API calls so that additional functionality can be implemented in an extension.
On the technical side, there are envisioned to be four major components to this proposal:
- Changes to Klipper to identify extensions and start them if requested.
- Example “extension code” so that developers can rapidly implement a new community extension.
- A new “global listing repository” that extension developers can submit their community extensions to.
- A tool to help users identify extensions available in the “global listing repository” and make it easy for them to install and/or update them. Ideally this tool will be directly available from the Klipper GUIs.
The “klipper patches” link above has initial support for the first component. A new mechanism has been added for Klipper to find and launch locally found extensions, and new API calls have been defined (see the docs/API_Server.md file). Documentation is limited at this point, as this is still a “work in progress”.
The “example extension” repo listed above is the very beginnings of the second component. More work is needed here. The current example code interacts with Klipper to append the config snippets in test_extension/config_snippet.txt
to Klipper’s main “printer.cfg” file.
The third and fourth components are still in a discussion phase. I hope to gather feedback on these components over the next several weeks.
-Kevin