placed in a trusted disk image directory (see above), or if suitable polkit
authentication was acquired. See `systemd.image-policy(7)` for the valid
syntax for image policy strings.
+
+`systemd-run`, `run0`, `systemd-nspawn`, `systemd-vmspawn`:
+
+* `$SYSTEMD_TINT_BACKGROUND` – Takes a boolean. When false the automatic
+ tinting of the background for containers, VMs, and interactive `systemd-run`
+ and `run0` invocations is turned off. Note that this environment variable has
+ no effect if the background color is explicitly selected via the relevant
+ `--background=` switch of the tool.
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);
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())
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);
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);
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);