Personal tools

Xmonad/Using xmonad in KDE

From HaskellWiki

< Xmonad(Difference between revisions)
Jump to: navigation, search
(Disable KDE multi desktops before you begin)
(Fixed config, changed other sections to match it)
Line 16: Line 16:
 
== Related reading ==
 
== Related reading ==
   
The [http://haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome GNOME/xmonad] page.
+
The [http://haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome GNOME/xmonad] page. Read this, really. Much of what is written there also applies to KDE,
  +
and is not repeated here.
   
 
== Before you begin ==
 
== Before you begin ==
Line 24: Line 24:
 
'''Desktop''' > '''Multiple desktops''', and set the number
 
'''Desktop''' > '''Multiple desktops''', and set the number
 
of desktops to 1.
 
of desktops to 1.
  +
  +
== Sample xmonad configuration for KDE ==
  +
  +
As usual, place xmonad configuration in <code>~/.xmonad/xmonad.hs</code>.
  +
  +
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.
  +
  +
<haskell>
  +
  +
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"]
  +
ircApps = ["Ksirc"]
  +
  +
</haskell>
  +
  +
'''Note:''' To get the class name for an application:
  +
# Open the application.
  +
# Enter the command <code>xprop | grep WM_CLASS</code> in a terminal window on the same desktop.
  +
# Click on the application window.
  +
# Read the class name in the terminal window.
  +
  +
Thanks to everyone on [http://haskell.org/haskellwiki/IRC_channel #xmonad]
  +
for all the help in putting together
  +
this vastly improved sample xmonad configuration.
   
 
== Make xmonad your window manager in KDE ==
 
== Make xmonad your window manager in KDE ==
Line 40: Line 91:
 
by hand it may be something like <code>/home/$USER/bin/xmonad</code>.
 
by hand it may be something like <code>/home/$USER/bin/xmonad</code>.
   
== Dealing with KDE windows ==
+
== Restart your KDE session ==
   
Without doing anything, you now have a working KDE environment.
+
Now end your current KDE session and start a new one.
One nice thing is that system notification windows will pop-up as small windows in the upper left window.
+
Welcome to xmonad with KDE!
   
=== KDE desktop and panel applets ===
+
== Tips and issues ==
 
The KDE desktop appears as a separate window in xmonad.
 
Some KDE panel applets also appear as a
 
separate window in xmonad and do not install into the panel.
 
You may want to reserve a separate xmonad desktop for these,
 
separate from the desktop you use for the panel itself.
 
 
Note that among the applets that appear in a separate
 
window is the xkb applet that switches between
 
different keyboard layouts. That allows you the flexibility
 
of managing its location in xmonad.
 
 
=== Xmonad Configuration ===
 
 
<haskell>
 
 
import XMonad
 
 
import XMonad.Config
 
 
import qualified XMonad.StackSet as W
 
 
main = xmonad $ defaultConfig
 
{ manageHook = manageHook defaultConfig <+> myManageHook
 
}
 
where
 
myManageHook = composeAll . concat $
 
[ [ className =? c --> doFloat | c <- myFloats]
 
, [ title =? t --> doFloat | t <- myOtherFloats]
 
, [ resource =? r --> doIgnore | r <- myIgnores]
 
, [ className =? "Firefox-bin" --> doF (W.shift "2:web") ]
 
, [ className =? "Opera" --> doF (W.shift "2:web") ]
 
]
 
where
 
myIgnores = ["gnome-panel", "desktop_window", "kicker",
 
"KDE Desktop", "KNetworkManager", "KMix",
 
"Power Manager", "KPowersave", "klipper",
 
"knotes", "panel", "stalonetray", "trayer"]
 
myFloats = ["MPlayer", "Gimp", "kdesktop"]
 
myOtherFloats = ["alsamixer"]
 
 
</haskell>
 
   
After ignoring the KDE kicker and panels, they will all be placed on the first desktop, which should be reserved for these items. It looks kind of odd, but it works.
+
* As in Gnome, you currently cannot switch the focus to a window by clicking on it in the task bar. Use the xmonad keys.
   
== KDE Configuration ==
+
* 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?''
   
If you don't use the KDE kicker bar much, you may want to configure the kicker bar to autohide, and show when the mouse touches the lower left corner of the screen. Right click on the bar, select "Configure Panel", select "Hiding" on the left, select "Hide Automatically", select "Raise when the pointer touches the screen's", select "Lower left Corner"
+
* 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.
  +
# Create a symbolic link to xscreensaver in <code>~/.kde/Autostart</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 23:07, 8 April 2008

Xmonad-logo-small.png

XMonad

Below configuration is for xmonad 0.5, known to work on Kubuntu

Screen-sjanssen-kde-kicker.png

Contents

1 Motivation

Easier system monitoring on laptops with networking widget.

Ability to browse all programs and utitlities with desktop bar (kicker)

Easy integration of Xmonad on a system using kdm for logins

2 Related reading

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

3 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.

4 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
 }
 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"]
   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.

5 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, and if you compiled xmonad by hand it may be something like /home/$USER/bin/xmonad.

6 Restart your KDE session

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

7 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.