From 179bd0991b0797217028dfacb04d34895b9adff1 Mon Sep 17 00:00:00 2001 From: MangaValk Date: Sat, 10 Oct 2026 15:28:52 +0200 Subject: [PATCH] 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 --- CLAUDE.md | 6 ++++-- README.md | 15 ++++++++++----- install.sh | 26 +++++++++++++++++--------- macros/klipper-macros.cfg | 4 +++- scripts/README.md | 6 ++++++ 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 1a20c11..0f2b012 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 diff --git a/README.md b/README.md index f43790e..d1e1f24 100644 --- a/README.md +++ b/README.md @@ -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]`. diff --git a/install.sh b/install.sh index 66309af..10fc3d5 100755 --- a/install.sh +++ b/install.sh @@ -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" -fi -ln -sfn "$REPO_DIR/macros" "$LINK_NAME" -echo "linked $LINK_NAME" +# 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 "$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 <` for each board, with the settings from your board's documentation. The file