Monday, July 18, 2011

X with xmonad without KDE/gnome, continued

This is the setup I settled upon in the end, it's working great. It has heavily based on this wiki page.

The .xsession file:

#!/bin/bash

# Load resources

xrdb -merge .Xresources

# Set up an icon tray

trayer --edge top --align right --SetDockType true --SetPartialStrut true \
--expand true --width 10 --transparent true --tint 0x191970 --height 12 &

# Set the background color 

xsetroot -solid midnightblue 


# Fire up apps 


xscreensaver -no-splash & 


if [ -x /usr/bin/nm-applet ] ; then nm-applet --sm-disable & fi 


if [ -x /usr/bin/gnome-power-manager ] ; then sleep 3 gnome-power-manager & fi


#xset b off 


eval `gpg-agent --daemon` 
eval `ssh-agent --daemon` 


setxkbmap -option compose:caps 


exec xmonad

In order to have X execute the .xsession isof starting the window manager itself, choose the "System default" as session type in gdm or kdm.

This is my .Xresource file:


# red cursor Color, looks great in combination with xmonad
xterm*cursorColor: red

# save tons of lines
xterm*saveLines: 100000

# triple click like in konsole/gnome-termimal
xterm*on3Clicks: regex [^ \n]+
xterm*on4Clicks: line

# use fancy terminus font
xterm*FaceName: terminus-10


This is the .xmobarrc file:


Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 90
, lowerOnStart = True
, commands = [
Run Weather "EBDT" ["-t"," C","-L","64","-H","77","--normal","green","--high","red","--low","lightblue"] 36000,
Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10,
Run Memory ["-t","Mem: %"] 10,
Run Swap [] 10,
Run Date "%a %b %_d %H:%M" "date" 10,
Run StdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ ancalagon %cpu% | %memory% * %swap% %date% | %EBDT%"
}


ancalagon is the name of my laptop.

Finally, this is the .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

main = do
xmproc <- spawnPipe "xmobar" xmonad $ defaultConfig { manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
--, modMask = mod4Mask -- Rebind Mod to the Windows key
} `additionalKeys`
[ ((controlMask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock")
, ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
, ((0, xK_Print), spawn "scrot")
]



With big thanks to John Goerzen for providing the excellent information.

No comments: