Skip to content

Instantly share code, notes, and snippets.

@jpaulickcz
Created November 17, 2021 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpaulickcz/93155e008873fede3f4779d1fcd270ef to your computer and use it in GitHub Desktop.
Save jpaulickcz/93155e008873fede3f4779d1fcd270ef to your computer and use it in GitHub Desktop.
OctoPrint progress in menubar on macOS with TextBar
#!/bin/bash
# Simple script to show print progress in the menu bar on MacOS via the app TextBar. Requires jq (brew install jq).
# TextBar: http://richsomerfield.com/apps/textbar/
# Settings
APIKEY=14F42AFCE3C64BAEA1A970FF67921A56
OCTOPRINT_IP=192.168.15.177
# The rest
JSON=$(curl --insecure -sX GET -H "Authorization: Bearer $APIKEY" "https://$OCTOPRINT_IP/api/job")
PERCENT=$(echo $JSON | jq '.progress.completion' | bc -l | xargs printf "%.1f")
TIME_SECONDS=$(echo $JSON | jq '.progress.printTimeLeft')
echo -e "\033[1mPrint progress:\033[0m $PERCENT % ($((TIME_SECONDS/60)) min left)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment