scripts/monitoweb.sh

48 lines
1.3 KiB
Bash

#!/bin/bash
url="$1"
interval="${2:-60}" # Default to 60 seconds if not specified
if [ -z "$url" ]; then
echo "Usage: $0 <url> [interval_seconds]"
exit 1
fi
# Test if notify-send is available
if ! command -v notify-send >/dev/null 2>&1; then
echo "notify-send not found. Installing libnotify-bin..."
sudo apt-get install libnotify-bin
fi
# Test notification
notify-send "Test" "Testing notifications..."
echo "If you didn't see a notification, there might be an issue with your notification daemon"
old_hash=""
while true; do
new_hash=$(curl -s "$url" | sha256sum | cut -d' ' -f1)
if [ -n "$old_hash" ] && [ "$old_hash" != "$new_hash" ]; then
echo "CHANGE DETECTED! $(date)"
# Try multiple notification methods
notify-send -u critical "Website Changed!" "Changes detected at $url"
# # Alternative: Use zenity if available
# if command -v zenity >/dev/null 2>&1; then
# zenity --info --text="Website changed: $url" &
# fi
#
# Also try to make a sound
if command -v paplay >/dev/null 2>&1; then
paplay --volume=17000 /usr/share/sounds/freedesktop/stereo/complete.oga &
elif command -v spd-say >/dev/null 2>&1; then
spd-say "Website changed"
fi
fi
old_hash=$new_hash
sleep $interval
done