nspawn, vmspawn, run0: add env var for turning off background tinting

Some people are just sad, sad lost souls who don't like even the tiniest
ray of color in their life. Let's add an env var knob for allowing them
to turn the background tinting off, to drive the last bit of color from
their life so that they can stay in their grey grey life.
This commit is contained in:
Lennart Poettering
2024-05-02 23:33:39 +02:00
committed by Luca Boccassi
parent 61628287bd
commit d4ffb37bb1
6 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -5556,7 +5556,7 @@ static int run_container(
arg_console_width,
arg_console_height);
if (!arg_background) {
if (!arg_background && shall_tint_background()) {
_cleanup_free_ char *bg = NULL;
r = terminal_tint_color(220 /* blue */, &bg);
+1 -1
View File
@@ -963,7 +963,7 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) {
if (strv_extend(&arg_property, "PAMName=systemd-run0") < 0)
return log_oom();
if (!arg_background && arg_stdio == ARG_STDIO_PTY) {
if (!arg_background && arg_stdio == ARG_STDIO_PTY && shall_tint_background()) {
double hue;
if (privileged_execution())
+15
View File
@@ -444,6 +444,21 @@ int terminal_tint_color(double hue, char **ret) {
return 0;
}
bool shall_tint_background(void) {
static int cache = -1;
if (cache >= 0)
return cache;
cache = getenv_bool("SYSTEMD_TINT_BACKGROUND");
if (cache == -ENXIO)
return (cache = true);
if (cache < 0)
log_debug_errno(cache, "Failed to parse $SYSTEMD_TINT_BACKGROUND, leaving background tinting enabled: %m");
return cache != 0;
}
void draw_progress_bar(const char *prefix, double percentage) {
fputc('\r', stderr);
+2
View File
@@ -50,5 +50,7 @@ static inline const char *green_check_mark_internal(char buffer[static GREEN_CHE
int terminal_tint_color(double hue, char **ret);
bool shall_tint_background(void);
void draw_progress_bar(const char *prefix, double percentage);
void clear_progress_bar(const char *prefix);
+1 -1
View File
@@ -1977,7 +1977,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
if (r < 0)
return log_error_errno(r, "Failed to create PTY forwarder: %m");
if (!arg_background) {
if (!arg_background && shall_tint_background()) {
_cleanup_free_ char *bg = NULL;
r = terminal_tint_color(130 /* green */, &bg);