From 1cc4f0c1924e20fad7018307c549cee445afbaf7 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 1 Dec 2018 19:13:08 +0000 Subject: Directory layout directly usable by xmobar executable --- src/lib/Config.hs | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/lib/Config.hs (limited to 'src/lib/Config.hs') diff --git a/src/lib/Config.hs b/src/lib/Config.hs new file mode 100644 index 0000000..94b9211 --- /dev/null +++ b/src/lib/Config.hs @@ -0,0 +1,71 @@ +module Config (Palette, baseConfig, palette, (<~>)) where + +import System.Environment (lookupEnv) + +import Xmobar + +data Palette = Palette { pNormal :: String + , pLow :: String + , pHigh :: String + , pFont :: String + , pBorder :: String + , pForeground :: String + , pBackground :: String + , pAlpha :: Int + } + +lightTheme :: IO Bool +lightTheme = fmap (== (Just "light")) (lookupEnv "JAO_COLOR_SCHEME") + +lightPalette :: Palette +lightPalette = Palette { pNormal = "black" + , pLow = "#4d4d4d" + , pHigh = "#a0522d" + , pFont = "xft:Source Code Pro Medium-9" + , pBorder = "grey70" + , pForeground = "#000000" + , pBackground = "white" + , pAlpha = 0 + } + +darkPalette :: Palette +darkPalette = Palette { pNormal = "black" + , pLow = "#4d4d4d" + , pHigh = "#a0522d" + , pFont = "xft:NotoMono-9,xft:Inconsolata-11" + , pBorder = "black" + , pForeground = "grey50" + , pBackground = "black" + , pAlpha = 102 + } + +palette :: IO Palette +palette = do + light <- lightTheme + if light then return lightPalette else return darkPalette + +baseConfig :: Palette -> Config +baseConfig p = defaultConfig { + font = pFont p + , borderColor = pBorder p + , fgColor = (pForeground p) + , bgColor = (pBackground p) + , border = FullBM 1 + , alpha = (pAlpha p) + , additionalFonts = [] + , overrideRedirect = True + , lowerOnStart = True + , allDesktops = True + , hideOnStart = False + , persistent = True + , sepChar = "|" + , alignSep = "{}" + } + +(<~>) :: Palette -> [String] -> [String] +(<~>) p args = concat [ args + , [ "--low", (pLow p) + , "--normal", (pNormal p) + , "--high", (pHigh p) + ] + ] -- cgit v1.2.3