[英]xmonad spacing between tiles
我正在使用以下内容,
layoutHook = smartBorders $ lessBorders OnlyFloat $ avoidStruts $ layoutHook defaultConfig
当工作空间中只有一个应用程序时禁用边框。 我要达到的目标是当我有2个或更多的时候在瓷砖之间留出空间。 我尝试将间距10添加到有效的混合中,但是当工作空间中只有一个窗口时,它仍然留有空间。 当工作空间中的瓷砖多于1个时,是否只能有间距?
这里的想法是创建一个布局修饰符,该修饰符可以识别只有一个窗口时的情况,因此不会缩小窗口。
这就是我在xmonad.hs中解决它的方式:
shrinkRect :: Int -> Rectangle -> Rectangle
shrinkRect p (Rectangle x y w h) = Rectangle (x+fi p) (y+fi p) (w-2*fi p) (h-2*fi p)
where fi n = fromIntegral n
这是缩小给定窗口的功能。
接下来,您必须定义布局修饰符:
data SmartSpacing a = SmartSpacing Int deriving (Show, Read)
instance LayoutModifier SmartSpacing a
where
pureModifier _ _ _ [x] = ([x], Nothing)
pureModifier (SmartSpacing p) _ _ wrs = (map (second $ shrinkRect p) wrs, Nothing)
modifierDescription (SmartSpacing p) = "SmartSpacing " ++ show p
最后,将其应用于布局的函数:
smartSpacing :: Int -> l a -> ModifiedLayout SmartSpacing l a
smartSpacing p = ModifiedLayout (SmartSpacing p)
您必须将smartSpacing
应用于要更改的布局,例如( Tall
在这里已更改):
myLayout = tiled ||| Mirror tiled ||| Full
where
-- Add spacing between windows
tiled = smartSpacing 3 $ Tall nmaster delta ratio
然后,您最终会像这样使用:
layoutHook = smartBorders myLayout
有关更多详细信息,您可以在这里查看我的xmonad.hs
另外,您可能必须在xmonad.hs中添加以下行才能进行编译:
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
聚苯乙烯
xmonad的最新版本已包含smartSpacing作为XMonad.Layout.Spacing模块的一部分,因此在这种情况下,您可以跳过定义rinkeRect,smartSpacing和SmartSpacing的定义(它们中已经有完全相同的代码)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.