xmonad: Move config from home to system

This commit is contained in:
Alexander Kobjolke 2024-02-11 15:32:03 +01:00
parent 3f138a5d76
commit 5e6aaabb6d
3 changed files with 81 additions and 77 deletions

View file

@ -1,77 +0,0 @@
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Util.EZConfig
import XMonad.Util.Loggers
import XMonad.Util.Ungrab
import XMonad.Layout.Magnifier
import XMonad.Layout.ThreeColumns
import XMonad.Hooks.EwmhDesktops
main :: IO ()
main = xmonad
. ewmhFullscreen
. ewmh
. withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey
$ myConfig
myConfig = def
{ modMask = mod4Mask -- Rebind Mod to the Super key
, layoutHook = myLayout -- Use custom layouts
, manageHook = myManageHook -- Match on certain windows
}
`additionalKeysP`
[ ("M-S-z", spawn "xscreensaver-command -lock")
, ("M-C-s", unGrab *> spawn "scrot -s" )
, ("M-f" , spawn "firefox" )
]
myManageHook :: ManageHook
myManageHook = composeAll
[ className =? "Gimp" --> doFloat
, isDialog --> doFloat
]
myLayout = tiled ||| Mirror tiled ||| Full ||| threeCol
where
threeCol = magnifiercz' 1.3 $ ThreeColMid nmaster delta ratio
tiled = Tall nmaster delta ratio
nmaster = 1 -- Default number of windows in the master pane
ratio = 1/2 -- Default proportion of screen occupied by master pane
delta = 3/100 -- Percent of screen to increment by when resizing panes
myXmobarPP :: PP
myXmobarPP = def
{ ppSep = magenta ""
, ppTitleSanitize = xmobarStrip
, ppCurrent = wrap " " "" . xmobarBorder "Top" "#8be9fd" 2
, ppHidden = white . wrap " " ""
, ppHiddenNoWindows = lowWhite . wrap " " ""
, ppUrgent = red . wrap (yellow "!") (yellow "!")
, ppOrder = \[ws, l, _, wins] -> [ws, l, wins]
, ppExtras = [logTitles formatFocused formatUnfocused]
}
where
formatFocused = wrap (white "[") (white "]") . magenta . ppWindow
formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . blue . ppWindow
-- | Windows should have *some* title, which should not not exceed a
-- sane length.
ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30
blue, lowWhite, magenta, red, white, yellow :: String -> String
magenta = xmobarColor "#ff79c6" ""
blue = xmobarColor "#bd93f9" ""
white = xmobarColor "#f8f8f2" ""
yellow = xmobarColor "#f1fa8c" ""
red = xmobarColor "#ff5555" ""
lowWhite = xmobarColor "#bbbbbb" ""

View file

@ -0,0 +1,80 @@
import XMonad
import XMonad.Util.Ungrab (unGrab)
import XMonad.Util.EZConfig (additionalKeys, additionalKeysP)
import Control.Monad (when)
import Text.Printf (printf)
import System.Posix.Process (executeFile)
import System.Info (arch,os)
import System.Environment (getArgs)
import System.FilePath ((</>))
compiledConfig = printf "xmonad-%s-%s" arch os
compileRestart resume = do
dirs <- asks directories
whenX (recompile dirs True) $ do
when resume writeStateToFile
catchIO
( do
args <- getArgs
executeFile (cacheDir dirs </> compiledConfig) False args Nothing
)
main :: IO ()
main = getDirectories >>= launch myConfig
myConfig = defaultConfig
{ modMask = mod4Mask -- Use Super instead of Alt
, terminal = "alacritty"
}
`additionalKeys`
[ ( (mod4Mask,xK_r), compileRestart True)
, ( (mod4Mask,xK_q), restart "xmonad" True )
]
`additionalKeysP`
[ ("M-S-z", spawn "xscreensaver-command -lock")
, ("M-C-s", unGrab *> spawn "scrot -s" )
, ("M-f" , spawn "firefox" )
]
-- myManageHook :: ManageHook
-- myManageHook = composeAll
-- [ className =? "Gimp" --> doFloat
-- , isDialog --> doFloat
-- ]
-- main = xmonad
-- . ewmhFullscreen
-- . ewmh
-- . withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey
-- $ myConfig
-- myXmobarPP :: PP
-- myXmobarPP = def
-- { ppSep = magenta " • "
-- , ppTitleSanitize = xmobarStrip
-- , ppCurrent = wrap " " "" . xmobarBorder "Top" "#8be9fd" 2
-- , ppHidden = white . wrap " " ""
-- , ppHiddenNoWindows = lowWhite . wrap " " ""
-- , ppUrgent = red . wrap (yellow "!") (yellow "!")
-- , ppOrder = \[ws, l, _, wins] -> [ws, l, wins]
-- , ppExtras = [logTitles formatFocused formatUnfocused]
-- }
-- where
-- formatFocused = wrap (white "[") (white "]") . magenta . ppWindow
-- formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . blue . ppWindow
-- -- | Windows should have *some* title, which should not not exceed a
-- -- sane length.
-- ppWindow :: String -> String
-- ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30
-- blue, lowWhite, magenta, red, white, yellow :: String -> String
-- magenta = xmobarColor "#ff79c6" ""
-- blue = xmobarColor "#bd93f9" ""
-- white = xmobarColor "#f8f8f2" ""
-- yellow = xmobarColor "#f1fa8c" ""
-- red = xmobarColor "#ff5555" ""
-- lowWhite = xmobarColor "#bbbbbb" ""

View file

@ -8,6 +8,7 @@
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
config = ./config.hs;
};
};
};