more xmonad stuff

This commit is contained in:
Bryson Steck 2023-10-23 11:24:12 -06:00
parent 5b41f4664a
commit c1e3c46afd
2 changed files with 114 additions and 51 deletions

View file

@ -1,34 +1,76 @@
import Xmobar import Xmobar
green, red, blue, blue2, purple, yellow, orange, lowWhite, white :: String
green = "#b8bb26"
red = "#fb4934"
blue = "#83a598"
blue2 = "#458588"
purple = "#d3869b"
yellow = "#fabd2f"
orange = "#fe8019"
lowWhite = "#a89984"
white = "#ebdbb2"
config :: Config config :: Config
config = config =
defaultConfig defaultConfig
{ overrideRedirect = False { overrideRedirect = False
, font = "xft:JetBrains Mono NF:style=medium:size=9" , font = "xft:JetBrains Mono NF:style=medium:size=10"
, bgColor = "#3c3836" , bgColor = "#3c3836"
, fgColor = "#ebdbb2" , fgColor = "#ebdbb2"
, position = TopW L 120 , position = Top
, commands = [ Run $ Cpu , commands = [ Run $ Cpu ["--template", "\63521 <total>%"
[ "-L", "30" , "-L", "30"
, "-H", "70" , "-H", "70"
, "--high" , "#fb4934" , "--high", red
, "--normal", "#fabd2f" , "--normal", yellow
] 10 ] 10
, Run $ Alsa "default" "Master" , Run $ Alsa "default" "Master"
[ "--template", "<volumestatus>" [ "--template", "墳 <volume><status>"
, "--suffix" , "True" , "--suffix", "True"
, "--" , "--"
, "--on", "" , "--on", ""
] , "--off", "/mute"
, Run $ Memory ["--template", "Mem: <usedratio>%"] 10 , "-c", red
, Run $ Swap [] 10 ]
, Run $ Date "%a %D <fc=#458588>%I:%M %p</fc>" "date" 10 , Run $ Memory ["--template", "\57958 <usedratio>%"
, "--High", "60"
, "--high", orange
] 10
, Run $ Swap ["--template", concat ["<fc=", lowWhite, ">[<usedratio>%]</fc>"]
, "--High", "0"
, "--high", orange
] 10
, Run $ Date (concat ["\62956 <fc=", purple, ">%a</fc> %D <fc=", blue2, ">%I:%M %p</fc>"]) "date" 10
, Run $ DynNetwork [ "--template", (concat ["\62722 <dev>: <tx>kB<fc=", lowWhite, ">tx</fc> <rx><fc=", white, ">kB</fc><fc=", lowWhite, ">rx</fc>"])
, "--Low", "5000" -- units: B/s
, "--High", "100000" -- units: B/s
, "--low", green
, "--normal", orange
, "--high", red
] 10
, Run $ Battery [ "--template", "\62840 <acstatus>"
, "--Low", "20" -- units: %
, "--High", "80" -- units: %
, "--low", red
, "--normal", green
, "--high", blue
, "--" -- battery specific options
-- discharging status
, "-o", "<left>% (<timeleft>)"
-- AC "on" status
, "-O", "<fc=#dAA520>+<left>%</fc>"
-- charged status
, "-i", "<fc=#006000>Charged</fc>"
] 50
, Run $ Com "brightness" [] "" 10
, Run XMonadLog , Run XMonadLog
] ]
, sepChar = "%" , sepChar = "%"
, alignSep = "}{" , alignSep = "}{"
, template = "%XMonadLog% }{ %alsa:default:Master% | %cpu% | %memory% * %swap% | %date% " , template = " %XMonadLog% }{%alsa:default:Master%|\62941 %brightness%|%battery%|%dynnetwork%|%cpu%|%memory%%swap%|%date% "
} }
main :: IO() main :: IO()
main = xmobar config main = xmobar config

View file

