Skip to content

Instantly share code, notes, and snippets.

@jonhoo
Last active August 29, 2015 14:06
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 jonhoo/275eb2551e602ef417d1 to your computer and use it in GitHub Desktop.
Save jonhoo/275eb2551e602ef417d1 to your computer and use it in GitHub Desktop.
Sidney Pacific Laundryview CLI
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "$0 <machine>"
exit 1
fi
rem=""
mtype=""
state=""
state() {
machine=$1
data=$(curl -s \
"http://classic.laundryview.com/classic_laundry_room_ajax.php?lr=1364821" \
| grep -B3 -A19 -P "^\\s*0*$machine\\s*</div></td>\$"
)
rem=$(echo "$data" | pup .runtime .stat | grep -v "<" | sed 's/^\s*//')
rem=$(echo "$rem" | sed 's/est. time remaining \([0-9]*\) min/\1 minutes remaining/')
rem=$(echo "$rem" | sed 's/^1 minutes/1 minute/')
icon=$(echo "$data" | grep 'width="30" height="30"' | sed 's@.*themes/default/images/icon_\([^_]*\)_\([^_]*\)\.gif.*@\1@')
mtype="${icon^}"
state=$(echo "$data" | grep 'width="30" height="30"' | sed 's@.*themes/default/images/icon_\([^_]*\)_\([^_]*\)\.gif.*@\2@')
}
while ((1)); do
state "$1"
if [[ $state == "available" ]]; then
notify-send -i user-trash-empty "$mtype cycle completed" "You can now collect your load from machine $machine"
exit 0
fi
echo "$mtype #$machine: $rem"
sleep 60
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment