简体   繁体   English

XMonad:按下生成键时具有焦点的SpawnOn工作空间

[英]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. 原因:我目前的设置是Arch Linux + XMonad,我让它在6台显示器上运行。 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. 我已经使用XMonad大约一年了,我唯一的问题是需要一段时间才能打开的程序。 For example the very first time I start chromium it takes 3 odd seconds to load. 例如,我第一次开始使用铬时需要3到几秒钟才能加载。 I press my key binding for chrome and then go to a different screen to do something else. 我按下我的键绑定chrome,然后转到另一个屏幕做其他事情。 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). 我以前在Lisp中编程并在C,python和JavaScript上花了很多时间,所以我确定如果需要的话我可以把它拿起来(所以请在答案中明确说明haskell样本)。

Thanks in advance. 提前致谢。

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. 这里的关键是增加了的manageSpawnmanageHook线。

Then replace your spawn s with spawnHere : 然后用spawnHere替换你的spawn

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

Becomes: 变为:

  , ((modMask, xK_w), spawnHere "chromium")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM