xmonad: Setup a basic xmonad config

This commit is contained in:
Alexander Kobjolke 2024-02-15 21:58:26 +01:00
parent 71dbb652b8
commit 3a367e9f4f
4 changed files with 124 additions and 14 deletions

View file

@ -0,0 +1,91 @@
import XMonad
import XMonad.Util.Ungrab (unGrab)
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Magnifier (magnifiercz')
import XMonad.Hooks.EwmhDesktops
import qualified XMonad.Hooks.ManageDocks as Docks
import qualified XMonad.Util.EZConfig as EZ
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
)
myLayout = Docks.avoidStruts (tiled ||| Mirror tiled ||| Full ||| columns)
where
tiled = Tall nmaster delta ratio
columns = magnifiercz' 1.3 $ ThreeColMid nmaster delta ratio
nmaster = 1 -- default number of windows in the master pane
ratio = 1/2 -- default proportion occupied by master pane
delta = 3/100 -- percent of screen to increment when resizing
main :: IO ()
main = getDirectories >>= launch myConfig
myConfig = ewmhFullscreen $ ewmh $ Docks.docks $ def
{ modMask = mod4Mask -- Use Super instead of Alt
, terminal = "alacritty"
, layoutHook = myLayout
}
`EZ.additionalKeysP`
[ ("M-S-z", spawn "xscreensaver-command -lock")
, ("M-S-r", compileRestart True)
, ("M-S-q", restart "xmonad" True)
, ("M-C-s", unGrab *> spawn "scrot -s")
, ("M-b", sendMessage Docks.ToggleStruts)
]
-- 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

@ -1,11 +1,18 @@
{ config, lib, pkgs, ... }:
{
xsession = {
windowManager.command = let
xmonad = pkgs.xmonad-with-packages.override {
packages = self: [ self.xmonad-contrib ];
config.services = {
upower.enable = true;
xserver = {
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
config = ./config.hs;
extraPackages = hp: [ hp.dbus hp.monad-logger hp.xmonad-contrib ];
};
in "${xmonad}/bin/xmonad";
};
};
config.systemd.services.upower.enable = true;
}

View file

@ -1,6 +1,10 @@
import XMonad
import XMonad.Util.Ungrab (unGrab)
import XMonad.Util.EZConfig (additionalKeys, additionalKeysP)
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Magnifier (magnifiercz')
import XMonad.Hooks.EwmhDesktops
import qualified XMonad.Hooks.ManageDocks as Docks
import qualified XMonad.Util.EZConfig as EZ
import Control.Monad (when)
import Text.Printf (printf)
import System.Posix.Process (executeFile)
@ -20,21 +24,28 @@ compileRestart resume = do
executeFile (cacheDir dirs </> compiledConfig) False args Nothing
)
myLayout = Docks.avoidStruts (tiled ||| Mirror tiled ||| Full ||| columns)
where
tiled = Tall nmaster delta ratio
columns = magnifiercz' 1.3 $ ThreeColMid nmaster delta ratio
nmaster = 1 -- default number of windows in the master pane
ratio = 1/2 -- default proportion occupied by master pane
delta = 3/100 -- percent of screen to increment when resizing
main :: IO ()
main = getDirectories >>= launch myConfig
myConfig = defaultConfig
myConfig = ewmhFullscreen $ ewmh $ Docks.docks $ def
{ modMask = mod4Mask -- Use Super instead of Alt
, terminal = "alacritty"
, layoutHook = myLayout
}
`additionalKeys`
[ ( (mod4Mask,xK_r), compileRestart True)
, ( (mod4Mask,xK_q), restart "xmonad" True )
]
`additionalKeysP`
`EZ.additionalKeysP`
[ ("M-S-z", spawn "xscreensaver-command -lock")
, ("M-C-s", unGrab *> spawn "scrot -s" )
, ("M-f" , spawn "firefox" )
, ("M-S-r", compileRestart True)
, ("M-S-q", restart "xmonad" True)
, ("M-C-s", unGrab *> spawn "scrot -s")
, ("M-b", sendMessage Docks.ToggleStruts)
]

View file

@ -9,6 +9,7 @@
enable = true;
enableContribAndExtras = true;
config = ./config.hs;
extraPackages = hp: [ hp.dbus hp.monad-logger hp.xmonad-contrib ];
};
};
};