Include after AFC, link scripts/ into the config folder

- bd_pa_spoolman.cfg renames AFC's SET_SPOOL_ID, so klipper-macros.cfg
  must be included after [include AFC/*.cfg]; the README said otherwise.
- install.sh links scripts/ as ~/printer_data/config/klipper-macros-scripts
  so the scripts can be edited in Mainsail/Fluidd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-10 15:28:52 +02:00
1 parent 9dc733b5bb
commit 179bd0991b
5 files changed
+39 -16

No files matched your search

+4 -2
View File
@@ -30,8 +30,10 @@ check runs with `motion_check: False`), iHeater chamber heater.
## Repo layout
- `macros/klipper-macros.cfg` is the only file `printer.cfg` includes; it
includes everything else. On the Pi, `macros/` is linked as
`~/printer_data/config/klipper-macros/`.
includes everything else. It must be included after `[include AFC/*.cfg]`
(a `rename_existing` of an AFC command only works if AFC loaded first).
On the Pi, `macros/` is linked as `~/printer_data/config/klipper-macros/`
and `scripts/` as `~/printer_data/config/klipper-macros-scripts/`.
- `extras/*.py` are linked into `~/klipper/klippy/extras/`.
- `scripts/` MCU firmware update scripts (printer-specific IDs).
- `tools/effective_config.py` expands the includes like Klipper and compares
+10 -5
View File
@@ -80,8 +80,9 @@ cd ~ && git clone https://mangavalk.com/mangavalk/klipper-macros.git
- links `extras/*.py` into `~/klipper/klippy/extras/` (and hides them from
Klipper's update manager),
- links `macros/` to `~/printer_data/config/klipper-macros`, so the files show
up in Mainsail/Fluidd under `klipper-macros/`,
- links `macros/` to `~/printer_data/config/klipper-macros` and `scripts/` to
`~/printer_data/config/klipper-macros-scripts`, so the files show up in
Mainsail/Fluidd and can be edited there,
- makes the shell scripts executable,
- adds this section to `moonraker.conf` (once, with a backup):
@@ -97,10 +98,14 @@ install_script: install.sh
Then:
1. In `printer.cfg`, after `[include mainsail.cfg]`:
1. In `printer.cfg`, after `[include mainsail.cfg]` **and after the AFC
includes** (`[include AFC/*.cfg]`):
```ini
[include klipper-macros/klipper-macros.cfg]
```
`bd_pa_spoolman.cfg` wraps AFC's `SET_SPOOL_ID` with `rename_existing`,
which only works when AFC is loaded first; otherwise Klipper stops with
`Existing command 'SET_SPOOL_ID' not found in gcode_macro rename`.
2. Restart the **Klipper service** (`sudo systemctl restart klipper`, or
Mainsail → services → klipper → restart). A `RESTART` or
`FIRMWARE_RESTART` does not load new or changed Python modules.
@@ -118,8 +123,8 @@ twice and the old copy may win:
- remove `[include bd_pa_afc_spoolman.cfg]` and
`[include ./blobifier/blobifier.cfg]` from `printer.cfg`,
- replace `[include ./Macros/macros.cfg]` with
`[include klipper-macros/klipper-macros.cfg]`,
- remove `[include ./Macros/macros.cfg]` and add
`[include klipper-macros/klipper-macros.cfg]` after `[include AFC/*.cfg]`,
- keep including what is not in this repo yourself, for example
`[include Macros/timelapse.cfg]` and `[include Macros/TEST_SPEED.cfg]`.
+16 -8
View File
@@ -6,7 +6,8 @@
#
# What it does (safe to run again, Moonraker runs it after every update):
# 1. links extras/*.py into ~/klipper/klippy/extras/
# 2. links macros/ to ~/printer_data/config/klipper-macros
# 2. links macros/ to ~/printer_data/config/klipper-macros and scripts/
# to ~/printer_data/config/klipper-macros-scripts (editable in the web UI)
# 3. makes the shell scripts executable
# 4. adds an [update_manager klipper-macros] section to moonraker.conf
# (once, with a backup of moonraker.conf)
@@ -21,6 +22,7 @@ KLIPPER_DIR="${KLIPPER_DIR:-$HOME/klipper}"
CONFIG_DIR="${CONFIG_DIR:-$HOME/printer_data/config}"
MOONRAKER_CONF="$CONFIG_DIR/moonraker.conf"
LINK_NAME="$CONFIG_DIR/klipper-macros"
SCRIPTS_LINK="$CONFIG_DIR/klipper-macros-scripts"
EXTRAS_DIR="$KLIPPER_DIR/klippy/extras"
ORIGIN="$(git -C "$REPO_DIR" remote get-url origin 2>/dev/null || echo "https://mangavalk.com/mangavalk/klipper-macros.git")"
@@ -36,7 +38,9 @@ if [[ ${1:-} == --uninstall ]]; then
rm "$target" && echo "removed $target"
fi
done
[[ -L $LINK_NAME ]] && rm "$LINK_NAME" && echo "removed $LINK_NAME"
for link in "$LINK_NAME" "$SCRIPTS_LINK"; do
if [[ -L $link ]]; then rm "$link" && echo "removed $link"; fi
done
echo "Remove [include klipper-macros/...] from printer.cfg and the"
echo "[update_manager klipper-macros] section from moonraker.conf yourself,"
echo "then restart the Klipper service."
@@ -61,12 +65,15 @@ if [[ -f $exclude ]]; then
done
fi
# 2. Macros
if [[ -e $LINK_NAME && ! -L $LINK_NAME ]]; then
die "$LINK_NAME exists and is not a link; move it away first"
# 2. Macros and scripts, visible and editable in Mainsail/Fluidd
for pair in "macros:$LINK_NAME" "scripts:$SCRIPTS_LINK"; do
src="$REPO_DIR/${pair%%:*}" link="${pair#*:}"
if [[ -e $link && ! -L $link ]]; then
die "$link exists and is not a link; move it away first"
fi
ln -sfn "$REPO_DIR/macros" "$LINK_NAME"
echo "linked $LINK_NAME"
ln -sfn "$src" "$link"
echo "linked $link"
done
# 3. Scripts
find "$REPO_DIR/macros" "$REPO_DIR/scripts" -name "*.sh" -exec chmod +x {} +
@@ -92,7 +99,8 @@ fi
cat <<EOF
Done. Next steps (see README.md):
1. add to printer.cfg: [include klipper-macros/klipper-macros.cfg]
1. add to printer.cfg, after [include AFC/*.cfg]:
[include klipper-macros/klipper-macros.cfg]
and remove the old includes of the same macro files
2. restart the Klipper SERVICE (not just RESTART), so the new Python
modules are loaded: sudo systemctl restart klipper
+3 -1
View File
@@ -1,7 +1,9 @@
#####################################################################
# klipper-macros: include this one file from printer.cfg, after
# [include mainsail.cfg] (it needs [pause_resume], [virtual_sdcard] and
# [respond] from there, and replaces Mainsail's PAUSE/RESUME/CANCEL_PRINT):
# [respond] from there, and replaces Mainsail's PAUSE/RESUME/CANCEL_PRINT)
# and after [include AFC/*.cfg] (bd_pa_spoolman.cfg renames AFC's
# SET_SPOOL_ID, which only works when AFC is loaded first):
#
# [include klipper-macros/klipper-macros.cfg]
#
+6
View File
@@ -35,6 +35,12 @@ wrong firmware to a board can leave it unusable until it is reflashed by hand.**
## Adapting them to your printer
`install.sh` links this folder into the config folder as
`klipper-macros-scripts/`, so you can edit the scripts in Mainsail/Fluidd.
Edits change files in the git repo: Moonraker then shows the repo as
modified ("dirty") and will not update it until you commit or discard them
(`git -C ~/klipper-macros stash` before updating, `stash pop` after).
1. **Make one build config per board.** In `~/klipper` (and in `~/katapult`
for the Katapult script), run `make menuconfig KCONFIG_CONFIG=<name>` for
each board, with the settings from your board's documentation. The file