From e00093fb569b5b66f657228e9bcdc463b727bd4b Mon Sep 17 00:00:00 2001 From: la-ninpre Date: Fri, 10 Mar 2023 17:33:50 +0300 Subject: small refactoring config from library no longer contains main function (which was odd), now user have to specify bells and whistles they want to put in their xmonad. workspaces and layout names are now easier to swap. --- lib/XMonad/Config/LaNinpre.hs | 46 ++++++++++++++++++++++--------------------- xmonad.hs | 21 ++++++++++++++++++++ 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/lib/XMonad/Config/LaNinpre.hs b/lib/XMonad/Config/LaNinpre.hs index 6f36fe5..bb86142 100644 --- a/lib/XMonad/Config/LaNinpre.hs +++ b/lib/XMonad/Config/LaNinpre.hs @@ -69,7 +69,7 @@ import XMonad.Layout.Simplest (Simplest(Simplest)) import XMonad.Layout.Spacing ( spacingWithEdge , toggleWindowSpacingEnabled - , toggleScreenSpacingEnabled + , toggleScreenSpacingEnabled, Border (top) ) import XMonad.Layout.SubLayouts ( GroupMsg(UnMerge, UnMergeAll) @@ -384,8 +384,8 @@ spawnSelected' conf lst = gridselect conf lst >>= flip whenJust spawn -- list of keybindings. it supposed to override the default keybindings. -- | keybindings in 'EZConfig' format -keybinds :: [(String, X ())] -keybinds = [ ("M-", spawn terminalEmulator) +keybinds :: [String] -> [(String, X ())] +keybinds ws = [ ("M-", spawn terminalEmulator) , ("M-w", spawn webBrowser) , ("M-p", spawn "dmenu_run") , ("M-", spawn "slock") @@ -439,7 +439,7 @@ keybinds = [ ("M-", spawn terminalEmulator) ] ++ [("M-" ++ m ++ show k, windows $ f i) - | (i, k) <- zip workspacesTP [1..9] + | (i, k) <- zip ws [1..9] , (f, m) <- [(W.greedyView, ""), (W.shift, "S-")] ] @@ -458,7 +458,7 @@ localXmobarPP = def , ppHiddenNoWindows = xmobarColor (col_bg_alt def) "" . sitelen , ppLayout = sitelen } where - sitelen = xmobarFont 3 + sitelen = xmobarFont 1 -- | status bar config statusBarConfig :: StatusBarConfig @@ -488,26 +488,35 @@ tabTheme = def -- * misc +-- | names for layouts +-- +-- this is to allow specifying layout names. not very flexible but plausible. +data LayoutNames = LayoutNames + { tiledName :: String + , threeColName :: String + , fullName :: String + } + -- | layout hook -- -- __NOTE__: it uses sitelen-pona font to name layouts. -localLayoutHook = windowNavigation +localLayoutHook ln = windowNavigation $ boringWindows $ toggleLayouts full $ smartBorders $ tiled ||| threeCol where - tiled = renamed [Replace "\xe624"] -- lawa + tiled = renamed [Replace $ tiledName ln] -- lawa $ addTabs shrinkText tabTheme $ subLayout [] Simplest $ spacingWithEdge space $ ResizableTall nmaster delta ratio [] - threeCol = renamed [Replace "\xe665"] -- supa + threeCol = renamed [Replace $ threeColName ln] -- supa $ addTabs shrinkText tabTheme $ subLayout [] Simplest $ spacingWithEdge space $ ResizableThreeColMid nmaster delta ratio [] - full = renamed [Replace "\xe663"] -- suli + full = renamed [Replace $ fullName ln] -- suli $ noBorders Full nmaster = 1 ratio = 1/2 @@ -516,28 +525,21 @@ localLayoutHook = windowNavigation -- | main config -- --- you can override things like that: +-- takes a list of workspaces and @LayoutNames@, be sure to specify them. -- -- @ --- myConfig = laNinpreConfig { workspaces = 'workspacesNorm' } +-- myConfig = laNinpreConfig workspacesNorm -- main = xmonad myConfig -- @ -laNinpreConfig = def +laNinpreConfig ws ln = def { terminal = terminalEmulator , modMask = mod4Mask - , layoutHook = localLayoutHook + , layoutHook = localLayoutHook ln , manageHook = localManageHook - , workspaces = workspacesTP + , workspaces = ws , borderWidth = 1 - , keys = (`mkKeymap` keybinds) + , keys = (`mkKeymap` keybinds ws) , normalBorderColor = col_bg_alt def , focusedBorderColor = col_fg_alt def } -main :: IO () -main = xmonad - . ewmhFullscreen - . ewmh - . withEasySB statusBarConfig defToggleStrutsKey - $ laNinpreConfig - diff --git a/xmonad.hs b/xmonad.hs index e407c68..0448ec7 100644 --- a/xmonad.hs +++ b/xmonad.hs @@ -1 +1,22 @@ +import XMonad + +import XMonad.Hooks.EwmhDesktops (ewmhFullscreen, ewmh) +import XMonad.Hooks.StatusBar (defToggleStrutsKey, withEasySB) + import XMonad.Config.LaNinpre + (LayoutNames(..) + , laNinpreConfig + , statusBarConfig + ) + +wsMin = [ "", "", "

", "", "", "", "", "", "" ] + +layoutNames = LayoutNames "l" "s" "u" + +configMin = laNinpreConfig wsMin layoutNames + +main = xmonad + . ewmhFullscreen + . ewmh + . withEasySB statusBarConfig defToggleStrutsKey + $ configMin -- cgit v1.2.3