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
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 =
defaultConfig
{ overrideRedirect = False
, font = "xft:JetBrains Mono NF:style=medium:size=9"
, font = "xft:JetBrains Mono NF:style=medium:size=10"
, bgColor = "#3c3836"
, fgColor = "#ebdbb2"
, position = TopW L 120
, commands = [ Run $ Cpu
[ "-L", "30"
, "-H", "70"
, "--high" , "#fb4934"
, "--normal", "#fabd2f"
] 10
, position = Top
, commands = [ Run $ Cpu ["--template", "\63521 <total>%"
, "-L", "30"
, "-H", "70"
, "--high", red
, "--normal", yellow
] 10
, Run $ Alsa "default" "Master"
[ "--template", "<volumestatus>"
, "--suffix" , "True"
, "--"
, "--on", ""
]
, Run $ Memory ["--template", "Mem: <usedratio>%"] 10
, Run $ Swap [] 10
, Run $ Date "%a %D <fc=#458588>%I:%M %p</fc>" "date" 10
[ "--template", "墳 <volume><status>"
, "--suffix", "True"
, "--"
, "--on", ""
, "--off", "/mute"
, "-c", red
]
, 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
]
, sepChar = "%"
, 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 = xmobar config

View file

@ -1,21 +1,29 @@
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.ManageHelpers
import XMonad.Hooks.StatusBar
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.Loggers
import XMonad.Util.Ungrab
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Spacing
import XMonad.Actions.CycleWS
import XMonad.Layout.Renamed
import XMonad.Layout.Spacing
import System.Exit (exitSuccess)
main :: IO ()
main = xmonad
@ -26,68 +34,80 @@ main = xmonad
myConfig = def
{ modMask = mod4Mask -- Rebind Mod to the Super key
, layoutHook = myLayout
, manageHook = myManageHook
, startupHook = setDefaultCursor xC_left_ptr
, workspaces = myWorkspaces
, layoutHook = lessBorders OnlyFloat $ avoidStruts $ myLayout -- layouts
, manageHook = myManageHook -- float/swallow rules
, startupHook = setDefaultCursor xC_left_ptr -- sets the cursor
, 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
, normalBorderColor = "#3c3836"
, focusedBorderColor = "#928374"
}
`additionalKeysP`
[ ("M-S-<Escape>", spawn "slock")
, ("M-<PrintScreen>", unGrab *> spawn "screenshot" )
, ("M-S-f", spawn "librewolf-bin" )
, ("M-S-k", spawn "keepassxc" )
, ("M-S-<Return>", spawn "spawn-alacritty")
, ("M-p", spawn "dmenu_run_history" )
[ -- executables
("M-S-<Escape>", spawn "slock")
, ("M-S-f", spawn "librewolf-bin")
, ("M-S-k", spawn "keepassxc")
, ("M-<F1>", spawn "volmute")
, ("M-<F2>", spawn "voldown")
, ("M-<F3>", spawn "volup")
, ("M-<F7>", spawn "brightness-down")
, ("M-<F8>", spawn "brightness-up")
, ("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-<Return>", dwmpromote)
-- layout jumps
, ("M-t", sendMessage $ JumpToLayout "Normal")
-- rebound quit call
, ("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 = [ "!", "@", "#", "$", "%", "^", "&", "*", "(" ]
myLayout = tiled ||| full ||| threeCol
myLayout = tiled ||| full ||| threeCol ||| accordion ||| grid
where
threeCol = renamed [Replace "ThreeCol"] $ spacing 2 $ ThreeColMid nmaster delta ratio
tiled = renamed [Replace "Tall"] $ spacing 2 $ Tall nmaster delta ratio
full = renamed [Replace "Full"] $ spacing 2 $ Full
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
tiled = renamed [Replace "Normal"] $ spaced $ Tall nmaster delta ratio
full = renamed [Replace "Full"] $ spaced $ Full
threeCol = renamed [Replace "ThreeCol"] $ spaced $ ThreeColMid nmaster delta ratio
accordion = renamed [Replace "Accrdin"] $ spaced $ Accordion
grid = renamed [Replace "Grid"] $ spaced $ Grid
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 = composeAll
[ className =? "Gimp" --> doFloat
, isDialog --> doFloat
]
]
myXmobarPP :: PP
myXmobarPP = def
{ ppSep = magenta ""
, ppTitleSanitize = xmobarStrip
, ppCurrent = wrap " " "" . xmobarBorder "Top" "#8be9fd" 2
, ppHidden = white . wrap " " ""
, ppHiddenNoWindows = lowWhite . wrap " " ""
, ppCurrent = wrap "" "" . xmobarBorder "Top" "#8be9fd" 2
, ppUrgent = red . wrap (yellow "!") (yellow "!")
, ppOrder = \[ws, l, _, wins] -> [ws, l, wins]
, ppExtras = [logTitles formatFocused formatUnfocused]
}
where
formatFocused = wrap (white "[") (white "]") . green . ppWindow
formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . lowWhite . ppWindow
formatFocused = wrap (white "{") (white "}") . aqua . ppWindow . shorten 80
formatUnfocused = wrap (lowWhite "<") (lowWhite ">") . lowWhite . ppWindow . shorten 40
-- | 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 80
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w)
blue, lowWhite, magenta, red, white, yellow :: String -> String
magenta = xmobarColor "#d3869b" ""
@ -96,4 +116,5 @@ myXmobarPP = def
yellow = xmobarColor "#fabd2f" ""
red = xmobarColor "#fb4934" ""
green = xmobarColor "#b8bb26" ""
lowWhite = xmobarColor "#a89984" ""
lowWhite = xmobarColor "#a89984" ""
aqua = xmobarColor "#8ec07c" ""