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

和自甴很熟 提交于 2019-12-10 02:56:30

问题


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.


回答1:


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")


来源:https://stackoverflow.com/questions/10752325/xmonad-spawnon-workspace-that-had-focus-when-spawn-key-was-pressed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!