2

I am trying to set up auto start of my main applications.

Following xmonad spawn on startup in different workspace I have added the following to my startupHook

startup :: X ()
startup = do
          setWMName "LG3D"
          spawnOn "workspace1" "urxvt"
          spawnOn "workspace2" "emacs"
          spawnOn "workspace3" "chromium"

but there are three problems:

  1. I am duplicating the definition of my terminal. It seems like I should be using shellPromptOn but it takes an extra parameter and I don't know where to get it from.
  2. this is putting everything on my current workspace. How can I find out what my workspaces are called? I don't believe I've customised the names, you can see my .xmonad/xmonad.hs on github to confirm
  3. this will start the apps again on a xmonad --restart. How can we guard against that? It is very useful to be able to restart xmonad without quitting and I don't want to lose that ability.
Community
  • 1
  • 1
fommil
  • 5,757
  • 8
  • 41
  • 81
  • Were you able to solve the second point? I am using the same procedure and mine are also starting on the current workspace. Similar to you, I did not change my workspace names either. – meguli Oct 03 '19 at 10:49

2 Answers2

0
  1. You can move your terminal value into a function that can both be called by xmonad and startup.

terminal = "urxvt"

spawnOn "workspace1" terminal

  1. Not a complete solution but just thought I'd mention there is spawnOnce - it doesn't allow you to select a spawning workspace though.
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
0

For the 2. case, I was able to do something like following:

On my startup, I have something similar to what the question shows but with changed workspace names

startup :: X ()
startup = do
          spawnOn "ed" "code-insiders"
          spawnOn "www" "opera" 
          spawnOn "slack" "slack" 

Which makes them start on current workspace. To move them to respective workspaces, I had to add a ManageHook as follows:

myManageHook :: ManageHook
myManageHook = composeAll
   [ className =? "Code - Insiders" --> doShift "ed"
   , className =? "Opera"      --> doShift "www"
   , className =? "Slack"  --> doShift "slack"
   , manageDocks
   ]

To learn the className of an app, like "Code - Insiders" above, you need to run following in a terminal

$ xprop | grep WM_CLASS

and click on the window of desired program with the given mouse pointer. This will write the className onto terminal.

meguli
  • 1,426
  • 1
  • 18
  • 35