Skip to content

Instantly share code, notes, and snippets.

@kylemcdonald
Created July 26, 2023 01:33
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 kylemcdonald/f75a07c94293475b55b47b618a4f5c2f to your computer and use it in GitHub Desktop.
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.
#!/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