Skip to content

Instantly share code, notes, and snippets.

@vasileboris
Forked from mcsf/calypso-anybar-handler.sh
Last active June 19, 2018 05:02
Show Gist options
  • Save vasileboris/a9cbe3acfbf6d5995310be9d7bf5e120 to your computer and use it in GitHub Desktop.
Save vasileboris/a9cbe3acfbf6d5995310be9d7bf5e120 to your computer and use it in GitHub Desktop.
Calypso AnyBar handler
#!/bin/bash
PORT="${PORT:-1738}"
INITIAL_COLOR="${INITIAL_COLOR:-"white"}"
PROGRESS_COLOR="${PROGRESS_COLOR:-"yellow"}"
DONE_COLOR="${DONE_COLOR:-"green"}"
BUILD_ERROR_COLOR="${BUILD_ERROR_COLOR:-"red"}"
main() {
reset_icon
tee >(update_status)
}
update_status() {
while read line
do
if [[ "$line" =~ "Rendering Complete, saving .css file..." ]]; then
set_icon "$PROGRESS_COLOR"
elif [[ "$line" =~ "Getting bundles ready, hold on..." ]]; then
set_icon "$PROGRESS_COLOR"
elif [[ "$line" =~ ": Compiling..." ]]; then
set_icon "$PROGRESS_COLOR"
elif [[ "$line" =~ ": Compiled successfully." ]]; then
set_icon "$DONE_COLOR"
elif [[ "$line" =~ ": Failed to compile." ]]; then
set_icon "$BUILD_ERROR_COLOR"
fi
done
}
set_icon() {
echo -n "$1" | nc -4u -w0 localhost $PORT
}
reset_icon() {
set_icon "$INITIAL_COLOR"
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment