Skip to content

Instantly share code, notes, and snippets.

@davidkryzaniak
Last active August 29, 2015 14:27
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 davidkryzaniak/e9587b57c0a4e3f66040 to your computer and use it in GitHub Desktop.
Save davidkryzaniak/e9587b57c0a4e3f66040 to your computer and use it in GitHub Desktop.
#!/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