Web Development & Programming Thoughts

By Timothy Elliott

Dwm with Gnome Guide

2/24/2009

I've been running dwm on Ubuntu for while now. Some conveniences, such as wireless network selection, font settings and automounting of USB drives don't work out of the box without various Gnome services running.

This guide describes how to get dwm to run nicely in the default Gnome environment as a drop-in replacement for metacity. Not because you want every Gnome service, panel, and applet running on your desktop, but because the best way to get the perfect desktop is to start as close as possible the implementation of your distribution, and to chip away at unneeded settings and services from there.

This guide was written using Ubuntu Hardy Heron as a reference and has since been updated for Intrepid Ibex. It should apply to all Gnome desktops.

Set a window manager in your .gnomerc file

Edit the file ~/.gnomerc and add the following line:

export WINDOW_MANAGER=dwm
Turn off Nautilus desktop management

Enter the following into a console to tell Nautilus not to manage your desktop:

gconftool --type boolean --set /apps/nautilus/preferences/show_desktop false

Configure dwm to handle gnome-panel nicely

By default, dwm will resize gnome-panel when it starts up. This causes gnome-panel to become unusable. Add the following tagging rule to your dwm config.h to prevent gnome-panel from being resized, and to auto-tag it into your 8th workspace:

/* tagging */
static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */
static Rule rules[] = {
        /* class      instance    title       tags mask     isfloating */
        { "Gimp",     NULL,       NULL,       0,            True },
        { "Firefox",  NULL,       NULL,       1 << 8,       True },
        { "Gnome-panel", NULL,    NULL,       1 << 7,       True },
};

Set quit and logout keys

The default dwm quit command (<modkey> + <shift> + q) kills the dwm client. With gnome session running, this leaves you with an unusable desktop. The following dwm config.h lines will cause dwm to issue the gnome session shutdown command for <modkey> + <shift> + q and the gnome session logout command for <modkey> + <shift> + l :

/* commands */
static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[]  = { "uxterm", NULL };
static const char *powercmd[] = { "gnome-session-save", "--shutdown-dialog", NULL };
static const char *logoutcmd[]= { "gnome-session-save", "--logout-dialog", NULL };

static Key keys[] = {
        /* modifier                     key        function        argument */
        { MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
        { MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
        { MODKEY,                       XK_b,      togglebar,      {0} },
        { MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
        { MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
        { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
        { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
        { MODKEY,                       XK_Return, zoom,           {0} },
        { MODKEY,                       XK_Tab,    view,           {0} },
        { MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
        { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
        { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
        { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
        { MODKEY,                       XK_space,  setlayout,      {0} },
        { MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
        { MODKEY,                       XK_0,      view,           {.ui = ~0 } },
        { MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
        TAGKEYS(                        XK_1,                      0)
        TAGKEYS(                        XK_2,                      1)
        TAGKEYS(                        XK_3,                      2)
        TAGKEYS(                        XK_4,                      3)
        TAGKEYS(                        XK_5,                      4)
        TAGKEYS(                        XK_6,                      5)
        TAGKEYS(                        XK_7,                      6)
        TAGKEYS(                        XK_8,                      7)
        TAGKEYS(                        XK_9,                      8)
        { MODKEY|ShiftMask,             XK_l,      spawn,          {.v = logoutcmd } },
        { MODKEY|ShiftMask,             XK_q,      spawn,          {.v = powercmd } },
};

References

Dwm homepage

Using xmonad with Gnome