tree/container: support sandbox properties in title format

This commit is contained in:
Jacob McNamee 2024-12-27 00:03:06 -08:00 committed by Simon Ser
parent 3ab1f0ca3d
commit f177d05441
2 changed files with 32 additions and 6 deletions

View file

@ -372,12 +372,29 @@ set|plus|minus|toggle <amount>
*title_format* <format> *title_format* <format>
Sets the format of window titles. The following placeholders may be used: Sets the format of window titles. The following placeholders may be used:
%title - The title supplied by the window ++ *%title*
%app_id - The wayland app ID (applicable to wayland windows only) ++ The title supplied by the window
%class - The X11 classname (applicable to xwayland windows only) ++
%instance - The X11 instance (applicable to xwayland windows only) ++ *%app_id*
%shell - The protocol the window is using (typically xwayland or The wayland app ID (applicable to wayland windows only)
xdg_shell)
*%class*
The X11 classname (applicable to xwayland windows only)
*%instance*
The X11 instance (applicable to xwayland windows only)
*%shell*
The protocol the window is using (typically xwayland or xdg_shell)
*%sandbox_engine*
The associated sandbox engine
*%sandbox_app_id*
The app ID provided by the associated sandbox engine
*%sandbox_instance_id*
The instance ID provided by the associated sandbox engine
This command is typically used with *for_window* criteria. For example: This command is typically used with *for_window* criteria. For example:

View file

@ -716,6 +716,15 @@ size_t parse_title_format(struct sway_container *container, char *buffer) {
} else if (has_prefix(next, "%shell")) { } else if (has_prefix(next, "%shell")) {
len += append_prop(buffer, view_get_shell(container->view)); len += append_prop(buffer, view_get_shell(container->view));
format += strlen("%shell"); format += strlen("%shell");
} else if (has_prefix(next, "%sandbox_engine")) {
len += append_prop(buffer, view_get_sandbox_engine(container->view));
format += strlen("%sandbox_engine");
} else if (has_prefix(next, "%sandbox_app_id")) {
len += append_prop(buffer, view_get_sandbox_app_id(container->view));
format += strlen("%sandbox_app_id");
} else if (has_prefix(next, "%sandbox_instance_id")) {
len += append_prop(buffer, view_get_sandbox_instance_id(container->view));
format += strlen("%sandbox_instance_id");
} else { } else {
lenient_strcat(buffer, "%"); lenient_strcat(buffer, "%");
++format; ++format;