]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: get_color_mode checks COLORTERM
authorSonali Srivastava <srivastava.sonali1@gmail.com>
Wed, 20 Apr 2022 19:28:02 +0000 (00:58 +0530)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 5 May 2022 07:18:51 +0000 (09:18 +0200)
src/basic/terminal-util.c
src/basic/terminal-util.h

index 7cf74e97d0a7f5f15460c179d0feaf25079a11a2..8ddcfe23230f28c4b0b17d11958c035cf1b753df 100644 (file)
@@ -1278,6 +1278,11 @@ ColorMode get_color_mode(void) {
                         /* We only check for the presence of the variable; value is ignored. */
                         cached_color_mode = COLOR_OFF;
 
+                else if (STRPTR_IN_SET(getenv("COLORTERM"),
+                                       "truecolor",
+                                       "24bit"))
+                        cached_color_mode = COLOR_24BIT;
+
                 else if (getpid_cached() == 1)
                         /* PID1 outputs to the console without holding it open all the time.
                          *
index ce454bc1aef544edeb16f39028456e67dd01ef9e..59c868a2a53913739e0d875dce16b138efce1f56 100644 (file)
@@ -100,16 +100,19 @@ typedef enum AcquireTerminalFlags {
 /* Limits the use of ANSI colors to a subset. */
 typedef enum ColorMode {
         /* No colors, monochrome output. */
-        COLOR_OFF = 0,
+        COLOR_OFF,
 
         /* All colors, no restrictions. */
-        COLOR_ON  = 1,
+        COLOR_ON,
 
         /* Only the base 16 colors. */
-        COLOR_16  = 16,
+        COLOR_16,
 
         /* Only 256 colors. */
-        COLOR_256 = 256,
+        COLOR_256,
+
+        /* For truecolor or 24bit color support.*/
+        COLOR_24BIT,
 
         _COLOR_INVALID = -EINVAL,
 } ColorMode;