From: Reginald Kennedy Date: Mon, 22 Jul 2013 07:24:53 +0000 (+0800) Subject: Add 'name' configuration option. X-Git-Url: https://jasonwoof.com/gitweb/?p=spectrwm.git;a=commitdiff_plain;h=57bfbfcfaa04c4b29ecc8c3d18d8847d2294c9ea Add 'name' configuration option. Set name of workspace at start-of-day. --- diff --git a/spectrwm.1 b/spectrwm.1 index 2fb85b5..00b802c 100644 --- a/spectrwm.1 +++ b/spectrwm.1 @@ -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 . diff --git a/spectrwm.c b/spectrwm.c index 342dc69..40c5416 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -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[]: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 diff --git a/spectrwm.conf b/spectrwm.conf index 27d46cb..4729531 100644 --- a/spectrwm.conf +++ b/spectrwm.conf @@ -65,6 +65,12 @@ # 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