例如,我想綁定Mod+ Shift+m將我帶到類名為“Emacs”的窗口,這樣我就可以立即切換到該應用程序,無論我在哪個工作區以及我正在關注哪個窗口。
答案1
https://stackoverflow.com/a/50427647/1663462
module WindowFinder where
import XMonad
import qualified XMonad.StackSet as W
import Control.Monad
import Data.Bool (bool)
findWindows :: String -> X [Window]
findWindows name = do
withWindowSet $ (\ws -> do
forM (W.allWindows ws)
(\w -> do
s <- withDisplay $ \d -> fmap resClass . liftIO $ getClassHint d w
return $ bool [] [w] (s == name) :: X [Window]
) >>= return . join
)
導入上述模組後,您可以設定以下鍵綁定:
, ((modm, xK_c), do
win' <- findWindows "Chromium"
when (length win' > 0)
(windows $ W.focusWindow $ head win')
)