From 44f748a663fc0ae96b2a750a804cf470dcad1675 Mon Sep 17 00:00:00 2001 From: Michael Hofmann Date: Sat, 7 Mar 2015 00:13:54 +0100 Subject: [PATCH] Rename workspaces in startup sequences. When renaming workspaces, any workspace names in pending startup sequences also need to be renamed. --- include/startup.h | 6 ++++++ src/commands.c | 2 ++ src/startup.c | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/startup.h b/include/startup.h index 2f28baa7..cb784913 100644 --- a/include/startup.h +++ b/include/startup.h @@ -44,6 +44,12 @@ void startup_sequence_delete(struct Startup_Sequence *sequence); */ void startup_monitor_event(SnMonitorEvent *event, void *userdata); +/** + * Renames workspaces that are mentioned in the startup sequences. + * + */ +void startup_sequence_rename_workspace(char *old_name, char *new_name); + /** * Gets the stored startup sequence for the _NET_STARTUP_ID of a given window. * diff --git a/src/commands.c b/src/commands.c index 92203e39..d3e2a6e3 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2044,6 +2044,8 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) { ewmh_update_desktop_names(); ewmh_update_desktop_viewport(); ewmh_update_current_desktop(); + + startup_sequence_rename_workspace(old_name, new_name); } /* diff --git a/src/startup.c b/src/startup.c index ebe8c1d9..aa347bd7 100644 --- a/src/startup.c +++ b/src/startup.c @@ -257,6 +257,22 @@ void startup_monitor_event(SnMonitorEvent *event, void *userdata) { } } +/** + * Renames workspaces that are mentioned in the startup sequences. + * + */ +void startup_sequence_rename_workspace(char *old_name, char *new_name) { + struct Startup_Sequence *current; + TAILQ_FOREACH(current, &startup_sequences, sequences) { + if (strcmp(current->workspace, old_name) != 0) + continue; + DLOG("Renaming workspace \"%s\" to \"%s\" in startup sequence %s.\n", + old_name, new_name, current->id); + free(current->workspace); + current->workspace = sstrdup(new_name); + } +} + /** * Gets the stored startup sequence for the _NET_STARTUP_ID of a given window. * -- 2.39.5