@ -1,21 +1,29 @@
import XMonad import XMonad
import System.Exit (exitSuccess)
import XMonad.Actions.UpdatePointer
import XMonad.Actions.CycleWS
import XMonad.Actions.DwmPromote
import XMonad.Hooks.DynamicLog import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageHelpers import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar import XMonad.Hooks.StatusBar
import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.EwmhDesktops
import XMonad.Util.Cursor import XMonad.Hooks.ManageDocks
import XMonad.Hooks.WindowSwallowing
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Spacing
import XMonad.Layout.NoBorders
import XMonad.Layout.Renamed
import XMonad.Layout.Accordion
import XMonad.Layout.Grid
import XMonad.Util.Cursor
import XMonad.Util.EZConfig import XMonad.Util.EZConfig
import XMonad.Util.Loggers import XMonad.Util.Loggers
import XMonad.Util.Ungrab import XMonad.Util.Ungrab
import XMonad.Layout.ThreeColumns import System.Exit (exitSuccess)
import XMonad.Layout.Spacing
import XMonad.Actions.CycleWS
import XMonad.Layout.Renamed
import XMonad.Layout.Spacing
main :: IO () main :: IO ()
main = xmonad main = xmonad
@ -26,42 +34,56 @@ main = xmonad
myConfig = def myConfig = def
{ modMask = mod4Mask -- Rebind Mod to the Super key { modMask = mod4Mask -- Rebind Mod to the Super key
, layoutHook = myLayout , layoutHook = lessBorders OnlyFloat $ avoidStruts $ myLayout -- layouts
, manageHook = myManageHook , manageHook = myManageHook -- float/swallow rules
, startupHook = setDefaultCursor xC_left_ptr , startupHook = setDefaultCursor xC_left_ptr -- sets the cursor
, workspaces = myWorkspaces , handleEventHook = swallowEventHook (className =? "Alacritty") (return True) -- make alacritty swallowable
, workspaces = myWorkspaces -- workspace names
, logHook = updatePointer (0.5, 0.5) (0, 0) -- warp pointer to center of window on focus
, borderWidth = 2 , borderWidth = 2
, normalBorderColor = "#3c3836" , normalBorderColor = "#3c3836"
, focusedBorderColor = "#928374" , focusedBorderColor = "#928374"
} }
`additionalKeysP` `additionalKeysP`
[ ("M-S-<Escape>", spawn "slock") [ -- executables
, ("M-<PrintScreen>", unGrab *> spawn "screenshot" ) ("M-S-<Escape>", spawn "slock")
, ("M-S-f", spawn "librewolf-bin" ) , ("M-S-f", spawn "librewolf-bin")
, ("M-S-k", spawn "keepassxc" ) , ("M-S-k", spawn "keepassxc")
, ("M-S-<Return>", spawn "spawn-alacritty")
, ("M-p", spawn "dmenu_run_history" )
, ("M-<F1>", spawn "volmute") , ("M-<F1>", spawn "volmute")
, ("M-<F2>", spawn "voldown") , ("M-<F2>", spawn "voldown")
, ("M-<F3>", spawn "volup") , ("M-<F3>", spawn "volup")
, ("M-<F7>", spawn "brightness-down") , ("M-<F7>", spawn "brightness-down")
, ("M-<F8>", spawn "brightness-up") , ("M-<F8>", spawn "brightness-up")
, ("M-<F11>", spawn "screenshot") , ("M-<F11>", spawn "screenshot")
, ("M-p", spawn "dmenu_run_history -fn 'JetBrains Mono NF:style=medium:size=11' -nb '#3c3836' -nf '#ebdbb2' -sb '#504945' -sf '#ebdbb2'")
, ("M-S-<Return>", spawn "spawn-alacritty")
-- XMonad calls
, ("M-<Tab>", toggleWS) , ("M-<Tab>", toggleWS)
, ("M-<Return>", dwmpromote)
-- layout jumps
, ("M-t", sendMessage $ JumpToLayout "Normal")
-- rebound quit call
, ("M-S-<Backspace>", io exitSuccess) , ("M-S-<Backspace>", io exitSuccess)
, ("M-S-q", spawn "true") ]
`removeKeysP`
[ -- default quit keybind, as moved to M-S-<Backspace>
("M-S-q")
] ]
myWorkspaces :: [String]
myWorkspaces = [ "!", "@", "#", "$", "%", "^", "&", "*", "(" ] myWorkspaces = [ "!", "@", "#", "$", "%", "^", "&", "*", "(" ]
myLayout = tiled ||| full ||| threeCol myLayout = tiled ||| full ||| threeCol ||| accordion ||| grid
where where
threeCol = renamed [Replace "ThreeCol"] $ spacing 2 $ ThreeColMid nmaster delta ratio tiled = renamed [Replace "Normal"] $ spaced $ Tall nmaster delta ratio
tiled = renamed [Replace "Tall"] $ spacing 2 $ Tall nmaster delta ratio full = renamed [Replace "Full"] $ spaced $ Full
full = renamed [Replace "Full"] $ spacing 2 $ Full threeCol = renamed [Replace "ThreeCol"] $ spaced $ ThreeColMid nmaster delta ratio
nmaster = 1 -- Default number of windows in the master pane accordion = renamed [Replace "Accrdin"] $ spaced $ Accordion
ratio = 6/10 -- Default proportion of screen occupied by master pane grid = renamed [Replace "Grid"] $ spaced $ Grid
delta = 2/100 -- Percent of screen to increment by when resizing panes nmaster = 1 -- Default number of windows in the master pane
ratio = 6/10 -- Default proportion of screen occupied by master pane
delta = 2/100 -- Percent of screen to increment by when resizing panes
spaced = spacing 2
myManageHook :: ManageHook myManageHook :: ManageHook
myManageHook = composeAll myManageHook = composeAll
@ -73,21 +95,19 @@ myXmobarPP :: PP
myXmobarPP = def myXmobarPP = def
{ ppSep = magenta "" { ppSep = magenta ""
, ppTitleSanitize = xmobarStrip , ppTitleSanitize = xmobarStrip
, ppCurrent = wrap " " "" . xmobarBorder "Top" "#8be9fd" 2 , ppCurrent = wrap "" "" . xmobarBorder "Top" "#8be9fd" 2
, ppHidden = white . wrap " " ""
, ppHiddenNoWindows = lowWhite . wrap " " ""
, ppUrgent = red . wrap (yellow "!") (yellow "!") , ppUrgent = red . wrap (yellow "!") (yellow "!")
, ppOrder = \[ws, l, _, wins] -> [ws, l, wins] , ppOrder = \[ws, l, _, wins] -> [ws, l, wins]
, ppExtras = [logTitles formatFocused formatUnfocused] , ppExtras = [logTitles formatFocused formatUnfocused]
} }
where where
formatFocused = wrap (white "[") (white "]") . green . ppWindow formatFocused = wrap (white "{") (white "}") . aqua . ppWindow . shorten 80
formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . lowWhite . ppWindow formatUnfocused = wrap (lowWhite "<") (lowWhite ">") . lowWhite . ppWindow . shorten 40
-- | Windows should have *some* title, which should not not exceed a -- | Windows should have *some* title, which should not not exceed a
-- sane length. -- sane length.
ppWindow :: String -> String ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 80 ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w)
blue, lowWhite, magenta, red, white, yellow :: String -> String blue, lowWhite, magenta, red, white, yellow :: String -> String
magenta = xmobarColor "#d3869b" "" magenta = xmobarColor "#d3869b" ""
@ -97,3 +117,4 @@ myXmobarPP = def
red = xmobarColor "#fb4934" "" red = xmobarColor "#fb4934" ""
green = xmobarColor "#b8bb26" "" green = xmobarColor "#b8bb26" ""
lowWhite = xmobarColor "#a89984" "" lowWhite = xmobarColor "#a89984" ""
aqua = xmobarColor "#8ec07c" ""