• Arch PKGBUILDs
  • Downloads
  • Get in touch
  • Hardware
  • Screenshots
  • The name
Home

WM_CLASS woes

B — Sun, 04/10/2009 - 02:08

Xfce's Terminal has been my terminal of choice for ages. It's a relic from the days that I ran Xfce as a desktop, days that are long gone. I've gone quite minimalist since but Terminal does just what I need it to do - it's a terminal emulator that doesn't get in your way. Sure there's urxvt and the likes - the best thing to push my buttons is to put me in front of an .Xdefaults file and tell me to configure urxvt. Hell, I'm all in favour of control - but urxvt's configuration borders on the insane. However, there's one feature urxvt has that Terminal (and a lot of similar emulators) doesn't have though, and that's the possibility to manage the WM_CLASS properties of the terminal windows you launch. A typical WM_CLASS output would be this:

[stijn@hermes ~]$ xprop WM_CLASS
WM_CLASS(STRING) = "terminal", "Terminal"

Openbox uses the WM_CLASS values to manipulate the windows - it's the foundation on which the whole window management aspect (maximising, (un)decorating, focus, binding to a particular virtual desktop, ...) is built. Since I'm neither a GUI lover or a terminal fiend, I tend to pick the application that suits me best. I use Irssi for IRC and I like Ncmpc quite a lot as an MPD client. They both need to be launched from within a terminal, but since Terminal can't set the WM_CLASS properties, to Openbox, a terminal with Irssi running or Ncmpc is just the same - it can't tell one from another. Since I like my Irssi running on virtual desktop 2, and with a certain size, and my terminal on desktop 1, maximised, you can guess Terminal won't save the settings per application i'm calling it with.

That's where Openbox's per-application settings come into play. I did try to switch to urxvt a while ago, exactly because of its ability to manipulate WM_CLASS properties, and I did configure it, but it had a lot of quirks. The mouse scroll was not working, and there's the crappy colour support - there is a patch to support 256 colours that's been floating around for ages but it's said that the even urxvt author doesn't approve of it; some even say it would make urxvt unstable. I had my fair share of recompiling urxvt with every remotely scroll-related option enabled, and that's the end of the story.

The irritation with having to move windows around when my WM could do it for me was my main motivation to try out PekWM. Unfortunately, I find its configuration to be even more complex than that of Openbox (purely a matter of taste I'm sure). Of course I'm used to Openbox now, and I only dabbled in PekWM once before, so it's not an honest comparison. Nevertheless, I got PekWM up and running, but not to the point where it could match the ease of use Openbox provides me with. I'm a shallow guy, so nice themes do a lot, but they're not what makes me stick with a WM (and PekWM has a fair share of nice themes). So out of the window it went.

Today I started searching for a Terminal replacement - it would at least remedy one of my irritations (yes, I have a low tolerance treshold, thanks, I know that). I bumped into gnome-terminal, and was surprised to find it did not actually need anything from gnome (besides libvte, on which Terminal also depends). I installed it and the help showed it could set WM_CLASS attributes - awesome! Unfortunately it only worked once - all subsequent gnome-terminal calls would gleefully ignore whatever WM_CLASS modifications I told them to make. Some googling revealed this was an age-old bug, reported on Debian's and Gnome's bugtracker but never fixed. There is, luckily, a workaround. The --name argument will not work after the first launch during your X session, and neither will --class, unless you add the --disable-factory argument. So out of the two properties that windows set, you'll redefine the second:

gnome-terminal --disable-factory --class=Canto -t Canto -e canto

What you'll see is this:

[stijn@hermes ~]$ xprop WM_CLASS
WM_CLASS(STRING) = "gnome-terminal", "Canto"

Et voilà. WM_CLASS properties can be manipulated, which means you can also tell Openbox to manipulate each gnome-terminal instance differently, depending on the class, by defining per-application settings. For people interested in similar behaviour on other WMs/DEs, devilspie should be able to So now my terminal launches maximised, on my first desktop, and Irssi happily lives on the second one. One thing that annoys me though is the eternally blinking cursor. In true Gnome fashion, you can only disable that in the Gnome control center - and it affects all applications (like Gedit for example), and not just gnome-terminal. Surely a separate setting for your terminal is redundant, no?
Anyway - you can also change it through gconf:

gconftool-2 -s /apps/gnome-terminal/profiles/Default/cursor_blink_mode -t string off

Truly a happy ending! Now if only I could change the colour of the cursor independently from the colour of the font, but I'm nitpicking now, aren't I...

  • Linux
  • Add new comment
  • 414 reads

what about terminal --role?

Anonymous — Mon, 05/10/2009 - 19:19

You can set WM_WINDOW_ROLE via the --role option and match it in openbox via <application role="...">

  • reply

Woopsie

B — Wed, 07/10/2009 - 21:55

I must admit I totally overlooked that. My impression was Openbox could only handle the WM_CLASS properties... I just checked the Openbox per-application settings wiki page and you're right:

application name="NAME" class="CLASS" role="ROLE"

I can't imagine I saw that before. Thanks a lot!

  • reply

Blog posts

  • Drupal (1)
  • Embedded Linux (5)
  • OpenWrt (5)
  • Hardware (3)
  • Linux (9)
  • Arch Linux (4)
  • Icadyptes (0)
  • Miscellaneous (2)
  • Music (3)
  • Open Source (4)
  • Politics (1)

Fellow nutcases

Avarus
Ks1
Sega01

Recommended links

Arch Linux
Drupal
Glasnost ISP Bittorrent test
Heise Online
Icadyptes (aka "The Penguin")
Kwort Linux
OpenWrt
Salix (The Bonsai OS)
Zenwalk Linux

All copyright by B unless stated otherwise. Linking and/or copying information is allowed as long as the source is properly credited.