How-to: automatic restart klipper in docker container when printer is turned on
eirinnm opened this issue · 0 comments
eirinnm commented
Leaving this here for anyone else wondering how to do this:
- run
lsusb
to get the vendor ID and productID of your hardware. In my case it's 1d50 and 614e:
Bus 001 Device 025: ID 1d50:614e OpenMoko, Inc. stm32f103xe
- create a udev rule:
sudo nano /etc/udev/rules.d/98-klipper.rules
- put this line in that file:
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="614e", ACTION=="add", RUN+="/usr/bin/docker exec --user klippy klipper /bin/sh -c '/bin/echo RESTART > /tmp/printer'"
- reload your udev rule with
sudo udevadm control --reload
- Turn off your printer and turn it back on. The klipper service should automatically restart.
How it works: it uses docker exec to run a command inside the klipper container as user klippy (important!) which sends a RESTART command to the virtual printer device.