如何配置 xmonad 以遵循粘性 (_NET_WM_STATE_STICKY) 和浮动 (_NET_WM_STATE_ABOVE) 窗口标签

如何配置 xmonad 以遵循粘性 (_NET_WM_STATE_STICKY) 和浮动 (_NET_WM_STATE_ABOVE) 窗口标签

一个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

解决办法是:

  1. 使窗口标记为_NET_WM_STATE_ABOVE浮动。
  2. 将标记为 的窗口复制_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

相关内容