Vlad Ioan Topan

My playground

Using a dark GTK 2 theme for Sylpheed in Windows

leave a comment »

What & why

The attempt to create similar development environments under Windows and Linux is a steep uphill climb – starting with the essentials (such as the development environment), but getting more and more frustrating as you get into aesthetic. Making something as “basic” as vim (or even better neovim) work (almost) the same cross-OS is a very interesting learning experience, and getting plugins to play nice with both kinds of paths, and library dependencies, and compilers, and linting for 5-10 languages, and code completion, and so on will either kill you or make you a better man (or woman, or helicopter, as the case may be). Making apps look the same on more than one OS is nigh impossible, and today’s topic is turning off the lights in Sylpheed (a marginally popular but very fast email client) under Windows.


Unlike many Windows apps which have some support for skins and/or themes, Sylpheed doesn’t. Under Linux this makes perfect sense, as that task is relegated to the window manager – more precisely to the UI toolkit, in this case GTK+ v2. The upshot of skinning the UI toolkit directly is that (in theory) applications have a unified look & feel. The downside is that there are several UI toolkits in use, and GTK+ alone has two incompatible versions widely employed by apps (2 and 3). This means that most cross-platform UI apps will either choose a toolkit or implement (at least) two versions, usually one for GTK+ and one for Qt. This leads us to the following question:

Which UI toolkit is my cross-platform app using?

Some software will have two binaries, named something along the lines of something-qt.exe and something-gtk.exe. Sylpheed has a single sylpheed.exe binary, so the name itself is of no help. Looking through its imported DLLs however will reveal libgtk-win32-2.0-0.dll, which means it’s GTK+ v2 (the 2.0.0 in the name means v2). If looking at imported DLLs sounds like jargon, just look through the program’s folder and subfolders for files ending in .dll. Qt*.dll means Qt (usually QtCore4.dll for v4 or Qt5Core.dll for v5), libgtk-*-[23].*.dll means GTK. If no such patterns show up, the binary is most likely built against the native Windows GUI (i.e. no cross platform toolkit is used), and if that’s the case, the UI will look “Windows-like” and can be styled using standard Windows themes.

Styling GTK+ 2

The look of GTK+ applications can be styled in great detail, but in incompatible ways between versions 2 and 3. Adding to the challenge, the folder paths where configuration and theme files must be placed are far less obvious on Windows (Linux has several standards on the topic but, although most distros have nuanced interpretations of said standards or just strong historical preferences, it’s generally obvious where configuration files must go).

GTK+ 2 expects a gtkrc file containing the styling configuration to be present in one of several predefined locations (e.g. ~/.gtkrc-2.0). To use a theme, the file must contain an entry like gtk-theme-name = "Sable-NC-3.14" (“Sable-NC-3.14” being the theme’s name), and the ~/.themes folder (or the global /usr/share/themes folder) must contain a Sable-NC-3.14 subfolder which in turn has a gtk-2.0 subfolder containing (at least) a gtkrc file describing the colors, fonts, icons etc. to be used.

On Windows, some apps look for the XDG_CONFIG_HOME environment variable, others don’t. Some use the %USERPROFILE% folder directly (usually C:\Users\<username>), others use the %LOCALAPPDATA% folder (usually C:\Users\<username>\AppData\Local). GTK+ 2 looks for folders named .gtkrc-2.0 and .gtk directly in %USERPROFILE%, so either can be used. The themes go in the C:\Users\<username>\.themes folder.

Guessing expected configuration file paths

But how do you figure out the paths without going through countless obsolete and / or irrelevant documentation pages? The cheating option is to watch Sylpheed’s file access attempts to guess what the expected paths are, and to do that an excellent option is Microsoft’s ProcMon. Download and run it, then ensure only file accesses are logged by leaving only the file cabinet icon highlighted on the toolbar:

Next, start Sylpheed and look for events with the process name sylpheed.exe. To make thing easier, right-click on one of the sylpheed.exe cells in the “Process Name” column and select “Include ‘sylpheed.exe’” – this will filter out events from other processes. To only see paths containing “gtk”, right-click on any path in the “Path” column and choose “Edit Filter ‘…’”, select “contains” instead of “is” from the second drop-down, type gtk in the text box and press “Add”. The file access attempts of interest (the ones inside C:\Users) should look like in the following picture:

The “Result” column should be filled with “NAME NOT FOUND” or “NO SUCH FILE”, but we do get the file / folder names. The configuration file should be either at c:\Users\<username>\gtkrc-2.0 or in a .gtk subfolder in that folder.

Finding a GTK+ 2 dark theme

The Internet has mostly moved on from GTK+ 2 to 3, but since some common apps haven’t, themes can still be found for GTK+ 2. Either try a web search for “gtk 2 dark theme” or try the traditional repository at gnome-look.org. I got the least eye-straining look from the Sable NC theme (the plain one, not the colored ones).

Putting it all together

The end result of the theme search should be an archive (to open *.tar.gz archives try the 7z archiver or WinRAR, or a proper file management tool like Total Commander). The archive should at some level have a gtk-2.0 folder, and that’s what we’re after. Create a c:\Users\<username>\.themes\<theme-name> folder for each theme you want to try out and place the gtk-2.0 subfolder from the theme archive in it. Then create a c:\Users\<username>\gtkrc-2.0 file containing gtk-theme-name = "<theme-name>" and restart Sylpheed. The end result should look something like this:

Sylpheed – Sable NC dark theme

Written by vtopan

November 21, 2018 at 8:03 PM

Posted in Uncategorized

Tagged with , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: