13

I know how to associate specific applications with specific workspaces using manageHook and composeAll. What I'm looking for is a way to spawn applications on specific workspaces, i.e. a function with type signature String -> workSpaceId -> X () whose example use would be something like:

spawnToWorkspace "emacs" "2:code"
user63896
  • 181
  • 1
  • 6

3 Answers3

9

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.

geekosaur
  • 12,091
5

Okay, it was actually easier than I thought:

spawnToWorkspace :: String -> String -> X ()
spawnToWorkspace program workspace = do
                                      spawn program     
                                      windows $ W.greedyView workspace
user63896
  • 181
  • 1
  • 6
0

For geekosaur's answer to work you also need to tell XMonad to manage the Spawns using the manageHook setting:

xmonad $ def
{
  ...
  , ...
  , manageHook = manageSpawn <+> manageHook def
  , ...
}

After you include this setting spawnOn should work as expected.

Worthwelle
  • 4,816
mose
  • 1
  • 2