Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMonad: SpawnOn workspace that had focus when spawn key was pressed

I would like to have my programs spawn on the screen that was in focus when its keybinding was pressed not on the screen thats currently in focus when it finishes loading.

Why: My current setup is Arch Linux + XMonad and I have it running on 6 monitors. I have been using XMonad for about a year now and my only issue with it is for programs that take a little while to open. For example the very first time I start chromium it takes 3 odd seconds to load. I press my key binding for chrome and then go to a different screen to do something else. But when chrome loads it loads on the screen im currently focused on not on the screen that was focused at the time the spawn key binding was pressed.

My haskell skills are well... non existent. I have programmed in Lisp before and spend a lot of time in C, python and JavaScript so im sure I can pick it up if need be (so please be clear when it comes to haskell samples in answers).

Thanks in advance.

like image 324
Nick Avatar asked May 25 '12 09:05

Nick


1 Answers

I found the answer to my own question.

First you must add to your imports:

import XMonad.Actions.SpawnOn

Then under your main function have something like:

main = do
xmonad $ defaultConfig
    {    
         manageHook = myManageHooks <+> manageSpawn <+> manageDocks <+> manageHook defaultConfig
       , startupHook = myStartupHook
       , ETC.....

The key here was the addition of the manageSpawn in the manageHook line.

Then replace your spawns with spawnHere:

  , ((modMask, xK_w), spawn "chromium")

Becomes:

  , ((modMask, xK_w), spawnHere "chromium")
like image 168
Nick Avatar answered Nov 09 '22 00:11

Nick