Hi!
As I have DIYed three different print heads (single hotend, dual hotend, laser head), I wanted to share my setup of switching between three different printer configurations.
Basically, I use hierarchical includes: GantryXYZ with most sensors (called common.cfg
), a printer-common.cfg
which describes heaters, and three top-level files printer_single.cfg
, printer_multi.cfg
and lasercutter.cfg
(all located in a git repo at /home/octoprint/klipper-config/
)
These call the “lower” config files.
Additionally, I changed the systemd service file to load a generic config file called /etc/systemd/system/klipper@.service
:
#Systemd service file for klipper
[Unit]
Description=Starts klipper on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=octoprint
RemainAfterExit=yes
ExecStart=/home/octoprint/klippy-env/bin/python /home/octoprint/klipper/klippy/klippy.py /home/octoprint/klipper-config/%I.cfg -l /tmp/klippy.log
Notice the keyword @
(and its substitution %I
in the file).
So to start klipper with my (default) config file printer_single.cfg
, I can call it with systemd by the command sudo systemctl klipper@printer_single
.
If I want to switch to, e.g., the laser module, I stop the running service: sudo systemctl stop klipper@*
and start it with sudo systemctl klipper@laser
.
If you want to have a default startup config, you register it via sudo systemctl enable klipper@[your-default-config-file]
.
Keep in mind, that if you still have the regular klipper service file, you need to disable and/or delete the old one: sudo systemctl disable klipper
If you run Octoprint, you can also incorporate these system level commands into Octoprints Action-Command, by adding these:
The referenced shell files are simple:
/home/octoprint/start_laser.sh
:
#!/bin/bash
sudo systemctl stop klipper@*
sudo systemctl start klipper@lasercutter
Also, back in klippers config files, you can use these action commands in your menu to switch between these configs back and forth:
/home/octoprint/klipper-config/etc/menu.cfg
:
[menu __main __octoprint __tomulti]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Switch to Multiextruder
gcode:
{action_respond_info('action:switchtomulti')}
[menu __main __octoprint __tolaser]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Switch to Laser mode
gcode:
{action_respond_info('action:switchtolaser')}