Created
July 26, 2023 01:33
-
-
Save kylemcdonald/f75a07c94293475b55b47b618a4f5c2f to your computer and use it in GitHub Desktop.
Watch a URL for updates and pop up a notification if it changes.
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/bash | |
URL=$1 | |
LAST_PAGE="cache.html" | |
while true; do | |
curl -s "$URL" > "$LAST_PAGE" | |
echo -n "$(date) - $(stat -f "%z" "$LAST_PAGE") - " | |
openssl md5 "$LAST_PAGE" | cut -d' ' -f2 | |
if ! diff -q "$LAST_PAGE" "$LAST_PAGE.old" > /dev/null; then | |
osascript -e 'display notification "Page changed!" with title "Page changed!"' | |
fi | |
mv "$LAST_PAGE" "$LAST_PAGE.old" | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment