Implements configurable named workspaces

This commit is contained in:
Bapt
2009-07-24 17:30:27 +00:00
committed by Michael Stapelberg
parent 33e536113d
commit ddcb11baba
3 changed files with 69 additions and 8 deletions

View File

@ -18,6 +18,7 @@
#include "util.h"
#include "config.h"
#include "xcb.h"
#include "table.h"
Config config;
@ -295,6 +296,37 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
continue;
}
/* name "workspace number" "name of the workspace" */
if (strcasecmp(key, "name") == 0) {
LOG("name workspace: %s\n",value);
char *ws_str = sstrdup(value);
char *end = strchr(ws_str, ' ');
if (end == NULL)
die("Malformed name, couln't find terminating space\n");
*end='\0';
/* Strip trailing whitespace */
while (strlen(value) > 0 && value[strlen(value)-1] == ' ')
value[strlen(value)-1] = '\0';
int ws_num=atoi(ws_str);
if ( ws_num < 1 || ws_num > 10 )
die("Malformed name, invalid workspace Number\n");
/* find the name */
char *name= value;
name += strlen(ws_str) + 1;
/* if no name reinitialize the name to NULL for reload */
if (name == '\0') {
workspaces[ws_num - 1].name=NULL;
continue;
}
workspaces[ws_num - 1].name=sstrdup(name);
continue;
}
/* assign window class[/window title] → workspace */
if (strcasecmp(key, "assign") == 0) {
LOG("assign: \"%s\"\n", value);