Start applications on specific workspaces in xmonad

Solution 1:

The more correct (and modern; I don't think SpawnOn was in the released XMonad back then, an awful lot of good stuff was only in darcs) way to do this is to

import XMonad.Actions.SpawnOn

and then use the action

spawnOn "2:code" "emacs"

See http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-SpawnOn.html for details.

Solution 2:

Okay, it was actually easier than I thought:

spawnToWorkspace :: String -> String -> X ()
spawnToWorkspace program workspace = do
                                      spawn program     
                                      windows $ W.greedyView workspace