12

I am trying to configure my xmonad.hs so that when I start my session I start an array of different programs on different workspaces (like Terminal in 1 ; Firefox in 2 ; Pidgin in 3).

I already looked into the XMonad.Actions.SpawnOn, but as spawnOn returns with an X () and not with a common m () I can not use it in main = do ....

Is there a function that takes an X-monad and returns with IO () or is there another workaround?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
salbeira
  • 2,375
  • 5
  • 26
  • 40
  • X is an instance of Monad, so `X ()` works with `m ()` - you can use do-notation with `X ()` actions. – amindfv Apr 24 '13 at 17:20

1 Answers1

12

The common way is to use startupHook which takes X () action and performs it on each startup. E.g.

main = xmonad $ defaultConfig
  { startupHook = do
      spawnOn "workspace1" "program1"
      …
      spawnOn "workspaceN" "programN"
  }
Matvey Aksenov
  • 3,802
  • 3
  • 23
  • 45
  • 1
    I called my workspaces according to their function "Terminal" "Web" "Chat" etc. , but passing these names as arguments for the spawnOn function does not work with certain programs (such as eclipse). I am currently working around it with setting up Manage Hooks for each application, like className =? "Firefox" --> doF(W.shift (customWorkspaces !! 1)) and spawning them with a regular spawn – salbeira Jun 11 '12 at 12:30
  • 4
    Note `spawnOn` is from the xmonad-contrib package – amindfv Apr 24 '13 at 17:21
  • 8
    I've got { startupHook = do spawnOn "workspace2" "emacs" }, but the program is just started on the first workspace after login, or the current workspace if I restart xmonad. – Roger Garza Feb 21 '14 at 15:37
  • 4
    1) what are the default workspace names? 2) this will start new apps on a reload, not just a fresh startup. How can this guard against a restart? – fommil Feb 26 '17 at 11:10