Getting the correct name on Gnome 3 Chromium windows

Fix the annoying alt tab behavior of multiple chromium browser windows on Gnome 3


Gnome 3 is awesome, by far the best user experience I ever had. It’s fast, does exactly what I need and has sensible defaults.

One problem that I had for some weeks – after some upgrade I am sure – was that Alt+Tab and Alt+(key below ESC) behavior with Google Chromium windows was completely annoying: all my browser windows, including the ones I use --app and a different data directory, were grouped under “Google Chromium” icon, like in this screenshot I took (click on it for full size):

{% img center http://i.imgur.com/91vHml.jpg %}

As you can see the Gmail screen is under the Google Chromium “group” during the Alt+Tab. This is ANNOYING. This happens because Gnome 3 uses the WM_CLASS property from X to decide what is going to be considered the same Application, this is a change from the Gnome 2 behavior, when it considered Windows, not Applications, for grouping. Nice test to do (you have to click a window after running the command):

$ xprop WM_CLASS
WM_CLASS(STRING) = "chromium-browser", "Chromium-browser"

So, how to fix it? Well, it’s pretty very trivial. What must be done is to add the --class=value to your .desktop Exec line. Also, add StartupWMClass with the same value to give window managers and docks a tip of what application that belongs, this is my Gmail.Desktop:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/home/coredump/Pictures/Gmail-Icon.png
Name[en_US]=Gmail
Exec=chromium-browser --user-data-dir="/home/coredump/.config/gmail-chromium" --app="https://mail.google.com" --class=Gmail
Comment[en_US]=Gmail on Chromium
Name=Gmail
Comment=Gmail on Chromium
Icon=/home/coredump/Pictures/Gmail-Icon.png
StartupWMClass=Gmail
StartupNotify=true

Just remember to close all Chromium sessions (including the background one if you use it) before testing it since it will reuse the binary that is not using --class and you will lose minutes in rage (I did). After doing that with as many .desktop files you want, you will have the expected behavior on Alt+Tab:

{% img center http://i.imgur.com/2BCall.jpg %}

Three distinct browser sessions, as it was supposed to be. This problem also affects some docks like Docky and even BAMF (the thing Unity uses to match windows).

cya!

 
comments powered by Disqus