例如,我想绑定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')
)