#include "log.h"
#include "macro.h"
#include "parse-util.h"
+//#include "path-util.h"
+//#include "proc-cmdline.h"
#include "process-util.h"
#include "socket-util.h"
#include "stat-util.h"
return cached_colors_enabled;
}
+bool dev_console_colors_enabled(void) {
+ _cleanup_free_ char *s = NULL;
+ int b;
+
+ /* Returns true if we assume that color is supported on /dev/console.
+ *
+ * For that we first check if we explicitly got told to use colors or not, by checking $SYSTEMD_COLORS. If that
+ * didn't tell us anything we check whether PID 1 has $TERM set, and if not whether $TERM is set on the kernel
+ * command line. If we find $TERM set we assume color if it's not set to "dumb", similar to regular
+ * colors_enabled() operates. */
+
+ b = getenv_bool("SYSTEMD_COLORS");
+ if (b >= 0)
+ return b;
+
+ if (getenv_for_pid(1, "TERM", &s) <= 0)
+ (void) proc_cmdline_get_key("TERM", 0, &s);
+
+ return !streq_ptr(s, "dumb");
+}
+
bool underline_enabled(void) {
if (cached_underline_enabled < 0) {
bool terminal_is_dumb(void);
bool colors_enabled(void);
bool underline_enabled(void);
+bool dev_console_colors_enabled(void);
#define DEFINE_ANSI_FUNC(name, NAME) \
static inline const char *ansi_##name(void) { \