diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2024-06-28 14:46:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-28 14:46:27 +0200 |
commit | cddbd730cb21ddee9f9ce86444c306a60391be77 (patch) | |
tree | bcdef0c7615016da75f4233a07b6b67ebd4fb852 /src/shared | |
parent | Merge pull request #33516 from poettering/more-stub-tweaks (diff) | |
parent | run: move condition inside set_window_title() (diff) | |
download | systemd-cddbd730cb21ddee9f9ce86444c306a60391be77.tar.xz systemd-cddbd730cb21ddee9f9ce86444c306a60391be77.zip |
Merge pull request #33370 from grawity/run-title
run: add option to prevent the setting of terminal title
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/ptyfwd.c | 16 | ||||
-rw-r--r-- | src/shared/ptyfwd.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index 998ce96b54..842aef9270 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -17,6 +17,7 @@ #include "sd-event.h" #include "alloc-util.h" +#include "env-util.h" #include "errno-util.h" #include "extract-word.h" #include "fd-util.h" @@ -367,6 +368,21 @@ static int insert_background_fix(PTYForward *f, size_t offset) { return insert_string(f, offset, s); } +bool shall_set_terminal_title(void) { + static int cache = -1; + + if (cache >= 0) + return cache; + + cache = getenv_bool("SYSTEMD_ADJUST_TERMINAL_TITLE"); + if (cache == -ENXIO) + return (cache = true); + if (cache < 0) + log_debug_errno(cache, "Failed to parse $SYSTEMD_ADJUST_TERMINAL_TITLE, leaving terminal title setting enabled: %m"); + + return cache != 0; +} + static int insert_window_title_fix(PTYForward *f, size_t offset) { assert(f); diff --git a/src/shared/ptyfwd.h b/src/shared/ptyfwd.h index 248646d764..b86027e9bc 100644 --- a/src/shared/ptyfwd.h +++ b/src/shared/ptyfwd.h @@ -50,4 +50,6 @@ int pty_forward_set_titlef(PTYForward *f, const char *format, ...) _printf_(2,3) int pty_forward_set_title_prefix(PTYForward *f, const char *prefix); +bool shall_set_terminal_title(void); + DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free); |