diff --git a/home/alex/programs/xmonad/config.hs b/home/alex/programs/xmonad/config.hs new file mode 100644 index 0000000..486ac96 --- /dev/null +++ b/home/alex/programs/xmonad/config.hs @@ -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" "" diff --git a/home/alex/programs/xmonad/default.nix b/home/alex/programs/xmonad/default.nix index 49af6ae..988cd29 100644 --- a/home/alex/programs/xmonad/default.nix +++ b/home/alex/programs/xmonad/default.nix @@ -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; } diff --git a/modules/wm/xmonad/config.hs b/modules/wm/xmonad/config.hs index a946326..486ac96 100644 --- a/modules/wm/xmonad/config.hs +++ b/modules/wm/xmonad/config.hs @@ -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) ] diff --git a/modules/wm/xmonad/default.nix b/modules/wm/xmonad/default.nix index 9473dae..c59ec4e 100644 --- a/modules/wm/xmonad/default.nix +++ b/modules/wm/xmonad/default.nix @@ -9,6 +9,7 @@ enable = true; enableContribAndExtras = true; config = ./config.hs; + extraPackages = hp: [ hp.dbus hp.monad-logger hp.xmonad-contrib ]; }; }; };