Start applications on specific workspaces in xmonad

13

2

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

Posted 2011-02-07T03:17:38.130

Reputation: 181

Answers

5

Okay, it was actually easier than I thought:

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

user63896

Posted 2011-02-07T03:17:38.130

Reputation: 181

1This is the only solution that seems to work, it appears that spawnOn from XMonad-Contrib is broken with newer versions of XMonad. – eazar001 – 2013-11-11T05:10:51.933

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

Posted 2011-02-07T03:17:38.130

Reputation: 10 195

6Does this still work? I'm on xmonad 0.10 and using spawnOn still seems to just spawn the application on the current workspace... – bhh1988 – 2012-08-05T04:41:44.063