Allow users to configure autogroups as:
autogroup X windowclass windowname
The idea is to better reflect the fact that classes match
more generally than names.
Index: cwm/group.c
===================================================================
--- cwm.orig/group.c 2012-11-02 17:45:39.851725859 -0500
+++ cwm/group.c 2012-11-02 17:55:25.056669818 -0500
@@ -172,7 +172,11 @@
aw = xcalloc(1, sizeof(*aw));
if ((p = strchr(class, ',')) == NULL) {
- aw->name = NULL;
+ if (name == NULL)
+ aw->name = NULL;
+ else
+ aw->name = xstrdup(name);
+
aw->class = xstrdup(class);
} else {
/*
@@ -182,7 +186,12 @@
tmp = class;
*(p++) = '\0';
- aw->name = xstrdup(tmp);
+
+ if (name == NULL)
+ aw->name = xstrdup(tmp);
+ else
+ aw->name = xstrdup(name);
+
aw->class = xstrdup(p);
}
aw->num = no;
Index: cwm/parse.y
===================================================================
--- cwm.orig/parse.y 2012-11-02 17:49:06.223469017 -0500
+++ cwm/parse.y 2012-11-02 17:55:25.056669818 -0500
@@ -129,7 +129,7 @@
free($2);
free($3);
}
- | AUTOGROUP NUMBER STRING {
+ | AUTOGROUP NUMBER STRING {
if ($2 < 0 || $2 > 9) {
free($3);
yyerror("autogroup number out of range: %d",
$2);
@@ -139,6 +139,25 @@
group_make_autogroup(conf, $2, $3, NULL);
free($3);
}
+ | AUTOGROUP NUMBER STRING STRING {
+ char *p;
+
+ if ($2 < 0 || $2 > 9) {
+ free($3);
+ yyerror("autogroup number out of range: %d",
$2);
+ YYERROR;
+ }
+
+ if ((p = strchr($3, ',')) != NULL) {
+ warnx("%s:%d: ambiguous autogroup
configuration, "
+ "will use class=%s, name=%s", file->name,
+ yylval.lineno, ++p, $4);
+ }
+
+ group_make_autogroup(conf, $2, $3, $4);
+ free($3);
+ free($4);
+ }
| AUTOGROUP NUMBER STRING ',' STRING {
if ($2 < 0 || $2 > 9) {
free($3);
Index: cwm/cwmrc.5
===================================================================
--- cwm.orig/cwmrc.5 2012-11-01 08:08:20.291499000 -0500
+++ cwm/cwmrc.5 2012-11-02 17:55:48.346865705 -0500
@@ -40,6 +40,7 @@
.Pp
.Bl -tag -width Ds -compact
.It Ic autogroup Ar group windowclass
+.It Ic autogroup Ar group windowclass windowname
.It Ic autogroup Ar group windowname,windowclass
Automatically add new windows to
.Ar group