Xmonad: A Config

24 November 2018 · 2 minute read

“[play] the voluntary attempt to overcome unnecessary obstacles“

— Bernard Suits

Lately some of my play has been trying out different window managers and desktop environments. My little laptop has a little screen and a trackpad that’s good for clicking but not dragging. So it’s a good case for tiling window managers.

The latest experiment was with xmonad which does its config in Haskell. I like having a task bar so I replaced the usual mode bar with tint2. Here’s my version of a config largely built off of John Goerzen’s tutorial

screenshot of xmonad with tint2 panel

Here’s the main ~/.xmonad/xmonad.hs configuration file. I’ve added XMonad.Hooks.EwmhDesktops to handle fullscreen apps like steam games and XMonad.Actions.WindowBringer for keyboard based window switching.

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

main = do
    xmonad $ ewmh $ defaultConfig -- ewmh is used for fullscreen games
        { manageHook = manageDocks <+> manageHook defaultConfig
        , layoutHook = avoidStruts  $  layoutHook defaultConfig
        , handleEventHook = fullscreenEventHook -- handle fullscreen games
        , modMask = mod4Mask     -- Rebind Mod to the Windows key
        } `additionalKeys`
        [ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock")
        , ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
        , ((0, xK_Print), spawn "scrot")
        , ((mod4Mask, xK_g     ), gotoMenu) -- quick menus for switching windows
        , ((mod4Mask, xK_b     ), bringMenu)

The second piece is a .xsession file to start tint2 and the other helper apps.


xrdb -merge .Xresources

# Set the background color<
xsetroot -solid midnightblue

~/.fehbg &

tint2 &
# Fire up apps
xscreensaver -no-splash &
if [ -x /usr/bin/nm-applet ] ; then
   nm-applet --sm-disable &

volumeicon &

exec xmonad