Skip to content

Instantly share code, notes, and snippets.

@bduisenov
Last active January 12, 2018 15:38
Show Gist options
  • Save bduisenov/06b4f3ec58c4a1fac4514cd60b3fa3cd to your computer and use it in GitHub Desktop.
Save bduisenov/06b4f3ec58c4a1fac4514cd60b3fa3cd to your computer and use it in GitHub Desktop.
#!/bin/bash
anybarNotify () {
(echo -n "$1" | nc -u -c -w 1 localhost 1738) &
}
if pgrep AnyBar > /dev/null; then
echo "skip starting anybar"
else
echo "starting anybar"
open -a AnyBar
fi
while ! nc -zu localhost 1738; do sleep 1 && echo -n .; done;
echo "anybar is listening"
while true; do
fping -c1 -t500 -q -a $1 >& /dev/null
if [[ $? -eq 0 ]]; then
echo "success"
anybarNotify "purple"
else
echo "failed"
anybarNotify "red"
fi
sleep 1
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment