dmenu-octoprint 1.41 KB
Newer Older
Maze's avatar
Maze committed
1 2
#!/bin/bash

Maze's avatar
Maze committed
3 4 5 6 7 8 9 10
# 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.

Maze's avatar
Maze committed
11 12 13
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
Maze's avatar
Maze committed
14
    exit 1
Maze's avatar
Maze committed
15 16
fi

Maze's avatar
reorder  
Maze committed
17
chosen=$(printf "light\nlightonlon\nlightoffloff\nconnect\nprint\nfeed\nabort\nheatbed\nheatnozzle\ncooldown\ncooldownbed\ncooldownnozzle\nstream" | dmenu -fn 'monospace:size=16')
Maze's avatar
Maze committed
18

Maze's avatar
Maze committed
19 20 21 22 23 24
case "$chosen" in

    "light") # my light script
        ssh mazieprinter ./bin/rpi-light-toggle.py
        ;;

Maze's avatar
esac  
Maze committed
25
    "lightonlon") # my light script
Maze's avatar
Maze committed
26 27 28
        ssh mazieprinter ./bin/rpi-light-on.py
        ;;

Maze's avatar
esac  
Maze committed
29
    "lightoffloff") # my light script
Maze's avatar
Maze committed
30 31 32
        ssh mazieprinter ./bin/rpi-light-off.py
        ;;

Maze's avatar
Maze committed
33
    "stream") # my stream command
Maze's avatar
firefox  
Maze committed
34
        firefox http://mazieprinter:8080?action=stream
Maze's avatar
Maze committed
35 36
        ;;

Maze's avatar
Maze committed
37
    *) # for actual octoprint operations
Maze's avatar
Maze committed
38 39 40 41 42
        if octorest mazieprinter $(cat ~/.octoprint_api_key) $chosen; then
            notify-send "✅"
        else
            notify-send "❌"
        fi
Maze's avatar
Maze committed
43
        ;;
Maze's avatar
esac  
Maze committed
44
esac