sfeed_curses

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

commit 6057dfc832cb190a76390fe800b71e7405ea2fcf
parent 795c0547aff616f42d92b7a2a91701cab08767b1
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 27 Jun 2020 23:02:37 +0200

set SFEED_PATH_PATH when changing feeds

This is useful for example for the plumb or content script to have contextual
customization per feed.

I use this to get the corresponding base url from the feed in the sfeedrc to
fix up feeds with relative urls in the content.

Diffstat:
Msfeed_curses.1 | 3+++
Msfeed_curses.c | 11+++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/sfeed_curses.1 b/sfeed_curses.1 @@ -111,6 +111,9 @@ By default this is "less". .It Ev SFEED_PLUMBER A program that received the url or enclosure url as a parameter. By default this is "xdg-open". +.It Ev SFEED_FEED_PATH +This variable is set when a feed is set or changed. +It can be used by the plumb or pipe program for scripting purposes. .El .Sh EXIT STATUS .Ex -std diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -986,6 +986,15 @@ feed_count(struct feed *f, FILE *fp) free(line); } +void +feed_setenv(struct feed *f) +{ + if (f && f->path) + setenv("SFEED_FEED_PATH", f->path, 1); + else + unsetenv("SFEED_FEED_PATH"); +} + /* change feed, have one file open, reopen file if needed */ void feeds_set(struct feed *f) @@ -1002,6 +1011,8 @@ feeds_set(struct feed *f) err(1, "fopen: %s", f->path); } + feed_setenv(f); + curfeed = f; }