Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell reporter #650

Closed
mhalano opened this issue Jun 21, 2021 · 6 comments
Closed

Shell reporter #650

mhalano opened this issue Jun 21, 2021 · 6 comments

Comments

@mhalano
Copy link

mhalano commented Jun 21, 2021

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
Copy link
Author

mhalano commented Jun 22, 2021

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?

@thp
Copy link
Owner

thp commented Nov 7, 2021

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

@devicenull
Copy link

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

@mborsetti
Copy link
Contributor

@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

@thp
Copy link
Owner

thp commented Mar 4, 2022

@mborsetti Please fix the licensing issue of your fork: mborsetti/webchanges#30

@thp
Copy link
Owner

thp commented Nov 18, 2022

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.

Repository owner deleted a comment from notDavid Nov 18, 2022
@thp thp closed this as completed in 9f18af7 Nov 18, 2022
thp added a commit that referenced this issue Nov 18, 2022
Repository owner deleted a comment from mborsetti Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants