]> code.delx.au - spectrwm/commitdiff
Add new window related character sequence.
authorTiago Cunha <tcunha@gmx.com>
Thu, 31 May 2012 21:31:31 +0000 (22:31 +0100)
committerTiago Cunha <tcunha@gmx.com>
Tue, 5 Jun 2012 21:32:02 +0000 (22:32 +0100)
Character pair +P outputs both window class and title separated by a
colon. Might be useful to some users and it's only a few lines of code.

spectrwm.1
spectrwm.c

index d14c707e10eb76a53c0a73771d3a835bc94ef07d..cb119bdce1ed07c944662770d44cfe6823411f11 100644 (file)
@@ -121,6 +121,7 @@ It may contain the following character sequences:
 .It Li "+F" Ta "Floating indicator"
 .It Li "+I" Ta "Workspace index"
 .It Li "+N" Ta "Screen number"
+.It Li "+P" Ta "Window class and title separated by a colon"
 .It Li "+S" Ta "Stacking algorithm"
 .It Li "+T" Ta "Window title"
 .It Li "+U" Ta "Urgency hint"
index 436e84d70158450a5e96403fa38860b44cd75e77..4b71a4f2ca73b0d6115838f1b0f88466b342feea 100644 (file)
@@ -1368,6 +1368,17 @@ bar_title_name(char *s, size_t sz, struct swm_region *r)
                strlcat(s, r->ws->focus->ch.res_name, sz);
 }
 
+void
+bar_class_title_name(char *s, size_t sz, struct swm_region *r)
+{
+       if (r == NULL || r->ws == NULL || r->ws->focus == NULL)
+               return;
+
+       bar_class_name(s, sz, r);
+       strlcat(s, ":", sz);
+       bar_title_name(s, sz, r);
+}
+
 void
 bar_window_float(char *s, size_t sz, struct swm_region *r)
 {
@@ -1542,6 +1553,9 @@ bar_replace_seq(char *fmt, char *fmtrep, struct swm_region *r, size_t *offrep,
        case 'N':
                snprintf(tmp, sizeof tmp, "%d", r->s->idx + 1);
                break;
+       case 'P':
+               bar_class_title_name(tmp, sizeof tmp, r);
+               break;
        case 'S':
                snprintf(tmp, sizeof tmp, "%s", r->ws->stacker);
                break;