Ato*_*ton 5 x11 xmonad xdotool
我正在努力做相同的事情
xdotool search "Chromium" windowactivate --sync key --clearmodifiers ctrl+r
Run Code Online (Sandbox Code Playgroud)
即我想切换到Chromium并重新加载当前页面.但是,使用XMonad,我收到以下错误:
Your windowmanager claims not to support _NET_ACTIVE_WINDOW, so the attempt to activate the window was aborted.
Run Code Online (Sandbox Code Playgroud)
在XMonad中有一种方法可以以编程方式切换到某个应用程序吗?
这是我使用的,受到 XMonad.Util.WindowBringer 的启发。您需要安装 Text.PCRE 包。如果我忘记了任何导入声明,请道歉。
import XMonad
import qualified XMonad.StackSet as W
import XMonad.Util.NamedWindows (getName)
import Control.Applicative ((<$>))
import Data.List (find)
import Text.Regex.PCRE ((=~))
findWindow :: String -> X (Maybe Window)
findWindow regex = do
wmap <- concat <$> (mapM mappings =<< (W.workspaces <$> gets windowset))
:: X [(String, Window)]
return (snd <$> find ((=~ regex) . fst) wmap)
where mappings :: WindowSpace -> X [(String, Window)]
mappings ws = mapM mapping $ W.integrate' (W.stack ws)
mapping w = flip (,) w <$> show <$> getName w
warpTo :: String -> X ()
warpTo regex =
findWindow regex >>= (flip whenJust $ windows . W.focusWindow)
Run Code Online (Sandbox Code Playgroud)
原则上您应该能够将密钥绑定到warpTo "Chromium" >> spawn "xdotool key --clearmodifiers ctrl+r". 然而,这对我不起作用,显然是由于我不明白的一些竞争条件。幸运的是,我发现以下方法有效:
warpTo "Chromium" >> spawn "sleep 0.2; xdotool key --clearmodifiers ctrl+r"
Run Code Online (Sandbox Code Playgroud)
您也许能够以更短的延迟逃脱。
| 归档时间: |
|
| 查看次数: |
550 次 |
| 最近记录: |