From: pyr Date: Thu, 4 Jun 2009 06:03:37 +0000 (+0000) Subject: Add two configuration options: X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;ds=inline;h=ef26984e3981a0ca7f50bf18da5ec8be9105ef29;p=spectrwm.git Add two configuration options: * title_name_enabled * title_class_enabled The first one shows the active window title in the status bar, the second the active window class (useful to find out window classes to use with quirks). Both are disabled by default. read & approved by marco. --- diff --git a/scrotwm.1 b/scrotwm.1 index 133fea9..9ddf6fd 100644 --- a/scrotwm.1 +++ b/scrotwm.1 @@ -140,6 +140,12 @@ binary must not be setuid or setgid, which it is by default on most systems. Users may need to set spawn term to use an alternate copy of the .Xr xterm 1 binary without the setgid bit set. +.It Cm title_class_enabled +Enable or disable displaying the window class in the status bar. +Enable by setting to 1 +.It Cm title_name_enabled +Enable or disable displaying the window title in the status bar. +Enable by setting to 1 .It Cm modkey Change mod key. Mod1 is generally the ALT key and Mod4 is the windows key on a PC. diff --git a/scrotwm.c b/scrotwm.c index 3f48ca6..2b1ba3b 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -182,6 +182,8 @@ int bar_extra_running = 0; int bar_verbose = 1; int bar_height = 0; int clock_enabled = 1; +int title_name_enabled = 0; +int title_class_enabled = 0; pid_t bar_pid; GC bar_gc; XGCValues bar_gcv; @@ -692,6 +694,12 @@ conf_load(char *filename) case 't': if (!strncmp(var, "term_width", strlen("term_width"))) term_width = atoi(val); + else if (!strncmp(var, "title_class_enabled", + strlen("title_class_enabled"))) + title_class_enabled = atoi(val); + else if (!strncmp(var, "title_name_enabled", + strlen("title_name_enabled"))) + title_name_enabled = atoi(val); else goto bad; break; @@ -756,6 +764,8 @@ bar_update(void) char s[SWM_BAR_MAX]; char loc[SWM_BAR_MAX]; char *b; + XClassHint *xch; + Status status; if (bar_enabled == 0) return; @@ -781,6 +791,24 @@ bar_update(void) localtime_r(&tmt, &tm); strftime(s, sizeof s, "%a %b %d %R %Z %Y ", &tm); } + xch = NULL; + if ((title_name_enabled == 1 || title_class_enabled == 1) && + cur_focus != NULL) { + if ((xch = XAllocClassHint()) == NULL) + goto out; + status = XGetClassHint(display, cur_focus->id, xch); + if (status == BadWindow || status == BadAlloc) + goto out; + if (title_name_enabled) + strlcat(s, xch->res_name, sizeof s); + if (title_name_enabled && title_class_enabled) + strlcat(s, " ", sizeof s); + if (title_class_enabled) + strlcat(s, xch->res_class, sizeof s); + } +out: + if (xch) + XFree(xch); for (i = 0; i < ScreenCount(display); i++) { x = 1; TAILQ_FOREACH(r, &screens[i].rl, entry) { diff --git a/scrotwm.conf b/scrotwm.conf index 5f08360..c0d06d0 100644 --- a/scrotwm.conf +++ b/scrotwm.conf @@ -13,6 +13,8 @@ bar_font = -*-terminus-medium-*-*-*-*-*-*-*-*-*-*-* #bar_action = baraction.sh #bar_delay = 1 clock_enabled = 1 +title_name_enabled = 0 +title_class_enabled = 0 # spawn app spawn_term = xterm