]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamectl: respect SYSTEMD_COLORS
authorSebastian Gross <sgross@emlix.com>
Tue, 10 Dec 2024 08:09:41 +0000 (09:09 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 10 Dec 2024 10:03:19 +0000 (11:03 +0100)
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.

src/hostname/hostnamectl.c

index a537312d25727c84a6d0f5b3b33aa569f816a9a4..cd4f86af8012013a3455449960935b92fd7bd1f1 100644 (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);
                 }