sfeed_curses

[fork] sfeed (atom feed) reader
Log | Files | Refs | README | LICENSE

commit c4cb8053a0fffcd4f4ef2a9f333539e06fa872ad
parent 6538364ec9dfb0cebc5ee1e886b9138b7f879cd8
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Wed, 15 Jul 2020 17:25:01 +0200

handle SIGHUP for reloading all feeds and document all handled signals

SIGHUP can be useful for automated (cronjob) scripts to update the current open
window.

Diffstat:
Msfeed_curses.1 | 13+++++++++++--
Msfeed_curses.c | 28+++++++++++++++++++++-------
2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/sfeed_curses.1 b/sfeed_curses.1 @@ -1,4 +1,4 @@ -.Dd July 12, 2020 +.Dd July 15, 2020 .Dt SFEED_CURSES 1 .Os .Sh NAME @@ -96,7 +96,7 @@ The used command to yank the url is "cut -f 3 | xclip -r". Pipe the TAB-Separated Value for yanking the enclosure. The used command to yank the enclosure is "cut -f 8 | xclip -r". .It q, EOF -quit +Quit .El .Sh MOUSE ACTIONS When mouse-mode is enabled the below actions are available. @@ -112,6 +112,15 @@ Scroll 1 page up. .It scroll down Scroll 1 page down. .El +.Sh SIGNALS +.Bl -tag -width Ds +.It SIGHUP +Reload all feed files as specified on startup when not read from stdin. +.It SIGINT, SIGTERM +Quit +.It SIGWINCH +Resize the pane dimensions relative to the terminal size. +.El .Sh ENVIRONMENT VARIABLES .Bl -tag -width Ds .It Ev SFEED_PIPER diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -499,6 +499,7 @@ init(void) sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; /* require BSD signal semantics */ sa.sa_handler = sighandler; + sigaction(SIGHUP, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGWINCH, &sa, NULL); @@ -1187,6 +1188,20 @@ feeds_load(struct feed *feeds, size_t nfeeds) } void +feeds_reloadall(void) +{ + off_t pos; + + pos = panes[PaneItems].pos; /* store numeric position */ + feeds_load(feeds, nfeeds); + /* restore numeric position */ + pane_setpos(&panes[PaneItems], pos); + updatesidebar(onlynew); + updategeom(); + updatetitle(); +} + +void updatesidebar(int onlynew) { struct pane *p; @@ -1228,6 +1243,7 @@ void sighandler(int signo) { switch (signo) { + case SIGHUP: case SIGINT: case SIGTERM: case SIGWINCH: @@ -1659,13 +1675,7 @@ nextpage: alldirty(); break; case 'R': /* reload all files */ - off = panes[PaneItems].pos; /* store numeric position */ - feeds_load(feeds, nfeeds); - /* restore numeric position */ - pane_setpos(&panes[PaneItems], off); - updatesidebar(onlynew); - updategeom(); - updatetitle(); + feeds_reloadall(); break; case 'a': /* attachment */ case 'e': /* enclosure */ @@ -1737,6 +1747,10 @@ event: /* handle last signal */ switch (sigstate) { + case SIGHUP: + feeds_reloadall(); + sigstate = 0; + break; case SIGINT: case SIGTERM: cleanup();