[hackers] [st] A better XClassHint class definition

From: Ammar James <ammar.james_AT_alumni.stonybrook.edu>
Date: Sat, 19 Dec 2015 19:27:16 +0000

Greetings,

One great thing about dwm is the rules[] array in the config.h that lets
you launch programs and have them assigned to tags automatically. dwm
does this by reading the window's WM_CLASS and matching it with the
"class" defined in the rules[] array. WM_CLASS is a property each window
has, and one can find the WM_CLASS for their open windows by running
'xprop'.

One problem with st is that it incorrectly assigns the WM_CLASS when
running st with the "-c" flag. So, for example, we are unable right now
to launch the following script from dmenu and have the new terminal
launch with the appropriate tag as defined in dwm's config.h:

/usr/local/bin/launchmutt.sh:
---
#!/bin/bash
# launch st and run mutt
st -c st_mutt -e mutt
---
/usr/portage/savedconfigs/x11-wm/dwm/config.h:
---
static const Rule rules[] = {
        /* class      instance    title       tags mask     isfloating   monitor */
        { "Gimp",     NULL,       NULL,       1 << 6,       True,        -1 },
        { "chrome",   NULL,       NULL,       1 << 1,       False,       -1 },
        { "st_mutt",  NULL,       NULL,       1 << 4,       True,        -1 },
---
This behavior was actually first found and mentioned on the dev mailing
list back in 2012, but it looks like no action was ever taken. The
problem in st.c is that it defines the XClassHint class backwards. This
patch will allow one to use dwm's rules[] array in the way above as long
as one runs st with the "-c" flag to designate the class.  
Please see the patch below to correct this behavior:
--- st.c        2015-12-19 18:41:09.211014836 +0000
+++ st-modified.c       2015-12-19 18:38:34.832011313 +0000
_AT_@ -2987,7 +2987,7 @@
 void
 xhints(void) {
-       XClassHint class = {opt_class ? opt_class : termname, termname};
+       XClassHint class = {termname, opt_class ? opt_class : termname};
        XWMHints wm = {.flags = InputHint, .input = 1};
        XSizeHints *sizeh = NULL;
-- 
Ammar R. James
Received on Sat Dec 19 2015 - 20:27:16 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 20 2015 - 01:48:11 CET