I am using mupdf-gl, and using xprop I don't get the value of WM_CLASS. But if I use mupdf-x11, I do get a value for WM_CLASS.

The output of xprop for mupdf-gl:

                window state: Normal
                icon window: 0x0
                Initial state is Normal State.
                user specified size: 1088 by 1668
WM_ICON_NAME(STRING) = "EEE Transformer CT.pdf - 1 / 4"
WM_NAME(STRING) = "EEE Transformer CT.pdf - 1 / 4"

The output of xprop for mupdf-x11:

                window state: Normal
                icon window: 0x0
_NET_WM_NAME(UTF8_STRING) = "EEE Transformer CT.pdf - 1/4 (96 dpi)"
WM_ICON_NAME(STRING) = "EEE Transformer CT.pdf - 1/4 (96 dpi)"
WM_NAME(STRING) = "EEE Transformer CT.pdf - 1/4 (96 dpi)"
WM_CLASS(STRING) = "mupdf", "MuPDF"
                bitmap id # to use for icon: 0x2800091
                bitmap id # of mask for icon: 0x2800093

How do I assign WM_CLASS to a window when launching it?

  • 1
    I could be mistaken, but WM_CLASS is a property that is set as part of the xlib library: tronche.com/gui/x/xlib/ICC/client-to-window-manager/…. If this is not set, you won't get anything. Either A) it wasn't set, or B) it's not supported in the GL version of mupdf. – bgregs Jan 17 at 13:40
  • If it might help, you can use xdotool to set the property afterwards, with something like xdotool search --pid 12656 set_window --classname MYCLASS – meuh Jan 17 at 15:11
  • @meuh, Couldn't I do that in one bash command? Somehow piping the required line from xprop to xdotool? – klaus Jan 17 at 15:57
  • @meuh Very nice! That's probably a much cleaner solution. However, you may want to update both --classname and --class for your set_window call. – bgregs Jan 17 at 16:16

Confirmed as per my comment above. When looking at the source code of the project, you can see multiple folders under "Platform". In the X11 folder, you can find the source code as follows:

if (classhint)
    classhint->res_name = "mupdf";
    classhint->res_class = "MuPDF";
    XSetClassHint(xdpy, xwin, classhint);

This does not exist in the GL platform folder. If you want the property set for that platform, you will need to submit an enhancement request to the developers.

  • I've talked with one of the maintainer. He asked me to call XSetClassHint from a file. He also told me that I can just copy the call from another file, that very code block you mentioned here. If you can just look at this irc log. I couldn't get it to work, and left it there. – klaus Jan 17 at 15:53
  • If you've time, you could try to build the program in your own computer. I had errors in mine when doing make, after copying the whole block, and declaring required variables, in the file mentioned in the irc log. – klaus Jan 17 at 15:55
  • Yea, it appears freeglut doesn't support WM_CLASS (which in my mind should be updated, maybe I'll save that for a rainy day :) ). I'm not at my home computer to be able to recompile the freeglut library for you (Windows computers at work :( ), but all you need to do is add the XSetClassHint call after line 368 of the fg_window_x11.c file. Chances are you already have the freeglut library on your computer, so you could just modify it directly and recompile. – bgregs Jan 17 at 16:06

You can set property with xprop.

xprop -name "ma_window" -f WM_TRUC 8s -set WM_TRUC "The_Truc"

xprop -name "ma_window" WM_TRUC
WM_TRUC(STRING) = "The_Truc"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.