I am using wayland based swaywm as my window manager. It uses the WM_CLASS property for the title of its containers (not sure if it is applicable only for X11 apps). It lets you group stuff, so that you can easily do scripting over a bunch of related windows.

However, the problem is that it is not uniform across applications. Sometimes you would see title case which is not nice if you have a - separated word like Google-chrome.

Can I control the WMClass of an application, so that I can at-least lowercase it?

Some .desktop files have an option that says StartupWMClass. How do I use that information while executing a command manually? I tried StartupWMClass=code code but that doesn't help.

  • 3
    Some apps, like xterm have a -class option just for that. gtk apps like chrome don't seem to have anything similar. But you can change the WM_CLASS property on an existing window with xprop(1), though that may be too late in your case. You can also use a LD_PRELOAD hack, though it may be overkill (you may just as well fix your wm in its source & recompile).
    – user313992
    May 25, 2019 at 11:42
  • 2
    Gtk applications have the --class option for this (see man gtk-options). May 25, 2019 at 13:44
  • Thanks @mosvy, yes apparently chrome also complies with --class as mentioned above.
    – Nishant
    May 25, 2019 at 14:14
  • 2
    As WM_CLASS like the other window properties are set by the toolkit, there can't be any toolkit-indepent solution for the initial settings. Some window managers allow matching on other criteria than class, but I've no idea what swaywm does. But I'd assume you could change it in the source code, if it's an important feature for you.
    – dirkt
    May 25, 2019 at 17:42
  • 4
    As mentioned in the other answers, historically, all the early X toolkits supported --class (this commandline parsing automatically done when the application initializes). Then more modern toolkits were invented, their programmers chose to ignore the old conventions ("Linux must be made modern for the Desktop, users won't need command line options!"), and that's why we can't have nice things like conventions that work for all toolkits.
    – dirkt
    May 26, 2019 at 4:31


You must log in to answer this question.

Browse other questions tagged .