Hi Rodrigo, I find your recent idea[0] to refresh the page on local file changes interesting, and it could be a quite useful feature. [0] https://github.com/dillo-browser/dillo/issues/255 I imagine it can be triggered with a tool like entr[1]: ls /tmp/test.html | entr 'pkill -SIGUSR1 dillo' [1] http://eradman.com/entrproject/ So far, I have a working signal handler which will act upon receipt of a SIGUSR1 signal. It just prints the signal # to the console right now. I am trying to make it perform an 'a_UIcmd_reload', but haven't been successful yet: dillo.cc:389:19: error: use of undeclared identifier 'vbw' a_UIcmd_reload(*vbw); ^ 1 error generated bw.h and uicmd.hh are defined in dillo.cc, so its probably a skill issue on my end :) Any hints would be appreciated! Regards, Alex --- a/src/dillo.cc Sun Aug 11 22:21:59 2024 +++ b/src/dillo.cc Mon Sep 2 14:21:08 2024 @@ -381,6 +381,14 @@ static DilloUrl *makeStartUrl(char *str, bool local) } /* + * Use SIGUSR1 to reload the page + */ +static void reload_handler(int signum) +{ + MSG("signum=%d\n\n", signum); +} + +/* * MAIN */ int main(int argc, char **argv) @@ -579,6 +587,10 @@ int main(int argc, char **argv) a_Url_free(start_url); } } + + // Reload page on SIGUSR1 + if (signal (SIGUSR1, reload_handler) == SIG_IGN) + signal (SIGUSR1, SIG_IGN); Fl::run();
Hi, On Mon, Sep 02, 2024 at 04:04:30PM +0200, a1ex@dismail.de wrote:
Hi Rodrigo,
I find your recent idea[0] to refresh the page on local file changes interesting, and it could be a quite useful feature.
[0] https://github.com/dillo-browser/dillo/issues/255
I imagine it can be triggered with a tool like entr[1]:
ls /tmp/test.html | entr 'pkill -SIGUSR1 dillo'
Yeah, that was the idea.
So far, I have a working signal handler which will act upon receipt of a SIGUSR1 signal. It just prints the signal # to the console right now. I am trying to make it perform an 'a_UIcmd_reload', but haven't been successful yet:
dillo.cc:389:19: error: use of undeclared identifier 'vbw' a_UIcmd_reload(*vbw); ^ 1 error generated
You need to find a pointer to BrowserWindow and pass it to a_UIcmd_reload(). Check a_Bw_num() and a_Bw_get() in src/bw.c. We should reload the current page on all windows. I'm not sure if we can do this from the context of a signal, we probably need to register a timeout in FLTK and handle it from there. Probably not a very easy issue. I should start labeling the ones that are easy. Best, Rodrigo.
Hi, On Mon, 2 Sep 2024 21:25:12 +0200 Rodrigo Arias <rodarima@gmail.com> wrote:
You need to find a pointer to BrowserWindow and pass it to a_UIcmd_reload(). Check a_Bw_num() and a_Bw_get() in src/bw.c.
We should reload the current page on all windows.
I'm not sure if we can do this from the context of a signal, we probably need to register a timeout in FLTK and handle it from there.
Probably not a very easy issue.
I didn't get much further with this yet, but in the meantime, here is a very simple example script which attempts to achieve the same goal. It opens the specified file in a new Dillo window and then automatically reloads the page whenever the file changes. Note that it only reloads the active tab. This relies on the 'entr' and 'xdotool' programs, but 'entr' can be easily replaced with a bit more scripting if desired. ```` #!/bin/sh # dillomon.sh # Monitor a local file for changes with Dillo # usage: dillomon.sh filename dillo $1 & sleep 1 echo $1 | entr xdotool key --window `xdotool search --classname Dillo | tail -1` ctrl+r ```` Regards, Alex
Hi Alex,
I didn't get much further with this yet, but in the meantime, here is a very simple example script which attempts to achieve the same goal.
It opens the specified file in a new Dillo window and then automatically reloads the page whenever the file changes. Note that it only reloads the active tab.
This relies on the 'entr' and 'xdotool' programs, but 'entr' can be easily replaced with a bit more scripting if desired.
```` #!/bin/sh # dillomon.sh # Monitor a local file for changes with Dillo # usage: dillomon.sh filename
dillo $1 & sleep 1 echo $1 | entr xdotool key --window `xdotool search --classname Dillo | tail -1` ctrl+r
````
Thanks!, that should do it for now. Eventually I'll need to add a tool to control the browser for automated testing, so I will probably also add the ability to refresh the current page too. So not sure if we want to spend too much effort in this, provided there is a intermediate solution already. I began tagging easy issues with "good first issue", so far only one: https://github.com/dillo-browser/dillo/issues?q=is%3Aissue+is%3Aopen+label%3... Best, Rodrigo.
Hi Alex, On Mon, Sep 02, 2024 at 04:04:30PM +0200, a1ex@dismail.de wrote:
Hi Rodrigo,
I find your recent idea[0] to refresh the page on local file changes interesting, and it could be a quite useful feature.
I implemented this on the following PR: https://github.com/dillo-browser/dillo/pull/290 It reloads the focused tabs on all windows of the given Dillo process when a SIGUSR1 signal arrives. Example to reload a local file test.html: All Dillo processes: echo test.html | entr pkill -SIGUSR1 dillo Only one with pid 1234: echo test.html | entr kill -SIGUSR1 1234 I mostly wanted to quickly reload the changes when I edit an HTML page, but this can also be used to monitor a remote page over time, like: $ dillo https://twtxt.envs.net/api/plain/tweets & $ while [ 1 ]; do sleep 10; pkill -SIGUSR1 dillo; done & See: https://forums.raspberrypi.com/viewtopic.php?t=330705 Could you test it on OpenBSD, I hope the signaling part continues to work fine there. Best, Rodrigo.
Hi Rodrigo, Rodrigo Arias <rodarima@gmail.com> wrote:
I implemented this on the following PR:
https://github.com/dillo-browser/dillo/pull/290
It reloads the focused tabs on all windows of the given Dillo process when a SIGUSR1 signal arrives.
Example to reload a local file test.html:
All Dillo processes:
echo test.html | entr pkill -SIGUSR1 dillo
Only one with pid 1234:
echo test.html | entr kill -SIGUSR1 1234
I mostly wanted to quickly reload the changes when I edit an HTML page, but this can also be used to monitor a remote page over time, like:
$ dillo https://twtxt.envs.net/api/plain/tweets & $ while [ 1 ]; do sleep 10; pkill -SIGUSR1 dillo; done &
See: https://forums.raspberrypi.com/viewtopic.php?t=330705
Could you test it on OpenBSD, I hope the signaling part continues to work fine there.
Nice patch! It seems to be working fine here with no problems. I agree that this is quite useful for editing and monitoring pages, thanks! -Alex
participants (2)
-
a1ex@dismail.de
-
Rodrigo Arias