REF add documentation and refactor xmobar binary

This commit is contained in:
Nathan Dwarshuis 2020-04-01 22:35:53 -04:00
parent d09ba6d9ec
commit 7d4558bc02
1 changed files with 35 additions and 25 deletions

View File

@ -1,5 +1,16 @@
module Main (main) where module Main (main) where
--------------------------------------------------------------------------------
-- | Xmobar binary
--
-- Features:
-- * Uses the 'UnsafeStdinReader' to receive the current workspace/layout config
-- from xmonad
-- * FontAwesome and Symbol fonts for icons
-- * Some custom plugins (imported below)
-- * Theme integration with xmonad (shared module imported below)
-- * A custom Locks plugin from my own forked repo
import Data.List import Data.List
import Xmobar.Plugins.Bluetooth import Xmobar.Plugins.Bluetooth
@ -9,30 +20,34 @@ import Xmobar.Plugins.VPN
import Xmobar import Xmobar
import XMonad (getXMonadDir) import XMonad (getXMonadDir)
import XMonad.Hooks.DynamicLog (xmobarColor) import XMonad.Hooks.DynamicLog (wrap, xmobarColor)
import qualified XMonad.Internal.Theme as T import qualified XMonad.Internal.Theme as T
sep :: String sep :: String
sep = xmobarColor T.backdropFgColor "" " : " sep = xmobarColor T.backdropFgColor "" " : "
aSep :: String
aSep = "}{"
pSep :: String
pSep = "%"
myTemplate :: String myTemplate :: String
myTemplate = formatTemplate left right myTemplate = formatTemplate left right
where where
formatTemplate l r = intercalate sep l formatTemplate l r = fmtAliases l ++ aSep ++ fmtAliases r ++ " "
++ " }{ " left = [ "UnsafeStdinReader" ]
++ intercalate sep r right = [ "wlp0s20f3wi"
++ " " , "vpn"
left = [ "%UnsafeStdinReader%" ] , "bluetooth"
right = [ "%wlp0s20f3wi%" , "alsa:default:Master"
, "%vpn%" , "battery"
, "%bluetooth%" , "intelbacklight"
, "%alsa:default:Master%" , "screensaver"
, "%battery%" , "locks"
, "%intelbacklight%" , "date"
, "%screensaver%"
, "%locks%"
, "%date%"
] ]
fmtAliases = intercalate sep . map (wrap pSep pSep)
barFont :: String barFont :: String
barFont = T.fmtFontXFT T.font barFont = T.fmtFontXFT T.font
@ -65,11 +80,7 @@ blockFont = T.fmtFontXFT T.font
config :: String -> Config config :: String -> Config
config confDir = defaultConfig config confDir = defaultConfig
{ font = barFont { font = barFont
, additionalFonts = , additionalFonts = [ iconFont, iconFontLarge, blockFont ]
[ iconFont
, iconFontLarge
, blockFont
]
, textOffset = 16 , textOffset = 16
, textOffsets = [ 16, 17, 17 ] , textOffsets = [ 16, 17, 17 ]
, bgColor = T.bgColor , bgColor = T.bgColor
@ -78,8 +89,8 @@ config confDir = defaultConfig
, border = NoBorder , border = NoBorder
, borderColor = T.bordersColor , borderColor = T.bordersColor
, sepChar = "%" , sepChar = pSep
, alignSep = "}{" , alignSep = aSep
, template = myTemplate , template = myTemplate
, lowerOnStart = False , lowerOnStart = False
@ -88,6 +99,7 @@ config confDir = defaultConfig
, overrideRedirect = True , overrideRedirect = True
, pickBroadest = False , pickBroadest = False
, persistent = True , persistent = True
-- store the icons with the xmonad/xmobar stack project
, iconRoot = confDir ++ "/icons" , iconRoot = confDir ++ "/icons"
, commands = , commands =
@ -144,6 +156,4 @@ config confDir = defaultConfig
} }
main :: IO () main :: IO ()
main = do main = xmobar =<< config <$> getXMonadDir
confDir <- getXMonadDir
xmobar $ config confDir