add feature to process a sequence of keys automatically on startup - sfeed_curses - sfeed curses UI (now part of sfeed, development is in sfeed)
 (HTM) git clone git://git.codemadness.org/sfeed_curses
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d05e1dd6754f12dfe86e43545d26c7cdaccff3c9
 (DIR) parent 07ba84aaade3283644269073f192aea576aa4fa2
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       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(-)
       ---
 (DIR) 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".
 (DIR) diff --git a/sfeed_curses.c b/sfeed_curses.c
       @@ -44,6 +44,7 @@ static char *pipercmd = "sfeed_content"; /* env variable: $SFEED_PIPER */
        static char *yankercmd = "xclip -r"; /* env variable: $SFEED_YANKER */
        static char *markreadcmd = "sfeed_markread read"; /* env variable: $SFEED_MARK_READ */
        static char *markunreadcmd = "sfeed_markread unread"; /* env variable: $SFEED_MARK_UNREAD */
       +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;