Get the G-code preprocessor running in 5 minutes!
cd ~
git clone https://github.com/jwellman80/klipper-gcode-preprocessor.git
cd klipper-gcode-preprocessor
./install.shFollow the prompts:
- Answer "1" for Moonraker integration (recommended)
- Answer "1" to restart Klipper
Add to your printer.cfg:
[include gcode-preprocessor/preprocessor.cfg]Save and restart Klipper:
sudo systemctl restart klipper- Upload the included test file to Mainsail/Fluidd:
- File:
~/klipper-gcode-preprocessor/examples/test_sample.gcode
- File:
- Check the first line - it should now say:
; processed by klipper-gcode-preprocessor - Look for inserted cooldown commands:
; T1 no longer needed - cooling down M104 T1 S0
PREPROCESS_GCODE_FILE FILE=/path/to/your/file.gcodeLIST_GCODE_PROCESSORSYou should see:
- token_replacer
- unused_tool_shutdown
✅ Automatically cools down tools after their last use
- T1 used, then T2 →
M104 T1 S0inserted - Saves energy and reduces oozing
✅ Extracts metadata from slicer comments
- Tool count, colors, materials, temperatures
✅ Replaces placeholders in your macros
!tool_count!→ actual number!colors!→ hex color codes
Edit ~/printer_data/config/gcode-preprocessor/preprocessor.cfg:
# Customize unused tool shutdown
[preprocessor unused_tool_shutdown]
exclude_tools: 0 # Optional: exclude T0 from shutdown- Read full docs:
docs/README.md - Try placeholders in your macros
- Write custom processors
Files not being preprocessed?
- Check:
tail -f ~/printer_data/logs/klippy.log - Verify config is included in printer.cfg
Already preprocessed warning?
- Files are only processed once
- Re-upload to process again
Need help?
- Full documentation:
README.md - Detailed guide:
docs/README.md - GitHub Issues for bugs
Add to your START_PRINT macro:
[gcode_macro START_PRINT]
gcode:
M118 Starting print with !tool_count! tools
M118 Colors: !colors!
M118 Materials: !materials!After preprocessing, this becomes:
M118 Starting print with 3 tools
M118 Colors: ff0000,00ff00,0000ff
M118 Materials: PLA,PETG,ABSThat's it! Your G-code preprocessor is now running and automatically optimizing your prints.