From e8f3d5ff9f3893b5c8a6c0e5fe48ca98dfcb7d36 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Tue, 3 Oct 2023 00:04:01 -0400 Subject: [PATCH] Tweak the terminal background-color guessing code. --- src/init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/init.c b/src/init.c index b71540bd..9eb193d6 100644 --- a/src/init.c +++ b/src/init.c @@ -1016,7 +1016,7 @@ guess_terminal_background(int *r, int *g, int *b) if (!isatty(STDOUT_FILENO)) { return; } - + ttyfd = open("/dev/tty", O_RDWR); if (ttyfd < 0) { return; @@ -1034,10 +1034,10 @@ guess_terminal_background(int *r, int *g, int *b) tty_raw(ttyfd); write(ttyfd, "\033]11;?\033\\", 8); - /* Wait up to 0.2s for terminal to respond */ + /* Wait up to 0.1s for terminal to respond */ p.fd = ttyfd; p.events = POLLIN; - if (poll(&p, 1, 200) < 0) { + if (poll(&p, 1, 100) < 0) { tty_reset(ttyfd); close(ttyfd); return; @@ -1056,11 +1056,11 @@ guess_terminal_background(int *r, int *g, int *b) tty_reset(ttyfd); buf[n+1] = 0; if (n < 25) { - printf("N too short %d\n", n); + /* Too short */ return; } if (sscanf(buf+5, "rgb:%x/%x/%x", &rr, &gg, &bb) != 3) { - printf("sscanf failed\n"); + /* Couldn't scan color codes */ return; } *r = (rr >> 8) & 255;