[英]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.