Saturday, November 14, 2009

Linux: My xmonad Setup

Since I already blogged about why I think xmonad is interesting, I thought I would take the time to blog about my xmonad setup. I'd like to thank arjuna del toso for his instructions, because that's how I got started.

Start by installing all the software:
apt-get install xmonad libghc6-xmonad-contrib-dev libghc6-xmonad-dev dwm-tools feh
Now, edit /usr/share/xsessions/xmonad.desktop so that it executes "xmonad.start" instead of "xmonad".

Then create /usr/local/bin/xmonad.start:

xrdb -merge .Xresources

gnome-panel &
syndaemon -d -t

# feh --bg-scale /usr/share/backgrounds/warty-final-ubuntu.png &
# xsetroot -solid "#978989" # Lighter gray.
xsetroot -solid "#636161" # Darker gray.

# This must be started before seahorse-daemon.
eval $(gnome-keyring-daemon)

# This is all the stuff I found in "Startup Applications".
/usr/lib/gnome-session/helpers/at-spi-registryd-wrapper &
bluetooth-applet &
sh -c 'test -e /var/cache/jockey/check || exec jockey-gtk --check 60' &
# sh -c "sleep 30; exec /usr/lib/evolution/2.26/evolution-alarm-notify"
# gnome-keyring-daemon --start
# /usr/bin/canberra-gtk-play --id="desktop-login" --description="GNOME Login"
# /usr/lib/gnome-session/helpers/gnome-session-splash
sh -c "sleep 60 && python /usr/share/gnome-panel/" &
nm-applet --sm-disable &
sh -c "sleep 1 && gnome-power-manager" &
sh -c "sleep 31 && system-config-printer-applet > /dev/null 2> /dev/null" &
# /usr/lib/vino/vino-server &
update-notifier --startup-delay=60 &
# gnome-at-visual -s

exec xmonad
You might wonder how I came up with all of that. I started with the xmonad documentation. Then, I opened up "Startup Applications" when logged into my GNOME desktop in order to figure out what I wanted to recreate. Some of the things I decided I didn't need. Some of the things had to be tweaked to run outside the context of a normal Ubuntu environment.

Make the script executable:
chmod +x /usr/local/bin/xmonad.start
Now, create ~/.xmonad/xmonad.hs:
import XMonad hiding (Tall)
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.SetWMName
import XMonad.Layout.Circle
import XMonad.Layout.Magnifier
import XMonad.Layout.HintedTile

myLayout = avoidStruts $ hintedTile Tall ||| hintedTile Wide ||| Circle
||| magnifier Circle ||| Full
-- hintedTile listens to application hints, so as not to break gVim.
hintedTile = HintedTile nmaster delta ratio TopLeft
nmaster = 1
delta = 3/100
ratio = 1/2

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

main = do
xmonad $ defaultConfig
{ manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig

-- I used to use: avoidStruts $ layoutHook defaultConfig
, layoutHook = myLayout

-- This hack is necessary to make Java GUIs like NetBeans work. See the FAQ.
, logHook = setWMName "LG3D"
To test that you got the syntax right:
ghci ~/.xmonad/xmonad.hs
Note that I decided not to use xmobar, which is a text-based status bar. It's just not my thing, although you might want to read arjuna del toso's instructions and give it a shot.

Last of all, there was one more incredibly esoteric hack that was necessary. If you using xmonad + NetBeans + jVi, then using ":w" to save your file will cause NetBeans to lock up. Weird, I know. The workaround is to edit your jVi preferences to tell jVi not to handle Control-s, but rather to pass it to the IDE. That way, you can use Control-s to save your file instead of using ":w".

Make sure to read the guided tour and check the xmonad FAQ if you have any issues.

No comments: