diff --git a/man/remind.1.in b/man/remind.1.in index 2d7b820a..acfc6b2e 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -112,12 +112,15 @@ If the optional \fIm\fR parameter is supplied following a comma, then and it will darken bright colors to make them visible. If \fIm\fR is specified as 2, then \fBRemind\fR does not perform any adjustments, and some reminders may be hard or impossible to see if the color is -too close to the terminal background color. +too close to the terminal background color. If you supply the letter +\fBt\fR rather than a number, then Remind attempts to guess the background +color of the terminal, \fIeven if\fR stdout is not a terminal. .PP On startup, if the standard output is a terminal, \fBRemind\fR attempts to determine if the terminal background is dark or light by sending a special escape sequence to determine the background color. -The \fIm\fR parameter can override this check. +The \fIm\fR parameter can override this check (or force it if +\fIm\fR is given as \fBt\fR.) .PP If the optional \fIb\fR parameter is supplied following a comma, then \fIb=0\fR tells \fBRemind\fR to ignore SPECIAL SHADE reminders (the diff --git a/src/init.c b/src/init.c index 987e5c2d..46df3045 100644 --- a/src/init.c +++ b/src/init.c @@ -41,6 +41,8 @@ #include "expr.h" #include "err.h" +static int should_guess_terminal_background = 1; + static void guess_terminal_background(int *r, int *g, int *b); static int tty_init(int fd); static void tty_raw(int fd); @@ -175,7 +177,6 @@ void InitRemind(int argc, char const *argv[]) int dse; int ttyfd; int r, g, b; - int should_guess_terminal_background = 1; dse = NO_DATE; @@ -273,19 +274,24 @@ void InitRemind(int argc, char const *argv[]) if (*arg == ',') { arg++; if (*arg != ',') { - PARSENUM(x, arg); - if (x == 0) { - should_guess_terminal_background = 0; - TerminalBackground = TERMINAL_BACKGROUND_DARK; - } else if (x == 1) { - should_guess_terminal_background = 0; - TerminalBackground = TERMINAL_BACKGROUND_LIGHT; - } else if (x == 2) { - should_guess_terminal_background = 0; - TerminalBackground = TERMINAL_BACKGROUND_UNKNOWN; + if (*arg == 't') { + arg++; + should_guess_terminal_background = 2; } else { - fprintf(ErrFp, "%s: -@n,m,b: m must be 0, 1 or 2 (assuming 2)\n", - argv[0]); + PARSENUM(x, arg); + if (x == 0) { + should_guess_terminal_background = 0; + TerminalBackground = TERMINAL_BACKGROUND_DARK; + } else if (x == 1) { + should_guess_terminal_background = 0; + TerminalBackground = TERMINAL_BACKGROUND_LIGHT; + } else if (x == 2) { + should_guess_terminal_background = 0; + TerminalBackground = TERMINAL_BACKGROUND_UNKNOWN; + } else { + fprintf(ErrFp, "%s: -@n,m,b: m must be t, 0, 1 or 2 (assuming 2)\n", + argv[0]); + } } } } @@ -1014,9 +1020,11 @@ guess_terminal_background(int *r, int *g, int *b) *g = -1; *b = -1; - /* Don't guess if stdout not a terminal */ - if (!isatty(STDOUT_FILENO)) { - return; + /* Don't guess if stdout not a terminal unless asked to by @,t */ + if (should_guess_terminal_background != 2) { + if (!isatty(STDOUT_FILENO)) { + return; + } } ttyfd = open("/dev/tty", O_RDWR);