![如何配置 xmonad 以遵循粘性 (_NET_WM_STATE_STICKY) 和浮动 (_NET_WM_STATE_ABOVE) 窗口标签](https://linux22.com/image/207711/%E5%A6%82%E4%BD%95%E9%85%8D%E7%BD%AE%20xmonad%20%E4%BB%A5%E9%81%B5%E5%BE%AA%E7%B2%98%E6%80%A7%20(_NET_WM_STATE_STICKY)%20%E5%92%8C%E6%B5%AE%E5%8A%A8%20(_NET_WM_STATE_ABOVE)%20%E7%AA%97%E5%8F%A3%E6%A0%87%E7%AD%BE.png)
一个xprop
对此类窗口的调用会在其_NET_WM_STATE
属性中显示这两个标志:
WM_STATE(WM_STATE):
window state: Normal
icon window: 0x0
_NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE, _NET_WM_STATE_STICKY
...
WM_NAME(UTF8_STRING) = "Picture in picture"
_NET_WM_NAME(UTF8_STRING) = "Picture in picture"
我们如何设置xmonad尊重这两面旗帜?
答案1
解决办法是:
- 使窗口标记为
_NET_WM_STATE_ABOVE
浮动。 - 将标记为 的窗口复制
_NET_WM_STATE_STICKY
到所有工作区。
import Data.Maybe ( fromMaybe )
import XMonad.Actions.CopyWindow ( copyToAll )
import XMonad.Util.WindowProperties ( getProp32 )
-- Other standard xmonad imports omitted.
myManageHook =
composeAll
$ [ hasNetWMState "_NET_WM_STATE_ABOVE" --> doFloat
, hasNetWMState "_NET_WM_STATE_STICKY" --> doF copyToAll
, ...
]
where
-- | Get the `_NET_WM_STATE` property as a list of atoms.
getNetWMState :: Window -> X [Atom]
getNetWMState w = do
atom <- getAtom "_NET_WM_STATE"
map fromIntegral . fromMaybe [] <$> getProp32 atom w
hasNetWMState :: String -> Query Bool
hasNetWMState state = do
window <- ask
wmstate <- liftX $ getNetWMState window
atom <- liftX $ getAtom state
return $ elem atom wmstate