Difference between revisions of "Xmonad/Using xmonad in KDE"

From HaskellWiki
Jump to navigation Jump to search
m (Minor clarifications)
(Clarify and expand a bit the Motivation section)
Line 7: Line 7:
   
 
== Motivation ==
 
== Motivation ==
  +
  +
You've heard about the wonders of Xmonad, and you want to try it out.
  +
But you're a [http://www.kde.org/ KDE] user, and you want to stay with KDE because of:
   
 
* Ability to browse all programs and utitlities with desktop bar (kicker).
 
* Ability to browse all programs and utitlities with desktop bar (kicker).
 
* Easy integration of Xmonad on a system using kdm for logins.
 
* Easy integration of Xmonad on a system using kdm for logins.
 
* Easier system monitoring on laptops with networking widget.
 
* Easier system monitoring on laptops with networking widget.
  +
* Best environment for running GUI applications developed with [http://trolltech.com/products/qt Qt].
  +
* Consistent user interface and shared system services for the vast collection of KDE applications.
  +
* You're just used to it.
  +
  +
Then this page is for you.
   
 
== Related reading ==
 
== Related reading ==
Line 22: Line 30:
 
== Versions ==
 
== Versions ==
   
The following instructions are optimized and tested for
+
The following instructions are optimized and tested (so far) for
 
xmonad 0.7 and KDE 3.5.
 
xmonad 0.7 and KDE 3.5.
   
Line 79: Line 87:
 
# Enter the command <code>xprop | grep WM_CLASS</code> in a terminal window on the same desktop.
 
# Enter the command <code>xprop | grep WM_CLASS</code> in a terminal window on the same desktop.
 
# Click on the application window.
 
# Click on the application window.
# Read the class name in the terminal window. The class name is the second of the two strings displayed, usually capitalized.
+
# Read the class name in the terminal window. The class name is the second of the two quoted strings displayed, usually capitalized.
   
Thanks to everyone on [http://haskell.org/haskellwiki/IRC_channel #xmonad]
+
Thanks to everyone on [http://haskell.org/haskellwiki/IRC_channel #xmonad],
  +
especially sjanssen,
for all the help in putting together
 
this vastly improved sample xmonad configuration.
+
for all the help in putting together this sample xmonad configuration
  +
for KDE.
   
 
== Make xmonad your window manager in KDE ==
 
== Make xmonad your window manager in KDE ==
Line 97: Line 106:
 
where "<code>/path/to/xmonad</code>" is the path to the xmonad
 
where "<code>/path/to/xmonad</code>" is the path to the xmonad
 
binary on your system. For example, on Debian systems this
 
binary on your system. For example, on Debian systems this
is <code>/usr/bin/xmonad</code>, and if you compiled xmonad
+
is <code>/usr/bin/xmonad</code>. If you compiled xmonad
by hand it may be something like <code>/home/$USER/bin/xmonad</code>.
+
from source, it may be something like <code>/home/$USER/bin/xmonad</code>.
   
 
== Restart your KDE session ==
 
== Restart your KDE session ==
Line 107: Line 116:
 
== Tips and issues ==
 
== 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.
+
* As in Gnome, you currently cannot switch the focus to a window by clicking on it in the task bar. Use xmonad keys, or use the mouse on the window itself.
   
 
* Also as in Gnome, it is '''very important''' not to use the xmonad <code>mod-shift-q</code> key to exit your session. Use the KDE menu or panel applet. ''How do you bind an xmonad key to exit a KDE session?''
 
* Also as in Gnome, it is '''very important''' not to use the xmonad <code>mod-shift-q</code> 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:
 
* 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:
*# Disable the KDE screensaver in the KDE Control Center.
 
 
*# Make sure that xscreensaver is installed.
 
*# Make sure that xscreensaver is installed.
 
*# Disable the KDE screensaver in the KDE Control Center.
 
*# Create a symbolic link in <code>~/.kde/Autostart</code> to the command <code>xscreensaver</code>.
 
*# Create a symbolic link in <code>~/.kde/Autostart</code> to the command <code>xscreensaver</code>.
 
*# Create a KDE button and/or xmonad key to run the command <code>xscreensaver-command -lock</code> or <code>xscreensaver-command -activate</code>.
 
*# Create a KDE button and/or xmonad key to run the command <code>xscreensaver-command -lock</code> or <code>xscreensaver-command -activate</code>.

Revision as of 09:45, 9 April 2008

Xmonad-logo-small.png

XMonad

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

Screen-sjanssen-kde-kicker.png

Motivation

You've heard about the wonders of Xmonad, and you want to try it out. But you're a KDE user, and you want to stay with KDE because of:

  • 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.
  • Best environment for running GUI applications developed with Qt.
  • Consistent user interface and shared system services for the vast collection of KDE applications.
  • You're just used to it.

Then this page is for you.

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.

Versions

The following instructions are optimized and tested (so far) 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.

The following 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 a specific desktop 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
 }
 where
   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"] -- open on desktop 2
   ircApps       = ["Ksirc"]                -- open on desktop 3

Note: To get the class name of an application for use in the above:

  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. The class name is the second of the two quoted strings displayed, usually capitalized.

Thanks to everyone on #xmonad, especially sjanssen, for all the help in putting together this sample xmonad configuration for KDE.

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:

KDEWM=/path/to/xmonad

where "/path/to/xmonad" is the path to the xmonad binary on your system. For example, on Debian systems this is /usr/bin/xmonad. If you compiled xmonad from source, 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 xmonad keys, or use the mouse on the window itself.
  • 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. Make sure that xscreensaver is installed.
    2. Disable the KDE screensaver in the KDE Control Center.
    3. Create a symbolic link in ~/.kde/Autostart to the command xscreensaver.
    4. Create a KDE button and/or xmonad key to run the command xscreensaver-command -lock or xscreensaver-command -activate.
    5. Restart your KDE session.