#!/bin/bash # This script uses `dmenu` to display a list of some 3D printer operations. # After you choose one, a command is sent to the 3D printer. # You need a separate script for this, which is called `octorest`. # You need to have an OctoPrint server attached to the 3D printer. # You need to make a file ~/.octoprint_api_key with your api key. # You also need to change `mazieprinter` here to the hostname you want. if [ ! -f ~/.octoprint_api_key ]; then echo "You need to: printf 3515349878973553 >~/.octoprint_api_key" notify-send "You need to: printf 3515349878973553 >~/.octoprint_api_key" -u critical exit 1 fi chosen=$(printf "light\nlightonlon\nlightoffloff\nconnect\nprint\nfeed\nabort\nheatbed\nheatnozzle\ncooldown\ncooldownbed\ncooldownnozzle\nstream" | dmenu -fn 'monospace:size=16') case "$chosen" in "light") # my light script ssh mazieprinter ./bin/rpi-light-toggle.py ;; "lightonlon") # my light script ssh mazieprinter ./bin/rpi-light-on.py ;; "lightoffloff") # my light script ssh mazieprinter ./bin/rpi-light-off.py ;; "stream") # my stream command firefox http://mazieprinter:8080?action=stream ;; *) # for actual octoprint operations if octorest mazieprinter $(cat ~/.octoprint_api_key) $chosen; then notify-send "✅" else notify-send "❌" fi ;; esac