Tasty KDE Desktop Themes

Bonjour, mes amis! Welcome back to my restaurant, “Chez Marcel”. Please, sit down. Francois has prepared your usual table and will be along with your wine tout de suite.

This month's menu features “Linux on the Desktop”. Your desktop, like any well-dressed table, should reflect something of your personality. Do you use gold-edged silver cutlery or stainless steel? Is candlelight a must for your dinners? Are your napkins linen, cotton or paper? Most important, of course, is to simply enjoy your meal. The well-dressed table, like the well-dressed Linux desktop, simply enhances the experience.

Okay, I admit it; I am stretching the metaphor, but what's a meta for if not for stretching? François! Better bring me a glass, as well. As for you, my welcome guests, let me show you how you, too, can develop a desktop theme that reflects your personality.

On your K Desktop (I am running 1.1.2), you will find the theme manager under the Settings/Desktop menu. Using this tool, you can easily import new themes (see Resources for links), delete old themes, create and modify them. Despite great strides in the development of the theme manager, creating and modifying a theme is still largely a command-line job. The theme manager is used primarily to manage existing themes, a job it does very well.

Using the theme manager, I created the skeleton for a “Cooking” theme by clicking on “Create”. Imagine that, non! This created a default structure for my theme in the directory /home/marcel/.kde/share/apps/kthememgr/Work/Cooking. As I mentioned, this is primarily a command-line (or editor) job. The theme manager allowed me to save my settings and apply changes on the fly as I worked out the details of my theme. A note of caution, though: when you click “Save”, your current working directory will be erased and rebuilt. Before clicking on “save”, you need to go back a directory (cd ..) before continuing. Once you have saved your theme and applied it, you can safely go back into the Work/Theme_name directory.

There are several components in a theme. They include icons, colors and fonts, borders and so on. Each of these is defined in a .themerc file for your theme. In my case, I have a Cooking.themerc file. The default built by the theme manager includes only the title and author information, in the [General] section of the file. Here's what mine looked like immediately after the Theme Manager created it:

# KDE Config File
Author=Marcel Gagné
description=Chez Marcel chef Marcel Gagné brings you his Cooking with Linux theme

This is only the beginning of the template; it requires several more sections, each with its own details: Display, Colors, File Manager and Window Border, to name a few.

If you feel so inclined and have a lot of wine to drink, you can write every section of your .themerc manually. My method involves copying the system .themerc template to the one created by the theme manager. You can find the system template under your KDE share directory. On an RPM system like mine, it is called /usr/share/apps/kthememgr/Themes/Template.themerc. I use the cat command to do the copying with the following single line (ignore wrapping):

cat /usr/share/apps/kthememgr/Themes/
Template.themerc >> /home/marcel/.kde/share/apps/kthememgr/

This gives me a complete template to work with. Using vi to edit the file, I removed the template's [General] section and left my own in place. For my Cooking with Linux theme, I used only the Display, Window Border, Window Titlebar and Window Button Layout sections.

Getting Creative

So, you want to create a theme, eh? Before we begin, let me give you some quick technical notes. All of my graphics were either created or modified using the GIMP. You could use another package to do this, but why would you? Other than the desktop wallpaper, which is a .jpg file, all images are in .xpm format and indexed before saving.

In creating this recipe, I started with a background I knew had to be food-related. A few years ago, at a very strange New Year's party in our home, a couple of friends offered to bring a veggie tray. This veggie tray was a joy to behold, with hard-boiled egg islanders, carrot palm trees and mushroom huts. We were so impressed, we took a picture of it. This was my starting point. With a little modification in the GIMP, I added Tux, gave him a glass of wine and sat him under a celery palm. Here are the specifics from the [Display] section.


Next, I created buttons. The way I see it, when you minimize a window, you are essentially offering it a glass of wine and giving it a rest. What better icon than a glass of wine, non? Then came maximizing a window to the desktop—sort of like “spooning” it out onto the desktop, n'est-ce pas? Et voil<\#224>, a spoon! The sticky button was obvious as well. You stab the window with a fork and anchor it, pointing down to stick and up to unstick (also the default position). Finally, I needed a close button, the great coup de gr<\#226>ce that dispatches a window. Ah, oui! A knife of the finest steel.

Figure 1. Icons

All these icons form the [Window Titlebar] section. They can be up to 20 pixels in height and width. Before finishing here, I created a pixmap for the titlebar, a salad look and feel. The difference between the active titlebar and the inactive one is brightness. Finally, I right-aligned the text. Here is the resulting section:

[Window Titlebar]

Buttons can be positioned anywhere you wish. There are six possible button positions: three on the left and three on the right. Since I tend to click before I think, I decided to stay with the default positions. However, if you are feeling dangerous, you could switch the Iconify and Close positions. Ah, the romance of living on the edge! Here is the section in question:

[Window Button Layout]
Window borders are a strange thing to me—I both love and hate them. On one hand, they decorate; on the other, they take up valuable desktop real estate on my notebook's panel display. For those times I feel wild and foolish, I decided to throw in a flash of color to my borders. For corner icons, I brought Tux and his wine glass back. The resulting entry from my “.themerc” follows.
[Window Border]
The border sections, like the window titlebar, need not be terribly long. KDE will automatically tile your image to fill any window. There is a catch, though, and let me tell you that I ached over this one for quite some time. You need to make sure the borders can line up with the corner. If you create a 20-by-20-pixel corner icon, make sure you line it up with a 20-pixel width border.

You know, as the Perl motto goes, “there is more than one way to do it”. Clicking “Save” each time you make changes in the theme manager is just one way to do it. If the constant refreshing of your Work directory gets tiring after awhile, resort to your old friend, the command line, and create your own lovely tar bundle. Gzipped, bien sûr. To simplify the image here, I will step back a directory and back up my bundle from there. Remember, I was in the Work/Cooking directory.

cd ..
tar -czvf Cooking.tar.gz Cooking

This will create my Cooking.tar.gz theme bundle. The catch, if you do it this way, is that you then need to copy the bundle back to your ~/.kde/share/apps/kthememgr/Themes directory.

In any case, when you are satisfied with your work, you can upload it to your favorite theme site for all the world to savor. It can then be installed with the theme manager using the Add function. For your viewing pleasure, Figure 2 is a picture of the resulting theme. Should you be so inspired, you may download a copy from the Linux Journal web site or from my own. Surely, fame and fortune are then only a heartbeat away, non?

Figure 2. Cooking Theme

Well, mes amis, it is once again closing time. Do come back soon. You are always welcome at Chez Marcel. Bon Appétit!


Marcel Gagné lives in Mississauga, Ontario. In real life, he is president of Salmar Consulting Inc., a systems integration and network consulting firm. He is also a pilot, writes science fiction and fantasy and edits TransVersions, a science fiction, fantasy and horror magazine. He loves Linux and all flavors of UNIX and will even admit it in public. He can be reached via e-mail at mggagne@salmar.com. You can discover lots of other things from his web site at http://www.salmar.com/.


Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot