From bfbcbe5c62a1dedad9cd7b9a6c984cc330012a4e Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Thu, 31 May 2012 22:31:31 +0100 Subject: [PATCH] Add new window related character sequence. 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 | 1 + spectrwm.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/spectrwm.1 b/spectrwm.1 index d14c707..cb119bd 100644 --- a/spectrwm.1 +++ b/spectrwm.1 @@ -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" diff --git a/spectrwm.c b/spectrwm.c index 436e84d..4b71a4f 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -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; -- 2.39.2