]> code.delx.au - spectrwm/commitdiff
Add 'name' configuration option.
authorReginald Kennedy <rk@rejii.com>
Mon, 22 Jul 2013 07:24:53 +0000 (15:24 +0800)
committerReginald Kennedy <rk@rejii.com>
Fri, 7 Feb 2014 15:37:39 +0000 (23:37 +0800)
Set name of workspace at start-of-day.

spectrwm.1
spectrwm.c
spectrwm.conf

index 2fb85b51b6852301f4ea545b7f78a51d3cd1e16d..00b802cc2aac7f5f3c7c5cddede941ddae08a642 100644 (file)
@@ -313,6 +313,10 @@ This setting is not retained at restart.
 .It Ic modkey
 Change mod key.
 Mod1 is generally the ALT key and Mod4 is the windows key on a PC.
+.It Ic name Ns Bq Ar n
+Set name of workspace
+.Ar n
+at start-of-day.
 .It Ic program Ns Bq Ar p
 Define new action to spawn a program
 .Ar p .
index 342dc69c0438a6d61695e1bea98d1ea6d65878fb..40c5416e09452015083fa8734e2b1f694dfd204b 100644 (file)
@@ -7686,7 +7686,8 @@ enum {
        SWM_S_WINDOW_CLASS_ENABLED,
        SWM_S_WINDOW_INSTANCE_ENABLED,
        SWM_S_WINDOW_NAME_ENABLED,
-       SWM_S_WORKSPACE_LIMIT
+       SWM_S_WORKSPACE_LIMIT,
+       SWM_S_WORKSPACE_NAME,
 };
 
 int
@@ -7694,7 +7695,7 @@ setconfvalue(const char *selector, const char *value, int flags)
 {
        struct workspace        *ws;
        int                     i, ws_id, num_screens;
-       char                    *b, *str;
+       char                    *b, *str, s[1024];
 
        switch (flags) {
        case SWM_S_BAR_ACTION:
@@ -7908,6 +7909,32 @@ setconfvalue(const char *selector, const char *value, int flags)
 
                ewmh_update_desktops();
                break;
+       case SWM_S_WORKSPACE_NAME:
+               if (getenv("SWM_STARTED") != NULL)
+                       return (0);
+
+               bzero(s, sizeof s);
+               if (sscanf(value, "ws[%d]:%1023c", &ws_id, s) != 2)
+                       errx(1, "invalid entry, should be 'ws[<idx>]:name'");
+               ws_id--;
+               if (ws_id < 0 || ws_id >= workspace_limit)
+                       errx(1, "setconfvalue: workspace_name: invalid "
+                           "workspace %d.", ws_id + 1);
+
+               num_screens = get_screen_count();
+               for (i = 0; i < num_screens; ++i) {
+                       ws = (struct workspace *)&screens[i].ws;
+
+                       if (strlen(s) > 0) {
+                               free(ws[ws_id].name);
+                               if ((ws[ws_id].name = strdup(s)) == NULL)
+                                       err(1, "setconfvalue: workspace_name.");
+
+                               ewmh_update_desktop_names();
+                               ewmh_get_desktop_names();
+                       }
+               }
+               break;
        default:
                return (1);
        }
@@ -8170,6 +8197,7 @@ struct config_option configopt[] = {
        { "window_instance_enabled",    setconfvalue,   SWM_S_WINDOW_INSTANCE_ENABLED },
        { "window_name_enabled",        setconfvalue,   SWM_S_WINDOW_NAME_ENABLED },
        { "workspace_limit",            setconfvalue,   SWM_S_WORKSPACE_LIMIT },
+       { "name",                       setconfvalue,   SWM_S_WORKSPACE_NAME },
 };
 
 void
index 27d46cbbe2b6607ff3078901cda9af4053d9fdc7..4729531244e09d93527d3d94efebfc7050adab7e 100644 (file)
 # layout               = ws[4]:4:0:0:0:vertical_flip
 # layout               = ws[5]:0:0:0:0:horizontal_flip
 
+# Set workspace name at start
+# name                 = ws[1]:IRC
+# name                 = ws[2]:Email
+# name                 = ws[3]:Browse
+# name                 = ws[10]:Music
+
 # Mod key, (Windows key is Mod4) (Apple key on OSX is Mod2)
 # modkey = Mod1