From c531c973e5056b39b2ea724a0df53f8841bf6d4c Mon Sep 17 00:00:00 2001 From: DonO Date: Mon, 11 Mar 2024 13:35:57 -0500 Subject: [PATCH] Add ability to set workspace prefix when using number --- docs/labwc-config.5.scd | 10 ++++++---- docs/rc.xml.all | 9 +++++++++ include/config/rcxml.h | 1 + src/config/rcxml.c | 8 +++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index 4162af03..6ea402c2 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -303,10 +303,9 @@ extending outward from the snapped edge. ## WORKSPACES ** - Define workspaces. A workspace covers all outputs. The OSD only shows - windows on the current workspace. Workspaces can be switched to with - GoToDesktop and windows can be moved with SendToDesktop. See - labwc-actions(5) for more information about their arguments. + Define workspaces. A workspace covers all outputs. Workspaces can be + switched to with GoToDesktop and windows can be moved with SendToDesktop. + See labwc-actions(5) for more information about their arguments. The number attribute defines the minimum number of workspaces. Default is 1. The number attribute is optional. If the number attribute is @@ -316,6 +315,9 @@ extending outward from the snapped edge. Define the timeout after which to hide the workspace OSD. A setting of 0 disables the OSD. Default is 1000 ms. +** + Set the prefix to use when using "number" above. Default is "Workspace" + ## THEME ** diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 3b207653..037462d2 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -100,9 +100,18 @@ Or it can also be configured like this: + Or like this: + + 500 + 5 + ws + + popupTime defaults to 1000 so could be left out. Set to 0 to completely disable the workspace OSD. + prefix defaults to "Workspace" when using number instead of names. + Use GoToDesktop left | right to switch workspaces. Use SendToDesktop left | right to move windows. See man labwc-actions for further information. diff --git a/include/config/rcxml.h b/include/config/rcxml.h index a0250711..277db849 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -129,6 +129,7 @@ struct rcxml { struct { int popuptime; int min_nr_workspaces; + char *prefix; struct wl_list workspaces; /* struct workspace.link */ } workspace_config; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 1b2265d2..ffef4fe9 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -934,6 +934,8 @@ entry(xmlNode *node, char *nodename, char *content) rc.workspace_config.popuptime = atoi(content); } else if (!strcasecmp(nodename, "number.desktops")) { rc.workspace_config.min_nr_workspaces = MAX(1, atoi(content)); + } else if (!strcasecmp(nodename, "prefix.desktops")) { + rc.workspace_config.prefix = xstrdup(content); } else if (!strcasecmp(nodename, "popupShow.resize")) { if (!strcasecmp(content, "Always")) { rc.resize_indicator = LAB_RESIZE_INDICATOR_ALWAYS; @@ -1465,10 +1467,14 @@ post_processing(void) int nr_workspaces = wl_list_length(&rc.workspace_config.workspaces); if (nr_workspaces < rc.workspace_config.min_nr_workspaces) { + char *ws_name = xstrdup("Workspace"); + if (rc.workspace_config.prefix) { + ws_name = rc.workspace_config.prefix; + } struct workspace *workspace; for (int i = nr_workspaces; i < rc.workspace_config.min_nr_workspaces; i++) { workspace = znew(*workspace); - workspace->name = strdup_printf("Workspace %d", i + 1); + workspace->name = strdup_printf("%s %d", ws_name, i + 1); wl_list_append(&rc.workspace_config.workspaces, &workspace->link); } }