Haskell

Recent site activity

Notes‎ > ‎

XMonad

posted Aug 3, 2008 3:09 PM by Wei Hu   [ updated Mar 17, 2010 8:26 AM ]
UPDATE: I no longer maintain this page. My configuration is available at http://github.com/wh5a/arch/tree/master/.xmonad/. To use my configuration you need to patch xmonad-contribs a little bit or delete some code.

Read the man page first and then the guided tour for key ideas and default key bindings. You can also find many tips at the wiki, an Arch Linux page, XMonad.Doc.Extending, and Desktop Environments @ Arch Linux forum. Another interesting guide is by John Goerzen. A few layout examples.

Coq proof.

Interesting changes can be found at http://www.haskell.org/haskellwiki/Xmonad#Documentation.

By convention, one pane is denoted as the master pane (usually the top or the left, depending on the current tiling mode). The top left window is called the master window. Other tiling algorithms are possible, (for example, fullscreen mode, or floating windows), and in these the concept of a `pane' has no real meaning. 

When a program launches, it's inserted before the focused window.
 
Recommended software:
 
Terminal: rxvt-unicode (from the multi-lingual full-featured rxvt-unicode-ml)
Program launcher: dmenu (status-bar like, from dwm-tools), or gmrun (popup launcher)
Status bar: dzen (from dzen2), or xmobar
System tray: trayer
Task bar: This is called panel in X. Panels must be EWMH compliant. apt-cache search ewmh turns up two panel programs: fbpanel and pypanel, and one systray: stalonetray. XMonad supports panels with the XMonad.Hooks.EwmhDesktops module. A nice looking program: tint2.
 
Some important snapshots showing the contributed layouts are missing. Find them here.
 

~/.xmonad/xmonad.hs

-- To get Xft support, configure XMonadContrib with --flags="use_xft"
-- Configure xmobar with --flags="with_xft"
-- Or build them with "cabal install -fYOUR_FLAG"

import XMonad
import XMonad.Layout.NoBorders
import XMonad.Util.EZConfig
import XMonad.Hooks.ManageDocks
-- {{ Prompt    
-- http://braincrater.wordpress.com/2008/11/29/pimp-your-xmonad-3-prompt/
import XMonad.Prompt
import XMonad.Prompt.RunOrRaise
--import XMonad.Prompt.Shell
import XMonad.Prompt.Window
import XMonad.Prompt.XMonad
import XMonad.Prompt.AppLauncher
-- Prompt }}
import XMonad.Actions.SpawnOn
import XMonad.Util.Run
-- http://haskell.org/haskellwiki/Xmonad/Config_archive/John_Goerzen%27s_Configuration#Configuring_xmonad_to_use_xmobar
import XMonad.Hooks.DynamicLog
import XMonad.Actions.SinkAll
import Data.List
    
myXPConfig = defaultXPConfig {
               --font = "-misc-fixed-*-*-*-*-13-*-*-*-*-*-*-*"
               --Couldn't get xft to work on gentoo using bitstream-vera
               --On arch it's just fine
               font = "xft:Droid Sans Mono:pixelsize=14"
             , position = Top
             --, height = 30
             }

-- If q contains x
contain q x = fmap (isInfixOf x) q

myManageHook = composeAll . concat $
    [ [ title `contain` c --> doFloat | c <- myFloats ]
--    , [ className =? "Firefox-bin" --> doShift "web" ]
    ]
    where myFloats = ["Option", "option", "Preference", "preference"]

main = do
  sp <- mkSpawner
  xmproc <- spawnPipe "xmobar /home/wh5a/.xmonad/xmobarc"
  xmonad $
         defaultConfig {
         modMask = mod4Mask
       , terminal = "urxvtc"
       , manageHook = manageSpawn sp <+> manageDocks <+> manageHook defaultConfig <+> myManageHook
       , layoutHook = avoidStruts $ smartBorders $ layoutHook defaultConfig
       , logHook = dynamicLogWithPP $ xmobarPP {
                     ppOutput = hPutStrLn xmproc
                   , ppTitle = xmobarColor "yellow" "" -- . shorten 52
                   }
       }
       `additionalKeysP`
       [ -- dmenu replacement
         ("M-p", shellPromptHere sp myXPConfig)
       --, ("M-r", runOrRaisePrompt myXPConfig)
       , ("M-g", windowPromptGoto myXPConfig)
       , ("M-x", xmonadPrompt myXPConfig)
       , ("M-e", launchApp myXPConfig "emacsclient -c -a emacs")
       , ("M-S-k", kill)
       , ("M-d", sinkAll)
       ]
 

~/.xinitrc

#export LC_ALL="zh_CN.UTF-8"
export LC_ALL="en_US.UTF-8"
export XMODIFIERS=@im=ibus
export GTK_IM_MODULE="ibus"
# test the term: emacs -nw -f list-colors-display
export TERM=rxvt-256color
xsetroot -cursor_name left_ptr
xrdb -merge .Xresources
urxvtd -q -f -o
ibus &
urxvtc &
xhost +local:root
exec xmonad
 

~/.Xresources

Rxvt.background: black
Rxvt.foreground: white
URxvt.font: xft:Bitstream Vera Sans Mono-12
URxvt.scrollBar_right: True
Rxvt.jumpScroll: True
Rxvt.skipScroll: True
URxvt.preeditType: OnTheSpot

! man urxvtperl
URxvt.perl-ext-common: default,-option-popup,matcher,-selection-popup,xim-onthespot
URxvt.urlLauncher: firefox
URxvt.matcher.rend.0: fg8 Uline Italic
!URxvt.colorUL: #86a2be
! Right click to launch the URL
URxvt.matcher.button: 3

!Xcursor.theme: gentoo
!Xcursor.size: 21

!You can disable Emacs' X Input support
!Emacs.useXIM: false

~/.xmonad/xmobarc

Config { font = "xft:WenQuanYi Zen Hei Mono-10"
       , bgColor = "black"
       , fgColor = "grey"
       , position = Top
       , lowerOnStart = True
       , commands = [ 
                      Run Cpu ["-L","3","-H","50","--normal","green","--high","red","-t","<total>"] 50
                    , Run Date "%a %b/%_d %H:%M" "date" 600
                    , Run StdinReader
                    ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = "%StdinReader%}{|%cpu% <fc=#ee9a00>%date%</fc>"
       }