From: Sebastian Gross Date: Tue, 10 Dec 2024 08:09:41 +0000 (+0100) Subject: hostnamectl: respect SYSTEMD_COLORS X-Git-Tag: v257~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f0484e096c9cfc22ae99f7452a366e2545255e30;p=thirdparty%2Fsystemd.git hostnamectl: respect SYSTEMD_COLORS Instead of the wrapper functions the color defines where used directly. This was especially a problem for ANSI_HIGHLIGHT_YELLOW which is not legible at all for light themes such as solarized. The 16 color palette fallback can be set to a sane yellow or orange on that matter but it was not used though `SYSTEMD_COLORS=16` was set. Use the proper wrapper functions and let the right color be selected the way other components do it already. --- diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index a537312d257..cd4f86af801 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -91,12 +91,12 @@ static const char *os_support_end_color(usec_t n, usec_t eol) { * yellow. If more than a year is left, color green. In between just show in regular color. */ if (n >= eol) - return ANSI_HIGHLIGHT_RED; + return ansi_highlight_red(); left = eol - n; if (left < USEC_PER_MONTH) - return ANSI_HIGHLIGHT_YELLOW; + return ansi_highlight_yellow(); if (left > USEC_PER_YEAR) - return ANSI_HIGHLIGHT_GREEN; + return ansi_highlight_green(); return NULL; } @@ -313,7 +313,7 @@ static int print_status_info(StatusInfo *i) { r = table_add_many(table, TABLE_FIELD, "Firmware Age", TABLE_TIMESPAN_DAY, n - i->firmware_date, - TABLE_SET_COLOR, n - i->firmware_date > USEC_PER_YEAR*2 ? ANSI_HIGHLIGHT_YELLOW : NULL); + TABLE_SET_COLOR, n - i->firmware_date > USEC_PER_YEAR*2 ? ansi_highlight_yellow() : NULL); if (r < 0) return table_log_add_error(r); }