Xmonad/Using xmonad in KDE

From HaskellWiki
< Xmonad
Revision as of 08:21, 9 April 2008 by YitzGale (talk | contribs) (Related reading is no longer required to get started quickly)

Jump to: navigation, search


Here's how to configure Xmonad to work with KDE.



  • Ability to browse all programs and utitlities with desktop bar (kicker).
  • Easy integration of Xmonad on a system using kdm for logins.
  • Easier system monitoring on laptops with networking widget.

Related reading

The GNOME/xmonad page. Read that, really. Much of what is written there also applies to KDE and is not repeated here.

But if all you want is to get started quickly with Xmonad in KDE, read on.


The following instructions are optimized and tested for xmonad 0.7 and KDE 3.5.

Before you begin

Make sure that KDE is not configured for multiple desktops. To configure that, open the KDE Control Center, select Desktop > Multiple desktops, and set the number of desktops to 1.

Sample xmonad configuration for KDE

As usual, place xmonad configuration in ~/.xmonad/xmonad.hs.

This sample configuration sets up xmonad to cooperate with the KDE desktop and panel; for more details about how this works, see the Gnome page. This configuration also does the following:

  • uses the Windows key instead of the Alt key as "mod" for xmonad (freeing up Alt for common emacs-style key bindings in applications)
  • causes certain applications to launch as floating windows
  • automatically sends certain applications to other desktops when they launch.
import XMonad
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
import qualified XMonad.StackSet as W

main = xmonad $ defaultConfig

 { manageHook            = manageHook defaultConfig <+> myManageHook
 , logHook               = ewmhDesktopsLogHook
 , layoutHook            = avoidStruts $ layoutHook defaultConfig
 , modMask               = mod4Mask -- use the Windows button as mod
   myManageHook = composeAll . concat $
     [ [manageDocks]
     , [ className   =? c --> doFloat           | c <- myFloats]
     , [ title       =? t --> doFloat           | t <- myOtherFloats]
     , [ className   =? c --> doF (W.shift "2") | c <- webApps]
     , [ className   =? c --> doF (W.shift "3") | c <- ircApps]
   myFloats      = ["MPlayer", "Gimp"]
   myOtherFloats = ["alsamixer"]
   webApps       = ["Firefox-bin", "Opera"]
   ircApps       = ["Ksirc"]

Note: To get the class name for an application:

  1. Open the application.
  2. Enter the command xprop | grep WM_CLASS in a terminal window on the same desktop.
  3. Click on the application window.
  4. Read the class name in the terminal window.

Thanks to everyone on #xmonad for all the help in putting together this vastly improved sample xmonad configuration.

Make xmonad your window manager in KDE

Create the directory ~/.kde/env if it does not already exist. Create a file there called set_window_manager.sh containing only the following line of text:


where "/path/to/xmonad" is the path to the xmonad binary on your system. For example, on Debian systems this is /usr/bin/xmonad, and if you compiled xmonad by hand it may be something like /home/$USER/bin/xmonad.

Restart your KDE session

Now end your current KDE session and start a new one. Welcome to xmonad with KDE!

Tips and issues

  • As in Gnome, you currently cannot switch the focus to a window by clicking on it in the task bar. Use the xmonad keys.
  • Also as in Gnome, it is very important not to use the xmonad mod-shift-q key to exit your session. Use the KDE menu or panel applet. How do you bind an xmonad key to exit a KDE session?
  • The KDE screensaver does not work properly with xmonad. It can lock the screen, but the screen remains blank. Until someone figures out how to fix this, you can use xscreensaver:
  1. Disable the KDE screensaver in the KDE Control Center.
  2. Make sure that xscreensaver is installed.
  3. Create a symbolic link to xscreensaver in ~/.kde/Autostart.
  4. Create a KDE button and/or xmonad key to run the command xscreensaver-command -lock or xscreensaver-command -activate.