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.
This commit is contained in:
Sebastian Gross
2024-12-10 11:03:19 +01:00
committed by Zbigniew Jędrzejewski-Szmek
parent 053cbabce7
commit f0484e096c
+4 -4
View File
@@ -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);
}