Metacity add-ons Brightside and Devil's Pie

City Lights


If the no-frills Metacity window manager doesn't give you the functionality you need, try the Metacity add-ons Brightside and Devil's Pie.

By Oliver Frommel

Philip Date, FOTOLIA

Software is no exception to the rule that there's no accounting for taste. Some users enjoy a full-featured, almost baroque approach, while others prefer to keep things more business-like. Window managers take this choice to extremes, from the minimalist TWM to the highly complex Enlightenment, a window manager that decorates its windows with bells, whistles, and even animations [1].

Metacity, the window manager for the Gnome desktop, is designed for simplicity and does not confuse users with an overabundance of options. To achieve this aim, Metacity concentrates on the window manager's core business: drawing window decorations, organizing windows, and moving windows. Gnome applets step in to handle additional functions such as virtual desktops.

This article describes a pair of programs called Brightside and Devil's Pie that add useful features to Metacity. Brightside provides mouse support to the corners and edges of the Gnome desktop, allowing users to toggle between virtual desktops, for example. Devil's Pie gives users the ability to specify various actions for the desktop to perform when launching programs. Both programs use Extended Window Manager Hints [2] to communicate with the window manager.

Active Corners

Some distributions, such as Ubuntu Dapper Drake and Fedora Core 5, include Brightside in their repositories. As an alternative, you can always build the program yourself using the packages from [3]. Brightside is fairly frugal with respect to dependencies; in fact, you mainly just need the typical Gnome libraries.

Libwnck is the slightly unusual exception to this rule. Libwnck serves up information on the active desktop programs and facilitates programming of tools such as task switchers.

After giving the make install command to install the program, you should have the brightside and brightside-properties binaries on your disk. You will find Brightside in the Gnome menu below System | Preferences | More Preferences. Brightside is configured using the brightside-properties tool (Figure 1). To enable the actions you configure with Brightside, you either need to launch Brightside manually, or add it to the list of programs to launch when starting a Gnome session in gnome-session-properties.

Figure 1: Brightside lets users assign an action to each corner of the desktop.

A default action is configured for each of the four corners of the screen; you can modify the action in the drop down from disabling and enabling sound output, enabling the screensaver, or even hibernating a machine.

Unfortunately, all of these actions are hard-coded instead of being defined through a configuration file. In our lab, the start screensaver function did not work because it uses commands for the Xscreensaver tool, which Fedora Core 5 does not have.

Defining Actions

Metacity supports custom actions that let you assign actions other than the defaults to reactive corners. When you select a custom action, Brightside pops up a small dialog where you can enter the program to run (Figure 2). To start the Fedora Core 5 screensaver via a reactive corner, just enter gnome-screensaver-command -activate for On entering region. You do not have to configure the options Brightside gives you for leaving the reactive corner: the screensaver is automatically disabled when you drag the mouse.

Figure 2: The Custom action setting gives users the ability to specify a program for Brightside to run.

Smooth Switching

The edge flipping feature, which lets you switch between virtual desktops when you drag the mouse over the left or right edge of the screen, is also an interesting Brightside option. A configurable delay prevents inadvertent switching (see Figure 1). Incidentally, Brightside not only works with Metacity. In our lab, we discovered that it would support Fluxbox and WMX, two alternatives to Metacity on Fedora.

Devil's Pie

The Metacity developers have deliberately avoided adding a feature that organizes windows in an intelligent way. In the developers' opinion, this is not part of the window manager's job description. Instead, Gnome developer Ross Burtonini fired up his editor and compiler, and wrote a tool that fills the gap.

Devil's Pie [4] gives users the ability to specify what happens to an application at launch time based on configuration files. The configurable behavior includes how to organize the application window on screen, whether to add an entry to the task list, the position on the virtual desktop, or whether to use window decorations. It is definitely worthwhile adding Devil's Pie as a permanent feature for any Gnome session.

Lisp Syntax Preferred over XML

Up until version 0.12, Devil's Pie used XML-formatted configuration files, but 0.13 introduced a syntax based on S expressions, which are mainly seen in the context of the Lisp programming language. The files reside in the $HOME/.devilspie directory and are recognizable by their .ds extension. Each file can only contain a single rule that governs a single application. For example, the following expression sends the application window to the second virtual desktop when the Amule P2P client is launched:

(if
  (is (application_name) "amule")
  (set_workspace 2)
)

The following configuration file maximizes the Kaffeine media player at launch:

(if
    (matches (application_name) "Kaffeine Player")
    (maximize)
)

Using the fullscreen keyword instead of maximize would launch Kaffeine in full-screen mode. If you change a configuration file, don't forget to relaunch devils--pie to apply the changes. If the changes do not have the desired effect, set the -d flag when launching the program for troubleshooting. As an alternative, you can add a (debug) directive at the end of the configuration file.

Devil's Pie can handle regular expressions, just like any decent Unix tool, using the matches keyword. If you want the program to execute a group of instructions for a single application, the begin keyword indicates the start of the group:

(if
   (matches (application_name) "Firefox")
   (begin
        (geometry "600x800")
        (center)
   )
)

The Devil's Pie Wiki [6] and the tutorial at [7] provide more details on using and configuring Devil's Pie.

Almost Perfect

Devil's Pie uses simple text files to control how the desktop handles applications you launch. Brightside adds reactive corners and edge flipping.

Unfortunately, Brightside is not as flexible as it could be, as it only supports simple user-configurable actions. A configuration file that specifies basic actions might be a better approach.

INFO
[1] Overview of X window managers: http://xwinman.org
[2] Extended Window Manager Hints: http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html
[3] Brightside: http://home.jesus.ox.ac.uk/~ecatmur/brightside
[4] Devil's Pie: http://www.burtonini.com/blog/computers/devilspie
[5] S Expressions: http://theory.lcs.mit.edu/~rivest/sexp.html
[6] Devil's Pie Wiki: http://live.gnome.org/DevilsPie
[7] Devil's Pie Tutorial: http://wiki.foosel.net/linux/devilspie