1

Like, many, others, I am trying to spawn a program on a specific Xmonad workspace at startup.

Here is my xmonad.hs that should start Firefox on workspace 4:

import XMonad
import XMonad.Actions.SpawnOn

myStartupHook :: X()
myStartupHook = spawnOn "4" "/usr/bin/firefox"

main :: IO()
main = xmonad $ defaultConfig {
  modMask = mod4Mask,
  startupHook = myStartupHook,
  }

However, upon startup, Firefox is launched on workspace 1 instead of 4. According to this Reddit thread, all I need to do is add manageSpawn somewhere in this code. Here is what I tried:

import XMonad
import XMonad.Actions.SpawnOn

myStartupHook :: X()
myStartupHook = spawnOn "4" "/usr/bin/firefox"

main :: IO()
main = xmonad $ defaultConfig {
  modMask = mod4Mask,
  startupHook = manageSpawn <+> myStartupHook,
  }

But I got the following error: Couldn't match type Query (base-4.13.0.0:Data.Semigroup.Internal.Endo WindowSet) with X () Expected type: X () Actual type: ManageHook. The documentation for spawnOn is not really helpful either.

What do I need to add the above xmonad.hs to start Firefox on workspace 4?

Jaap Joris Vens
  • 929
  • 10
  • 23

1 Answers1

1

You should set manageSpawn to be the manageHook rather than the startupHook. Here is a working xmonad.hs that spawns Firefox on workspace 4:

import XMonad
import XMonad.Actions.SpawnOn

myStartupHook :: X()
myStartupHook = spawnOn "4" "/usr/bin/firefox"

main :: IO()
main = xmonad $ defaultConfig {
  modMask = mod4Mask,
  startupHook = myStartupHook,
  manageHook = manageSpawn
  }
Jaap Joris Vens
  • 929
  • 10
  • 23