xmonad-config/bin/xmobar.hs

165 lines
4.3 KiB
Haskell
Raw Normal View History

2020-04-01 20:17:47 -04:00
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
2020-04-01 20:17:47 -04:00
import Data.List
2020-03-25 18:55:52 -04:00
import Xmobar.Plugins.Bluetooth
2020-05-28 23:17:17 -04:00
import Xmobar.Plugins.Device
2020-03-25 18:55:52 -04:00
import Xmobar.Plugins.IntelBacklight
import Xmobar.Plugins.Screensaver
import Xmobar.Plugins.VPN
2020-03-15 15:10:25 -04:00
2020-03-25 18:55:52 -04:00
import XMonad (getXMonadDir)
import XMonad.Hooks.DynamicLog (wrap, xmobarColor)
2020-04-01 20:17:47 -04:00
import qualified XMonad.Internal.Theme as T
2021-06-19 00:54:01 -04:00
import Xmobar
2020-03-15 13:12:01 -04:00
2020-03-15 13:45:53 -04:00
sep :: String
2020-04-01 20:17:47 -04:00
sep = xmobarColor T.backdropFgColor "" " : "
2020-03-15 13:12:01 -04:00
aSep :: String
aSep = "}{"
pSep :: String
pSep = "%"
2020-03-15 13:45:53 -04:00
myTemplate :: String
2020-03-15 15:28:48 -04:00
myTemplate = formatTemplate left right
where
formatTemplate l r = fmtAliases l ++ aSep ++ fmtAliases r ++ " "
left = [ "UnsafeStdinReader" ]
right = [ "wlp0s20f3wi"
2020-05-28 23:17:17 -04:00
, "enp7s0f1"
, "vpn"
, "bluetooth"
, "alsa:default:Master"
, "battery"
, "intelbacklight"
, "screensaver"
, "locks"
, "date"
2020-03-15 15:28:48 -04:00
]
fmtAliases = intercalate sep . map (wrap pSep pSep)
2020-03-15 13:12:01 -04:00
2020-03-16 13:50:08 -04:00
barFont :: String
barFont = T.fmtFontXFT T.font
{ T.family = "DejaVu Sans Mono"
, T.size = Just 11
, T.weight = Just T.Bold
}
iconFont :: String
iconFont = T.fmtFontXFT T.font
{ T.family = "FontAwesome"
, T.size = Nothing
, T.pixelsize = Just 13
}
2020-03-22 17:17:57 -04:00
iconFontLarge :: String
iconFontLarge = T.fmtFontXFT T.font
{ T.family = "FontAwesome"
, T.size = Nothing
, T.pixelsize = Just 15
}
2020-03-16 13:50:08 -04:00
blockFont :: String
blockFont = T.fmtFontXFT T.font
{ T.family = "Symbola"
, T.size = Just 13
, T.weight = Just T.Bold
}
2020-03-15 13:45:53 -04:00
config :: String -> Config
2020-03-20 00:51:36 -04:00
config confDir = defaultConfig
{ font = barFont
, additionalFonts = [ iconFont, iconFontLarge, blockFont ]
2020-03-15 13:12:01 -04:00
, textOffset = 16
2020-03-22 17:17:57 -04:00
, textOffsets = [ 16, 17, 17 ]
2020-03-16 13:50:08 -04:00
, bgColor = T.bgColor
, fgColor = T.fgColor
2020-03-15 13:12:01 -04:00
, position = BottomSize C 100 24
, border = NoBorder
2020-03-16 13:50:08 -04:00
, borderColor = T.bordersColor
2020-03-15 13:12:01 -04:00
, sepChar = pSep
, alignSep = aSep
2020-03-15 13:12:01 -04:00
, template = myTemplate
, lowerOnStart = False
, hideOnStart = False
, allDesktops = True
, overrideRedirect = True
, pickBroadest = False
, persistent = True
-- store the icons with the xmonad/xmobar stack project
2020-03-15 13:45:53 -04:00
, iconRoot = confDir ++ "/icons"
2020-03-15 13:12:01 -04:00
2020-03-20 01:12:20 -04:00
, commands =
2020-03-15 13:12:01 -04:00
[ Run $ Alsa "default" "Master"
[ "-t", "<status><volume>%"
, "--"
, "-O", "<fn=1>\xf028</fn>"
, "-o", "<fn=1>\xf026 </fn>"
2020-03-16 13:50:08 -04:00
, "-c", T.fgColor
, "-C", T.fgColor
2020-03-15 13:12:01 -04:00
]
, Run $ Battery [ "--template", "<acstatus><left>"
, "--Low", "10"
, "--High", "80"
, "--low", "red"
2020-03-16 13:50:08 -04:00
, "--normal", T.fgColor
, "--high", T.fgColor
2020-03-15 13:12:01 -04:00
, "--"
, "-P"
, "-o" , "<fn=1>\xf0e7</fn>"
, "-O" , "<fn=1>\xf1e6</fn>"
, "-i" , "<fn=1>\xf1e6</fn>"
] 50
, Run $ IntelBacklight "<fn=1>\xf185</fn>"
2020-03-20 00:51:36 -04:00
2020-03-15 13:12:01 -04:00
, Run $ Wireless "wlp0s20f3"
[ "-t", "<qualityipat><essid>"
, "--"
, "--quality-icon-pattern", "<icon=wifi_%%.xpm/>"
] 5
2020-05-28 23:17:17 -04:00
, Run $ Device
("enp7s0f1", "<fn=2>\xf0e8</fn>", T.fgColor, T.backdropFgColor) 5
2020-03-15 13:12:01 -04:00
, Run $ Locks
2020-03-22 17:17:57 -04:00
[ "-N", "<fn=3>\x1f13d</fn>"
2020-04-01 20:17:47 -04:00
, "-n", xmobarColor T.backdropFgColor "" "<fn=3>\x1f13d</fn>"
2020-03-22 17:17:57 -04:00
, "-C", "<fn=3>\x1f132</fn>"
2020-04-01 20:17:47 -04:00
, "-c", xmobarColor T.backdropFgColor "" "<fn=3>\x1f132</fn>"
2020-03-15 13:12:01 -04:00
, "-s", ""
, "-S", ""
2020-03-22 17:17:57 -04:00
, "-d", "<fn=3> </fn>"
2020-03-15 13:12:01 -04:00
]
2021-04-27 19:44:54 -04:00
, Run $ Date "%Y-%m-%d %H:%M:%S" "date" 10
2020-03-15 13:12:01 -04:00
, Run $ Screensaver ("<fn=1>\xf254</fn>", T.fgColor, T.backdropFgColor)
2020-03-15 15:10:25 -04:00
2020-03-22 17:17:57 -04:00
, Run $ Bluetooth ("<fn=2>\xf293</fn>", T.fgColor, T.backdropFgColor) 5
2020-03-21 01:18:38 -04:00
2020-03-15 13:12:01 -04:00
, Run UnsafeStdinReader
2020-03-21 18:37:26 -04:00
2020-03-22 17:17:57 -04:00
, Run $ VPN ("<fn=2>\xf023</fn>", T.fgColor, T.backdropFgColor) 5
2020-03-15 13:12:01 -04:00
]
}
main :: IO ()
main = xmobar =<< config <$> getXMonadDir