For the general case you want to monitor a file, and send a desktop notification with the new file content only when the content has changed, you can use inotifywait (from inotify-tools) with the -m, --monitor option to execute indefinitely.
--format "%e" will print only the type of the event to the next command.
notify-send, from libnotify for desktop notifications, is being used to send the notification only if the file content is modified.
#!/bin/bash
f="file"f="filename"
curr="$curr=$(<"$f")"
inotifywait -m -e modify "$f" --format "%e" | while read -r event; do
    if [ "$event" == "MODIFY" ]; then
        prev="$curr"
        curr="$curr=$(<"$f")"
        [ "$curr" == "$prev" ] || notify-send "Title" "$curr"
    fi
done
For your specific case, I would not monitor changes to files, if your goal is to display a desktop notification with a text like "you are connected" or "you are disconnected". I would modify the place where you print that text (every N seconds as you say) into that file, to something like this:
while true; do
    prev="$curr"
    curr="$curr=$( <here you output the new text> )"
    [ "$curr" == "$prev" ] || notify-send "Title" "$curr"
    sleep 4
done