Enlarge xmobar font to 10 and fit the bar's contents to its width

Workspaces show only their icon, layouts show an icon instead of their name, and window titles share a 60-character budget (8–30 each), so more windows get shorter titles instead of overflowing the bar.
This commit is contained in:
Daniele Fucini
2026-10-28 19:50:11 +01:00
parent 4e431d6710
commit a41afe4983
3 changed files with 31 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Config { overrideRedirect = True
, lowerOnStart = True
, font = "Jetbrains Mono Nerd Font Bold 9"
, font = "Jetbrains Mono Nerd Font Bold 10"
, bgColor = "#24283b"
, fgColor = "#737aa2"
, position = TopH 24
+1 -1
View File
@@ -1,6 +1,6 @@
Config { overrideRedirect = True
, lowerOnStart = True
, font = "Jetbrains Mono Nerd Font Bold 9"
, font = "Jetbrains Mono Nerd Font Bold 10"
, bgColor = "#24283b"
, fgColor = "#737aa2"
, position = TopH 24
+29 -5
View File
@@ -299,17 +299,41 @@ myXmobarPP =
ppHidden = cultured . wrap " " "",
ppHiddenNoWindows = outerspace . wrap " " "",
ppUrgent = sunsetorange . wrap (keylime "!") (keylime "!"),
-- Show "1:<icon>" as just the icon; tags stay as they are (clickablePP uses the index)
ppRename = \tag _ -> case break (== ':') tag of
(_, ':' : icon) -> icon
_ -> tag,
-- NamedScratchpad never removes NSP once created; hide it while it's empty
ppSort = (. filter (\w -> W.tag w /= scratchpadWorkspaceTag || isJust (W.stack w))) <$> ppSort def,
ppOrder = \[ws, l, _, wins] -> [ws, l, wins],
ppExtras = [logTitles formatFocused formatUnfocused]
ppLayout = layoutIcon,
ppExtras = [budgetTitles]
}
where
formatFocused = wrap (cultured "[") (cultured "]") . pink . ppWindow
formatUnfocused = wrap (outerspace "[") (outerspace "]") . cultured . ppWindow
layoutIcon :: String -> String
layoutIcon l = case l of
"Tall" -> "\xf0bcc"
"Mirror Tall" -> "\xf0bcb"
"Tabbed" -> "\xf04e9"
"ThreeCol" -> "\xf056d"
"Grid" -> "\xf0570"
"Spiral" -> "\xf056e"
"Full" -> "\xf0293"
_ -> l
ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 20
-- Titles share one width budget, so more windows get shorter titles instead of overflowing the bar
budgetTitles :: Logger
budgetTitles = do
n <- gets $ length . W.integrate' . W.stack . W.workspace . W.current . windowset
let width = max 8 . min 30 $ 60 `div` max 1 n
logTitles (formatFocused width) (formatUnfocused width)
formatFocused, formatUnfocused :: Int -> String -> String
formatFocused w = wrap (cultured "[") (cultured "]") . pink . ppWindow w
formatUnfocused w = wrap (outerspace "[") (outerspace "]") . cultured . ppWindow w
ppWindow :: Int -> String -> String
ppWindow w = xmobarRaw . (\t -> if null t then "untitled" else t) . shorten' "…" w
outerspace, pink, sunsetorange, cultured, keylime :: String -> String
pink = xmobarColor "#ff79c6" ""