urlwatch icon indicating copy to clipboard operation
urlwatch copied to clipboard

Shell reporter

Open mhalano opened this issue 4 years ago • 5 comments

I have an edge case, but could become a feature request: I execute urlwatch locally and I would like to execute a shell command when there is any changes. The goal is to use notify-send command to display a notification in my desktop telling me about a change was detected (not necessarily what was the change). I tried to create a job to execute the command, but the message appears every time the urlwatch executes, and not only when there is a change.

mhalano avatar Jun 21 '21 12:06 mhalano

I tried to do a very hackish thing to get a notification on the desktop, but it doesn't work as expected. I put in my crontab:

[ -n "$(/usr/bin/urlwatch |/usr/bin/tee -a /home/mhalano/urlwatch.log)" ] && (eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)"; /usr/bin/notify-send "urlwatch detected a change" && echo "alert triggered" >> /home/mhalano/urlwatch.log)

The idea was executing the urlwatch, log the exit (for debug purposes only), and if there is anything on the exit, show the notification. I thought it was nice, until I get notifications even without reports (so that's why the logs, to try debugging that). The problem is the error logs: it shows in the exit but don't produce report (and I don't want to). So my idea to fix that would be a way to execute a command every time a report would be generated. What you think about it? There is another solution for that?

mhalano avatar Jun 22 '21 09:06 mhalano

Recent versions have diff_tool and diff_filter settings.

The diff_tool will get the old content and the new content as two filename arguments, and you can do whatever. Alternatively, if you're fine with the diff, you can use the diff_filter to do something.

An example is documented here: https://urlwatch.readthedocs.io/en/latest/advanced.html#pass-diff-output-to-a-custom-script

thp avatar Nov 07 '21 09:11 thp

I'd love to see this as well - my use case is to kick off a script to request archive.org save a page whenever it changes. I don't see a clear way of doing this, short of monitoring stdout

devicenull avatar Nov 24 '21 01:11 devicenull

@devicenull You may want to try the fork (optimized for web monitoring) webchanges as it has such reporter: https://webchanges.readthedocs.io/en/stable/reporters.html#run-command

mborsetti avatar Nov 24 '21 03:11 mborsetti

@mborsetti Please fix the licensing issue of your fork: https://github.com/mborsetti/webchanges/issues/30

thp avatar Mar 04 '22 20:03 thp

Removed comment from @notdavid because that's already mentioned elsewhere, and webchanges removed copyright/license headers in its source files (it's an unfriendly fork of urlwatch), so I'd prefer not promoting it here unnecessarily.

thp avatar Nov 18 '22 09:11 thp