Linux Yak First (Part 3): Unpacking a Theme

If you don’t have Linux installed, you might want to start with Part 1. If you want an overview of the basic apps in a desktop environment, try Part 2. At this point we’re going to talk even more specifically about Xfce, in particular on Debian-based distros like Ubuntu or Mint.

You may have come across a description of Linux that mentioned that configuration was always stored in plain text. While I’m sure there are some exceptions, this concept is true; most any kind of configuration you change on the system through a GUI is really just updating a value in a readable configuration file somewhere on your system.

Generally, system configuration is stored in /etc/, whereas user configuration is stored in in your home directory. If you’re running Xfce, you likely have a directory in your home directory, .config/autostart/. Let’s look at what’s in there on my system:

at-spi-dbus-bus.desktop
ckb.desktop
enpass.desktop
Franz.desktop
rambox.desktop
xfce4-clipman-plugin-autostart.desktop

And let’s look at what in a .desktop file (this is enpass.desktop):

[Desktop Entry]
Type=Application
Name=Enpass
Exec= /opt/Enpass/bin/runenpass.sh startWithTray
Icon=enpass.png
Comment=The best password manager
X-GNOME-Autostart-Delay=12
X-GNOME-Autostart-enabled=true

You don’t need to know what all the lines in this file do, but Name=, Exec=, Icon=, and Comment= are probably recognizable. If you really wanted to edit this file directly instead of using the Xfce settings manager, you could. Perhaps more importantly, If you want to backup or copy these settings from one computer to another, you now know exactly where these settings are stored.


It doesn’t stop there. Let’s look in /usr/share/themes/Default/ and what actually makes up an XFCE theme.

balou/  gtk-2.0-key/  gtk-3.0/  xfce-notify-4.0/  xfwm4/

Some themes have more or less subfolders. Balou is the splash screen app while XFCE loads. There are settings for GTK 2 and GTK 3 apps, Xfce notifications, and lastly for xfwm, Xfce’s window manager. xfwm controls what all the window borders look like, including the buttons in the top left or right that let you minimize/maximize/close windows. Out of the box, macs don’t let you control the appearance of window borders. Windows does, but all the components are hidden with a special .vsstyle file.

If we dig into the xfwm4/ directory, we can a lot of plain old PNG files, XPM files, and a themerc file. The themerc file is plain text settings — here’s an excerpt:

button_offset=2
button_spacing=0
full_width_title=true

Xfwm themes can also pickup and use colors from GTK. Turns out XPM is just another plain text format — let’s look at bottom-left-active.xpm:

/* XPM */
static char * bottom_left_active_xpm[] = {
"16 16 3 1",
" c None",
"# c #C0C0C0 s active_color_2",
"@ c #C0C0FF s active_color_2",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@ ",
"@@@@@@@@@@@@@@@@",
"@@@@@@@@@@@@@@@@",
" @@@@@@@@@@@@@@@");

XPM files are just ascii art. "16 16 3 1" says it’s 16px by 16px, uses 3 colors, and uses 1 character per pixel; the next three lines define the colors (and if available, which GTK colors to use), and all the rest is just ascii art. Even this far down into the theme, files are still just plain text and easy to read and edit.

One of the consequences of the Unix philosophy is that configuration is almost always stored in the simplest format it can. Most is plain text. Sometimes its just regular images or media. It’s rare that binary or specialized formats are ever used. This keeps even configuration simple to read, backup, and edit. For example, if we wanted to change the button spacing in the default Xfce theme, even without any GUI we could go into the themerc file and edit that line. If we wanted to square out the bottom corners, we could edit a handle of PNGs and XPM files.

You develop an expectation that you should have this level of control. Over time, the idea feels so natural it feels like a right you should always have. It’s your system — you should be able to control how it looks and works.

Show your support

Clapping shows how much you appreciated Kevin Hamer’s story.