From 836bcb7286275969ce4b22ad130384652c5821e8 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 1 Dec 2018 13:00:04 +0000 Subject: Working xmobar top/bottom configurations --- src/Bottom.hs | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Config.hs | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 src/Bottom.hs create mode 100644 src/Config.hs (limited to 'src') diff --git a/src/Bottom.hs b/src/Bottom.hs new file mode 100644 index 0000000..1c70548 --- /dev/null +++ b/src/Bottom.hs @@ -0,0 +1,83 @@ +module Bottom (config) where + +import Xmobar +import Config + +uptime p = Uptime (p <~> [ "-t" , " ", "-m", "3", "-c", "0", "-S" + , "On" , "-L", "10", "-H", "100"]) 600 + +weather st = + Weather st ["-t", "° % ()" + , "-L","10", "-H", "25", "--normal", "black", + "--high", "lightgoldenrod4", "--low", "darkseagreen4"] 18000 + +batt p = + BatteryN ["BAT0"] + ((p <~> ["-t", "%" + , "-S", "Off", "-d", "0", "-m", "3" + , "-L", "10", "-H", "80", "-p", "3"]) + ++ [ "--" + , "-i", "", "-O", " " + , "-o", " " + , "-H", "16", "-L", "10" + , "-h", "sienna4", "-l", "gray20"]) 50 "b0" + +coreTemp p = + CoreTemp (p <~> ["-t", "° °" + , "-L", "50", "-H", "75", "-d", "0"]) 50 + +diskU p = + DiskU [("dm-1", "") , ("/media/sdb", " s ")] + (p <~> ["-L", "20", "-H", "70", "-m", "1", "-p", "3"]) + 20 + +diskIO p = + DiskIO [("dm-1", "↑ ")] + (p <~> ["-L", "20", "-H", "5000", "-m", "5", "-p", "3"]) 10 + +mbox = MBox [ ("I", "inbox", "darkseagreen4") + , ("B", "bigml.spool", "sienna4") + , ("S", "bigsup.spool", "sienna4") + , ("b", "bugml.spool", "sienna4") + , ("G", "geiser.spool", "darkseagreen4") + , ("X", "xmobar.spool", "darkseagreen4") + , ("g", "gnu.spool", "") + , ("k", "books.spool", "") + , ("h", "hacking.spool", "") + , ("c", "computers.spool", "") + , ("w", "words.spool", "") + , ("t", "think.spool", "") + ] ["-d", "/home/jao/var/mail", "-p", " ", "-s", ""] "mbox" + + +masterVol = + Volume "default" "Master" + ["-t", " " + , "--", "-C", "black", "-c", "sienna4", "-O", "" + , "-o", "×"] 10 + +captureVol = Volume "default" "Capture" ["-t", ""] 10 + +kbd = Kbd [("us", ""), ("us(intl)", "*")] + +brightness = Brightness ["--", "-D", "intel_backlight"] 10 + +memory = Memory ["-t"," M", "-p", "2"] 20 + +config cs p = (baseConfig p) { + position = BottomSize C 100 24 + , textOffset = 17 + , commands = [ Run (uptime p) + , Run brightness + , Run (weather "EGPH") -- LEGE, LEBL, KCV0 + , Run memory + , Run (batt p) + , Run (coreTemp p) + , Run (diskU p) + , Run (diskIO p) + , Run mbox + , Run masterVol + , Run captureVol + , Run kbd + ] ++ cs +} diff --git a/src/Config.hs b/src/Config.hs new file mode 100644 index 0000000..94b9211 --- /dev/null +++ b/src/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