[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9LBZsdh3PsjuB28@orbyte.nwl.cc>
Date: Thu, 13 Mar 2025 12:28:38 +0100
From: Phil Sutter <phil@....cc>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: Matteo Croce <technoboy85@...il.com>, netdev@...r.kernel.org,
Matteo Croce <teknoraver@...a.com>
Subject: Re: [PATCH iproute2-next v2] color: default to dark color theme
On Mon, Mar 10, 2025 at 02:12:16PM -0700, Stephen Hemminger wrote:
> On Mon, 10 Mar 2025 21:36:09 +0100
> Matteo Croce <technoboy85@...il.com> wrote:
>
> > From: Matteo Croce <teknoraver@...a.com>
> >
> > The majority of Linux terminals are using a dark background.
> > iproute2 tries to detect the color theme via the `COLORFGBG` environment
> > variable, and defaults to light background if not set.
> >
>
> This is not true. The default gnome terminal color palette is not dark.
ACK. Ever since that famous movie I stick to the real(TM) programmer
colors of green on black[1], but about half of all the blue pill takers
probably don't.
> > Change the default behaviour to dark background, and while at it change
> > the current logic which assumes that the color code is a single digit.
> >
> > Signed-off-by: Matteo Croce <teknoraver@...a.com>
>
> The code was added to follow the conventions of other Linux packages.
> Probably best to do something smarter (like util-linux) or more exactly
> follow what systemd or vim are doing.
I can't recall a single system on which I didn't have to 'set bg=dark'
in .vimrc explicitly, so this makes me curious: Could you name a
concrete example of working auto color adjustment to given terminal
background?
Looking at vim-9.1.0794 source code, I see:
| char_u *
| term_bg_default(void)
| {
| #if defined(MSWIN)
| // DOS console is nearly always black
| return (char_u *)"dark";
| #else
| char_u *p;
|
| if (STRCMP(T_NAME, "linux") == 0
| || STRCMP(T_NAME, "screen.linux") == 0
| || STRNCMP(T_NAME, "cygwin", 6) == 0
| || STRNCMP(T_NAME, "putty", 5) == 0
| || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
| && (p = vim_strrchr(p, ';')) != NULL
| && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
| && p[2] == NUL))
| return (char_u *)"dark";
| return (char_u *)"light";
| #endif
| }
So apart from a little guesswork based on terminal names, this does the
same as iproute currently (in his commit 54eab4c79a608 implementing
set_color_palette(), Petr Vorel even admitted where he had copied the
code from). No hidden gems to be found in vim sources, at least!
Cheers, Phil
[1] And have the screen rotated 90 degrees to make it more realistic,
but that's off topic.
Powered by blists - more mailing lists