]> git.sur5r.net Git - i3/i3/blobdiff - src/commands.c
Parse the title_format and display the customized window title if a format was set.
[i3/i3] / src / commands.c
index 3790f50f0d5d3969013679feb06358fc6fdb1f25..71b48182e61ca1c47d4c100774f8b17d0c443c77 100644 (file)
@@ -1904,7 +1904,25 @@ void cmd_scratchpad_show(I3_CMD) {
  *
  */
 void cmd_title_format(I3_CMD, char *format) {
-    DLOG("setting title_format to %s\n", format);
+    DLOG("setting title_format to \"%s\"\n", format);
+    HANDLE_EMPTY_MATCH;
+
+    owindow *current;
+    TAILQ_FOREACH(current, &owindows, owindows) {
+        if (current->con->window == NULL)
+            continue;
+
+        DLOG("setting title_format for %p / %s\n", current->con, current->con->name);
+        FREE(current->con->window->title_format);
+
+        /* If we only display the title without anything else, we can skip the parsing step,
+         * so we remove the title format altogether. */
+        if (strcasecmp(format, "%title") != 0)
+            current->con->window->title_format = sstrdup(format);
+
+        /* Make sure the window title is redrawn immediately. */
+        current->con->window->name_x_changed = true;
+    }
 
     cmd_output->needs_tree_render = true;
     ysuccess(true);