]> git.mdlowis.com Git - proto/labwc.git/commitdiff
workspaces: add ability to set prefix when using number argument
authordroc12345 <80716141+droc12345@users.noreply.github.com>
Mon, 11 Mar 2024 22:19:03 +0000 (17:19 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Mar 2024 22:19:03 +0000 (23:19 +0100)
docs/labwc-config.5.scd
docs/rc.xml.all
include/config/rcxml.h
src/config/rcxml.c

index e658e7d8014255040171df5be77eda4d65cfdf98..2ba5ce192c57eb1aeabbddf66fff0fcbdfcfe7df 100644 (file)
@@ -313,10 +313,9 @@ extending outward from the snapped edge.
 ## WORKSPACES
 
 *<desktops number=""><names><name>*
-       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
@@ -326,6 +325,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.
 
+*<desktops><prefix>*
+       Set the prefix to use when using "number" above. Default is "Workspace"
+
 ## THEME
 
 *<theme><name>*
index 3b207653df89a22cf9e834578f0c3fad882eef32..3865c571a67018f9ef08c551d9d57f388b2a6521 100644 (file)
     Or it can also be configured like this:
     <desktops number="4" />
 
+    Or like this:
+    <desktops>
+      <popupTime>500</popupTime>
+      <number>5</number>
+      <prefix>ws</prefix>
+    </desktops>
+
+    Or:
+    <desktops number="4" popupTime="500" prefix="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.
index a0250711acb26f890a257924c2905003a2dc2fa4..277db84920b9084302ea68317a566ac66ee36692 100644 (file)
@@ -129,6 +129,7 @@ struct rcxml {
        struct {
                int popuptime;
                int min_nr_workspaces;
+               char *prefix;
                struct wl_list workspaces;  /* struct workspace.link */
        } workspace_config;
 
index 1b2265d2e9189d567bc692c8f772e61247cfe250..e672aebd1a56162258856d6b677c39ed78c8ac45 100644 (file)
@@ -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) {
+               if (!rc.workspace_config.prefix) {
+                       rc.workspace_config.prefix = xstrdup("Workspace");
+               }
                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",
+                               rc.workspace_config.prefix, i + 1);
                        wl_list_append(&rc.workspace_config.workspaces, &workspace->link);
                }
        }
@@ -1638,6 +1644,7 @@ rcxml_finish(void)
        zfree(rc.font_menuitem.name);
        zfree(rc.font_osd.name);
        zfree(rc.theme_name);
+       zfree(rc.workspace_config.prefix);
 
        struct usable_area_override *area, *area_tmp;
        wl_list_for_each_safe(area, area_tmp, &rc.usable_area_overrides, link) {