The Algorithm by which ‘Docky’ Determines the .desktop File Associated with a Window

August 28, 2014 Linux 1 comment , , ,

UPDATE: I’ve created a Python implementation of this algorithm. It’s available here.

I was curious how docks seem able to determine the correct icon (ie find the correct .desktop file) for applications even when their .desktop files lack the StartupWMClass key. So I had a look at the source code for ‘Docky’. After a little figuring out of the, almost entirely uncommented :(, code, I determined that the algorithm goes like this, stopping on the first successful step:

  • Check if there is a .desktop file with the appropriate StartupWMClass.
  • See if there is a .desktop file whose name is the same as that of the WM_CLASS of the window.
  • Then check if the window belongs to ‘OpenOffice’, ‘LibreOffice’ or ‘Wine’.
  • Look for a .desktop file whose name is the same as that of the WM_CLASS of the window with all . characters removed.
  • Check if the process name matches the Exec field of any .desktop file.
  • Finally, check if the window command matches the Exec field of any .desktop file.

Here is the relevant method starting a line 165 of Docky.Services/Docky.Services/WindowMatcherService.cs in Docky-2.2.0:

See the full code here.

Unicode in X Core Fonts

July 24, 2014 Linux No comments , ,

If you want to use an X core font specified by its X Logical Font Description, and you want to access some unicode symbols, make sure you specify the CHARSET_REGISTRY part as iso10646. For example:


Adding to X Core Fonts

July 23, 2014 Linux No comments , ,

The X Core Font System is a very old font system of the X Window Server (some of the man pages are 25 years old!). However, some things (most notably bar ain’t recursive) still use it.

The default installed fonts for the Core Font System aren’t very nice, and I wanted to use my own. Fortunately, it not only has support for TrueType fonts (wow), but it’s very easy add them:

  • Navigate to the directory containing the fonts (e.g. /usr/share/fonts/truetype/ubuntu-font-family/)
  • Run mkfontscale then mkfontdir (you may need to install something like xfonts-utils)
  • Add something like xset fp+ /usr/share/fonts/truetype/ubuntu-font-family/ to your ~/.xinitrc file

Automatically Set Windows’ Icons based on GNOME Theme

July 17, 2014 Linux No comments , , , , ,

I’ve got a very nice Moka+Numix icon theme which works well with my dock and Nautilus, but unfortunately Openbox wasn’t picking up on it (not surprisingly, since the icon theme is a GNOME thing). As a result, the icons in Openbox’s Alt-Tab Switcher were inconsistent with the rest of my desktop.

It turns out that Openbox was using the icon specified in the X properties of the window. This is set by the application itself. Fortunately, there’s a rather useful xseticon script made by Paul “LeoNerd” Evans that allows for the modification of these icons. Together with Devil’s Pie, a look at the XDG Icon Theme Specifications, and small script, this allowed me to automatically set the icon for all windows, so that now everything is nice and consistent.

This requires xseticon, python-xdg, and xprop, all of which are in the Debian repositories (Wheezy).

The Devil’s Pie configuration file is:

Replace $HOME with your home directory.

The ~/.local/bin/set-xdg-icon looks like:

This can certainly be adapted for use with KDE, by just using whatever analogue of gsettings KDE has when determining the icon theme.

Note that some .desktop files don’t have the StartupWMClass set. In order to get the corresponding applications to work with this, you’ll need to add it with the WM_CLASS found by xprop‘ing the appropriate window.

Here’s a Gist.