[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

This is an old revision of the document!


Xmonad as a Windowmanager for Slackware

Xmonad is a tiling windowmanager, for information about tiling windowmanagers please read this wiki: wikipedia

For Xmonad read here xmonad.org

Required packages

Xmonad is not included in Slackware by default, but available via slackbuilds.org. Xmonad is written in Haskell and therefore some packages of the Haskell-series are required in order to build Xmonad. Here the packages in the correct order:

  1. ghc (the glasgow-haskell-compiler)
  2. haskell-syb
  3. haskell-utf8-string
  4. haskell-X11
  5. haskell-transformers
  6. haskell-mtl
  7. xmonad
  8. haskell-random
  9. xmonad-contrib
  10. haskell-hinotify
  11. haskell-stm
  12. haskell-X11-xft
  13. haskell-text
  14. haskell-parsec
  15. xmobar

I would also recommend to install dwm and trayer (note that trayer is not yet available via slackbuilds.org, but I'm considering to write a slackbuild-script).

Configuration of Xmonad

After building and installing the above packages you can configure Xmonad

.xinitrc

the following sections of my .xinitrc configure dbus, the mousepointer and trayer, then xmonad is started

# Use dbus-launch if installed.
if test x"$DBUS_SESSION_BUS_ADDRESS" = x""; then
 dbuslaunch=`which dbus-launch`
 if test x"$dbus-launch" != x"" -a x"$dbus-launch" != x"no"; then
  eval `$dbus-launch --sh-syntax --exit-with-session`
 fi
fi
xsetroot -cursor_name left_ptr

trayer --edge top --align right --SetDockType true --SetPartialStrut true \
         --expand true --width 10 --transparent true --height 14 &

exec xmonad
Configuring xmobar

xmobar displays useful information, in my case in the top-part of the desktop. Here an example for the file .xmobarrc

Config { font = "-misc-fixed-bold-R-normal-*-13-*-*-*-*-*-*-*"
    , bgColor = "#1074EA"
    , fgColor = "#DDDDDD"
    , position = TopW L 90
    , commands = [ Run BatteryP ["BAT1"]
               ["-t", "<acstatus><watts> (<left>%)",
                "-L", "10", "-H", "80", "-p", "3",
                "--", "-O", "<fc=green>On</fc> - ", "-o", "",
                "-L", "-15", "-H", "-5",
                "-l", "red", "-m", "blue", "-h", "green"] 60
          , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
          , Run CpuFreq ["-t", "<cpu0> <cpu1>", "-L", "0", "-H", "2",
                  "-l", "lightblue", "-n","white", "-h", "red"] 50
          , Run Memory ["-t","Mem: <usedratio>%"] 10
          , Run Swap [] 10
          , Run Date "%a %d. %B %H:%M Uhr" "LC_TIME=date" 10
          , Run StdinReader
          ]
    , sepChar = "%"
    , alignSep = "}{"
    , template = "%StdinReader% }{ <fc=#FFD700>%date%</fc> | %cpu%  %cpufreq% | %memory% %swap% | Bat: %battery% "
    }

for an explanation please read the manuals.

xmonad.hs

Here as an example my ~/.xmonad/xmonad.hs file

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

myManageHook = composeAll
  [ className =? "Gimp"   --> doFloat
  , className =? "Vlc"    --> doFloat
  ]

main = do
  xmproc <- spawnPipe "/usr/bin/xmobar /home/markus/.xmobarrc"
  xmonad $ defaultConfig
    { manageHook = manageDocks <+> manageHook defaultConfig
    , layoutHook = avoidStruts $ layoutHook defaultConfig
    , logHook = dynamicLogWithPP xmobarPP
            { ppOutput = hPutStrLn xmproc
            , ppTitle = xmobarColor "green" "" . shorten 50
            }
    } `additionalKeys`
    [ ((mod4Mask, xK_c  ), kill)
     ,((mod4Mask, xK_Return ), spawn "xterm")
    ]							]

Please read the documentation for xmonad.hs, this is only an example (which works well for me).

Additional Hints

When using a tiling windowmanager one experiences that some applications behave unusual. In my above xmonad.hs you see Vlc and Gimp in the List of programs which should float. In order to find out the so called “Classname” of the application (through which the application can be detected by the windowmanager, there is a script in the xmonad-contrib package. You can find it in /usr/share/doc/xmonad-contrib-0.10/scripts/ directory.

Sources

 howtos:window_managers:xmonad_tiling_window_manager ()