This is my advanced filament swap script for Mainsail (possibly also compatible with Fluids??). It allows for guided pop-up alerts on run-out and M600 events, with a fluid UI suitable for all screen sizes.
This script is inspired by Jay Lexx's MOM script for for OctoPrint.
Some people had issues with replacing their index.html with the modified version I provided. It appears that from time to time Mainsail update the source for it and if it then gets replaced with a mismatched version, it causes a blank screen. The new method instead requires the user to edit their own index.html and paste in a few extra lines (see installation instructions below).
STEP 1: Connect to your printer via SFTP
STEP 2: Save adv_filament_swap.cfg in your config folder (i.e: home/pi/klipper_config/)
STEP 3: Save alert-handler.js in /home/pi/mainsail
STEP 4: Edit your index.html in /home/pi/mainsail and add the following before </head>
<!-- MOD START -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css">
<script src="./alert-handler.js"></script>
<!-- MOD END -->
STEP 5: Include this script in your printer.cfg (i.e [include adv_filament_swap.cfg])
OPTIONAL: Tweak any of the default values in adv_filament_swap.cfg as required (from line #120)
OPTIONAL: Point your run-out pin to RUN_OUT in your printer.cfg
STEP 1) Extensions > Post Processing > Modify G-Code
STEP 2) Add a script -> Filament Change
STEP 3) Set "Layer" to the layer number you want the switch to occur
STEP 4) Repeat Step 3 for however many changes you require (:
N.B. You can also manaually send FILAMENT_SWAP in the console to trigger a filament swap.
For support, join my Discord.
Run out:
Filament unloading:
M600:
Fluid UI for all screen sizes: