Last active
August 29, 2015 14:27
-
-
Save davidkryzaniak/e9587b57c0a4e3f66040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# The mac address of your Dash. Like: 74:75:48:b9:80:fb | |
MACADDR= | |
# Number of seconds to wait in between checks | |
INTERVAL=3 | |
# Number of seconds to sleep after the button is pressed | |
WAITFOR=60 | |
# Command to run when the button is hit | |
# Ensures that there is only a single instance of this script running | |
ME=`basename $0` | |
RUNNING=`ps | awk '/'"$ME"'/ {++x}; END {print x+0}'` | |
if [ "$RUNNING" -gt 3 ]; then | |
echo "Another instance of \"$ME\" is running" | |
exit 1 | |
fi | |
while sleep $INTERVAL | |
do | |
# Search for the mac address of the | |
SEARCH=`ip neigh | grep "$MACADDR"` | |
if [ -n "$SEARCH" ]; then | |
# Debug message | |
echo "Dash Found." | |
# Command to run when the button is hit | |
# echo `wget -U "**my-secret-user-agent**" -O /dev/tty "http://example.com/test.php?secret=key&type=twitter&msg=I%20just%20pressed%20my%20Amazon%20Dash%20button"` | |
echo "Sleeping for $WAITFOR seconds" | |
sleep $WAITFOR | |
else | |
# Debug message | |
echo "Dash not found" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment