nspawn: set window title from container name

Let's update the window title with an ANSI sequence if we can. We'll
insert a blue dot, to match the blue tinting of the terminal screen,
indicating that we are in a container.
This commit is contained in:
Lennart Poettering
2024-02-09 18:27:01 +01:00
parent c80139f078
commit ab03434aa7
+17
View File
@@ -4451,6 +4451,22 @@ static int setup_notify_parent(sd_event *event, int fd, pid_t *inner_child_pid,
return 0;
}
static void set_window_title(PTYForward *f) {
_cleanup_free_ char *hn = NULL, *dot = NULL;
assert(f);
(void) gethostname_strict(&hn);
if (emoji_enabled())
dot = strjoin(special_glyph(SPECIAL_GLYPH_BLUE_CIRCLE), " ");
if (hn)
(void) pty_forward_set_titlef(f, "%sContainer %s on %s", strempty(dot), arg_machine, hn);
else
(void) pty_forward_set_titlef(f, "%sContainer %s", strempty(dot), arg_machine);
}
static int merge_settings(Settings *settings, const char *path) {
int rl;
@@ -5383,6 +5399,7 @@ static int run_container(
} else if (!isempty(arg_background))
(void) pty_forward_set_background_color(forward, arg_background);
set_window_title(forward);
break;
default: