Trigger Python Script from Custom G-code in OctoPrint Without Modifying Marlin

Hello,

I am currently using a 3D printer running Marlin firmware, controlled via a Raspberry Pi 4B with Ubuntu and OctoPrint installed.

I would like to add a custom auxiliary command to my G-code, such as M900. When this command is encountered during printing, I hope to trigger a specific Python script to run automatically.

If I prefer not to modify Marlin's G-code processing code, is there any way to achieve this by modifying OctoPrint’s config.yaml or through another configuration method?

Thank you very much for your help!
And if I’ve posted this in the wrong place, I sincerely apologize.

This plugin should do exactly what you want.

2 Likes

The exact answer I gave to this question in Discord, which I believe is the same person...

1 Like