check-changes-website.sh (807B) - raw
1 #!/bin/sh 2 # 2020 Oscar Benedito <oscar@oscarbenedito.com> 3 # License: CC0 1.0 Universal License 4 5 # Script that notifies through Gotify when a website has changed. 6 7 # This scripts assumes there is an executable called "notify" in your PATH that 8 # takes two arguments (the first one is the notification title and the second 9 # one is the message). 10 11 URLS="${XDG_CONFIG_HOME:-$HOME/.config}/osf/urls-check-changes.txt" 12 13 [ ! -f "$URLS" ] && echo "Error: $URLS is not a file." && exit 1 14 15 check_and_notify() { 16 newhash="$(curl "$1" 2>/dev/null | sha256sum | cut -f 1 -d " ")" 17 [ "$2" != "$newhash" ] && notify "$3" "$1" 18 } 19 20 while read -r url hash title 21 do 22 check_and_notify "$url" "$hash" "$title" 23 done < "$URLS" 24 25 # Can also be used by calling check_and_notify directly. Example: 26 # check_and_notify url hash title