add feature to process a sequence of keys automatically on startup - sfeed_curs… | |
git clone git://git.codemadness.org/sfeed_curses | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d05e1dd6754f12dfe86e43545d26c7cdaccff3c9 | |
parent 07ba84aaade3283644269073f192aea576aa4fa2 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 10 Mar 2021 17:07:52 +0100 | |
add feature to process a sequence of keys automatically on startup | |
This adds the environment variable $SFEED_AUTOCMD: | |
Read and process a sequence of keys as input commands from this environment | |
variable first, afterwards read from stdin as usual. | |
This can be useful to automate certain actions at the start. | |
Diffstat: | |
M sfeed_curses.1 | 4 ++++ | |
M sfeed_curses.c | 5 +++++ | |
2 files changed, 9 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/sfeed_curses.1 b/sfeed_curses.1 | |
@@ -156,6 +156,10 @@ Resize the pane dimensions relative to the terminal size. | |
.El | |
.Sh ENVIRONMENT VARIABLES | |
.Bl -tag -width Ds | |
+.It Ev SFEED_AUTOCMD | |
+Read and process a sequence of keys as input commands from this environment | |
+variable first, afterwards read from stdin as usual. | |
+This can be useful to automate certain actions at the start. | |
.It Ev SFEED_PIPER | |
A program where the whole TAB-Separated Value line is piped to. | |
By default this is "sfeed_content". | |
diff --git a/sfeed_curses.c b/sfeed_curses.c | |
@@ -44,6 +44,7 @@ static char *pipercmd = "sfeed_content"; /* env variable: $SF… | |
static char *yankercmd = "xclip -r"; /* env variable: $SFEED_YANKER */ | |
static char *markreadcmd = "sfeed_markread read"; /* env variable: $SFEED_MARK… | |
static char *markunreadcmd = "sfeed_markread unread"; /* env variable: $SFEED_… | |
+static char *cmdenv; /* env variable: $SFEED_AUTOCMD */ | |
static int plumberia = 0; /* env variable: $SFEED_PLUMBER_INTERACTIVE */ | |
static int piperia = 1; /* env variable: $SFEED_PIPER_INTERACTIVE */ | |
static int yankeria = 0; /* env variable: $SFEED_YANKER_INTERACTIVE */ | |
@@ -982,6 +983,9 @@ readch(void) | |
fd_set readfds; | |
struct timeval tv; | |
+ if (cmdenv && *cmdenv) | |
+ return *(cmdenv++); | |
+ | |
for (;;) { | |
FD_ZERO(&readfds); | |
FD_SET(0, &readfds); | |
@@ -1819,6 +1823,7 @@ main(int argc, char *argv[]) | |
if ((tmp = getenv("SFEED_LAZYLOAD"))) | |
lazyload = !strcmp(tmp, "1"); | |
urlfile = getenv("SFEED_URL_FILE"); /* can be NULL */ | |
+ cmdenv = getenv("SFEED_AUTOCMD"); /* can be NULL */ | |
panes[PaneFeeds].row_format = feed_row_format; | |
panes[PaneFeeds].row_match = feed_row_match; |