summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/Configuration.hs158
-rw-r--r--src/app/Main.hs260
-rw-r--r--src/lib/Xmobar.hs (renamed from src/Xmobar.hs)0
-rw-r--r--src/lib/Xmobar/Actions.hs (renamed from src/Xmobar/Actions.hs)0
-rw-r--r--src/lib/Xmobar/Bitmap.hs (renamed from src/Xmobar/Bitmap.hs)0
-rw-r--r--src/lib/Xmobar/ColorCache.hs (renamed from src/Xmobar/ColorCache.hs)0
-rw-r--r--src/lib/Xmobar/Commands.hs (renamed from src/Xmobar/Commands.hs)0
-rw-r--r--src/lib/Xmobar/Config.hs (renamed from src/Xmobar/Config.hs)0
-rw-r--r--src/lib/Xmobar/Environment.hs (renamed from src/Xmobar/Environment.hs)0
-rw-r--r--src/lib/Xmobar/IPC/DBus.hs (renamed from src/Xmobar/IPC/DBus.hs)0
-rw-r--r--src/lib/Xmobar/Localize.hsc (renamed from src/Xmobar/Localize.hsc)0
-rw-r--r--src/lib/Xmobar/MinXft.hsc (renamed from src/Xmobar/MinXft.hsc)0
-rw-r--r--src/lib/Xmobar/Parsers.hs (renamed from src/Xmobar/Parsers.hs)0
-rw-r--r--src/lib/Xmobar/Plugins.hs (renamed from src/Xmobar/Plugins.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/BufferedPipeReader.hs (renamed from src/Xmobar/Plugins/BufferedPipeReader.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/CommandReader.hs (renamed from src/Xmobar/Plugins/CommandReader.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Date.hs (renamed from src/Xmobar/Plugins/Date.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/DateZone.hs (renamed from src/Xmobar/Plugins/DateZone.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/EWMH.hs (renamed from src/Xmobar/Plugins/EWMH.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Kbd.hsc (renamed from src/Xmobar/Plugins/Kbd.hsc)0
-rw-r--r--src/lib/Xmobar/Plugins/Locks.hs (renamed from src/Xmobar/Plugins/Locks.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/MBox.hs (renamed from src/Xmobar/Plugins/MBox.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Mail.hs (renamed from src/Xmobar/Plugins/Mail.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/MarqueePipeReader.hs (renamed from src/Xmobar/Plugins/MarqueePipeReader.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors.hs (renamed from src/Xmobar/Plugins/Monitors.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Alsa.hs (renamed from src/Xmobar/Plugins/Monitors/Alsa.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Batt.hs (renamed from src/Xmobar/Plugins/Monitors/Batt.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Bright.hs (renamed from src/Xmobar/Plugins/Monitors/Bright.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/CatInt.hs (renamed from src/Xmobar/Plugins/Monitors/CatInt.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Common.hs (renamed from src/Xmobar/Plugins/Monitors/Common.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/CoreCommon.hs (renamed from src/Xmobar/Plugins/Monitors/CoreCommon.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/CoreTemp.hs (renamed from src/Xmobar/Plugins/Monitors/CoreTemp.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Cpu.hs (renamed from src/Xmobar/Plugins/Monitors/Cpu.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/CpuFreq.hs (renamed from src/Xmobar/Plugins/Monitors/CpuFreq.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Disk.hs (renamed from src/Xmobar/Plugins/Monitors/Disk.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/MPD.hs (renamed from src/Xmobar/Plugins/Monitors/MPD.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Mem.hs (renamed from src/Xmobar/Plugins/Monitors/Mem.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Mpris.hs (renamed from src/Xmobar/Plugins/Monitors/Mpris.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/MultiCpu.hs (renamed from src/Xmobar/Plugins/Monitors/MultiCpu.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Net.hs (renamed from src/Xmobar/Plugins/Monitors/Net.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Swap.hs (renamed from src/Xmobar/Plugins/Monitors/Swap.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Thermal.hs (renamed from src/Xmobar/Plugins/Monitors/Thermal.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/ThermalZone.hs (renamed from src/Xmobar/Plugins/Monitors/ThermalZone.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Top.hs (renamed from src/Xmobar/Plugins/Monitors/Top.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/UVMeter.hs (renamed from src/Xmobar/Plugins/Monitors/UVMeter.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Uptime.hs (renamed from src/Xmobar/Plugins/Monitors/Uptime.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Volume.hs (renamed from src/Xmobar/Plugins/Monitors/Volume.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Weather.hs (renamed from src/Xmobar/Plugins/Monitors/Weather.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Wireless.hs (renamed from src/Xmobar/Plugins/Monitors/Wireless.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/PipeReader.hs (renamed from src/Xmobar/Plugins/PipeReader.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/StdinReader.hs (renamed from src/Xmobar/Plugins/StdinReader.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/Utils.hs (renamed from src/Xmobar/Plugins/Utils.hs)0
-rw-r--r--src/lib/Xmobar/Plugins/XMonadLog.hs (renamed from src/Xmobar/Plugins/XMonadLog.hs)0
-rw-r--r--src/lib/Xmobar/Runnable.hs (renamed from src/Xmobar/Runnable.hs)0
-rw-r--r--src/lib/Xmobar/Runnable.hs-boot (renamed from src/Xmobar/Runnable.hs-boot)0
-rw-r--r--src/lib/Xmobar/Signal.hs (renamed from src/Xmobar/Signal.hs)0
-rw-r--r--src/lib/Xmobar/StatFS.hsc (renamed from src/Xmobar/StatFS.hsc)0
-rw-r--r--src/lib/Xmobar/Window.hs (renamed from src/Xmobar/Window.hs)0
-rw-r--r--src/lib/Xmobar/XPMFile.hsc (renamed from src/Xmobar/XPMFile.hsc)0
-rw-r--r--src/lib/Xmobar/XUtil.hsc (renamed from src/Xmobar/XUtil.hsc)0
60 files changed, 418 insertions, 0 deletions
diff --git a/src/app/Configuration.hs b/src/app/Configuration.hs
new file mode 100644
index 0000000..db5c109
--- /dev/null
+++ b/src/app/Configuration.hs
@@ -0,0 +1,158 @@
+{-# LANGUAGE FlexibleContexts #-}
+
+------------------------------------------------------------------------------
+-- |
+-- Module: Configuration
+-- Copyright: (c) 2018 Jose Antonio Ortega Ruiz
+-- License: BSD3-style (see LICENSE)
+--
+-- Maintainer: jao@gnu.org
+-- Stability: unstable
+-- Portability: portable
+-- Created: Wed Nov 21, 2018 23:13
+--
+--
+-- Parsing configuration files
+--
+------------------------------------------------------------------------------
+
+
+module Configuration (parseConfig) where
+
+import Text.ParserCombinators.Parsec
+import Text.ParserCombinators.Parsec.Number (int)
+import Text.ParserCombinators.Parsec.Perm ((<|?>), (<$?>), permute)
+
+import qualified Xmobar.Config as C
+
+stripComments :: String -> String
+stripComments =
+ unlines . map (drop 5 . strip False . (replicate 5 ' '++)) . lines
+ where strip m ('-':'-':xs) = if m then "--" ++ strip m xs else ""
+ strip m ('"':xs) = '"': strip (not m) xs
+ strip m (x:xs) = x : strip m xs
+ strip _ [] = []
+
+-- | Parse the config, logging a list of fields that were missing and replaced
+-- by the default definition.
+parseConfig :: String -> Either ParseError (C.Config,[String])
+parseConfig = runParser parseConf fields "Config" . stripComments
+ where
+ parseConf = do
+ many space
+ sepEndSpc ["Config","{"]
+ x <- perms
+ eof
+ s <- getState
+ return (x,s)
+
+ perms = permute $ C.Config
+ <$?> pFont <|?> pFontList <|?> pWmClass <|?> pWmName
+ <|?> pBgColor <|?> pFgColor
+ <|?> pPosition <|?> pTextOffset <|?> pTextOffsets
+ <|?> pIconOffset <|?> pBorder
+ <|?> pBdColor <|?> pBdWidth <|?> pAlpha <|?> pHideOnStart
+ <|?> pAllDesktops <|?> pOverrideRedirect <|?> pPickBroadest
+ <|?> pLowerOnStart <|?> pPersistent <|?> pIconRoot
+ <|?> pCommands <|?> pSepChar <|?> pAlignSep <|?> pTemplate
+
+
+ fields = [ "font", "additionalFonts","bgColor", "fgColor"
+ , "wmClass", "wmName", "sepChar"
+ , "alignSep" , "border", "borderColor" ,"template"
+ , "position" , "textOffset", "textOffsets", "iconOffset"
+ , "allDesktops", "overrideRedirect", "pickBroadest"
+ , "hideOnStart", "lowerOnStart", "persistent", "iconRoot"
+ , "alpha", "commands"
+ ]
+
+ pFont = strField C.font "font"
+ pFontList = strListField C.additionalFonts "additionalFonts"
+ pWmClass = strField C.wmClass "wmClass"
+ pWmName = strField C.wmName "wmName"
+ pBgColor = strField C.bgColor "bgColor"
+ pFgColor = strField C.fgColor "fgColor"
+ pBdColor = strField C.borderColor "borderColor"
+ pSepChar = strField C.sepChar "sepChar"
+ pAlignSep = strField C.alignSep "alignSep"
+ pTemplate = strField C.template "template"
+
+ pTextOffset = readField C.textOffset "textOffset"
+ pTextOffsets = readIntList C.textOffsets "textOffsets"
+ pIconOffset = readField C.iconOffset "iconOffset"
+ pPosition = readField C.position "position"
+ pHideOnStart = readField C.hideOnStart "hideOnStart"
+ pLowerOnStart = readField C.lowerOnStart "lowerOnStart"
+ pPersistent = readField C.persistent "persistent"
+ pBorder = readField C.border "border"
+ pBdWidth = readField C.borderWidth "borderWidth"
+ pAllDesktops = readField C.allDesktops "allDesktops"
+ pOverrideRedirect = readField C.overrideRedirect "overrideRedirect"
+ pPickBroadest = readField C.pickBroadest "pickBroadest"
+ pIconRoot = readField C.iconRoot "iconRoot"
+ pAlpha = readField C.alpha "alpha"
+
+ pCommands = field C.commands "commands" readCommands
+
+ staticPos = do string "Static"
+ wrapSkip (string "{")
+ p <- many (noneOf "}")
+ wrapSkip (string "}")
+ string ","
+ return ("Static {" ++ p ++ "}")
+ tillFieldEnd = staticPos <|> many (noneOf ",}\n\r")
+
+ commandsEnd = wrapSkip (string "]") >> (string "}" <|> notNextRun)
+ notNextRun = do {string ","
+ ; notFollowedBy $ wrapSkip $ string "Run"
+ ; return ","
+ }
+ readCommands = manyTill anyChar (try commandsEnd) >>=
+ read' commandsErr . flip (++) "]"
+ strField e n = field e n strMulti
+
+ strMulti = scan '"'
+ where
+ scan lead = do
+ spaces
+ char lead
+ s <- manyTill anyChar (rowCont <|> unescQuote)
+ (char '"' >> return s) <|> fmap (s ++) (scan '\\')
+ rowCont = try $ char '\\' >> string "\n"
+ unescQuote = lookAhead (noneOf "\\") >> lookAhead (string "\"")
+
+ strListField e n = field e n strList
+ strList = do
+ spaces
+ char '['
+ list <- sepBy (strMulti >>= \x -> spaces >> return x) (char ',')
+ spaces
+ char ']'
+ return list
+
+ wrapSkip x = many space >> x >>= \r -> many space >> return r
+ sepEndSpc = mapM_ (wrapSkip . try . string)
+ fieldEnd = many $ space <|> oneOf ",}"
+ field e n c = (,) (e C.defaultConfig) $
+ updateState (filter (/= n)) >> sepEndSpc [n,"="] >>
+ wrapSkip c >>= \r -> fieldEnd >> return r
+ readField a n = field a n $ tillFieldEnd >>= read' n
+
+ readIntList d n = field d n intList
+ intList = do
+ spaces
+ char '['
+ list <- sepBy (spaces >> int >>= \x-> spaces >> return x) (char ',')
+ spaces
+ char ']'
+ return list
+
+ read' d s = case reads s of
+ [(x, _)] -> return x
+ _ -> fail $ "error reading the " ++ d ++ " field: " ++ s
+
+commandsErr :: String
+commandsErr = "commands: this usually means that a command could not" ++
+ "\nbe parsed." ++
+ "\nThe error could be located at the begining of the command" ++
+ "\nwhich follows the offending one."
diff --git a/src/app/Main.hs b/src/app/Main.hs
new file mode 100644
index 0000000..c96c47e
--- /dev/null
+++ b/src/app/Main.hs
@@ -0,0 +1,260 @@
+{-# LANGUAGE FlexibleContexts #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module : Xmobar.Main
+-- Copyright : (c) Andrea Rossato
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Jose A. Ortega Ruiz <jao@gnu.org>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- The main module of Xmobar, a text based status bar
+--
+-----------------------------------------------------------------------------
+
+module Main ( -- * Main Stuff
+ -- $main
+ main
+ , readConfig
+ , readDefaultConfig
+ ) where
+
+import Xmobar
+import Xmobar.Parsers
+import Xmobar.Config
+import Xmobar.XUtil
+
+import Data.Foldable (for_)
+import Data.List (intercalate)
+import qualified Data.Map as Map
+
+import Data.Version (showVersion)
+import Graphics.X11.Xlib
+import System.Console.GetOpt
+import System.Directory (getHomeDirectory)
+import System.Exit
+import System.Environment
+import System.FilePath ((</>))
+import System.Posix.Files
+import Control.Concurrent.Async (Async, cancel)
+import Control.Exception (bracket)
+import Control.Monad (unless)
+import Text.Read (readMaybe)
+
+import Xmobar.Signal (setupSignalHandler, withDeferSignals)
+
+import Paths_xmobar (version)
+import Configuration
+
+-- $main
+
+-- | The main entry point
+main :: IO ()
+main = withDeferSignals $ do
+ initThreads
+ d <- openDisplay ""
+ args <- getArgs
+ (o,file) <- getOpts args
+ (c,defaultings) <- case file of
+ [cfgfile] -> readConfig cfgfile
+ _ -> readDefaultConfig
+
+ unless (null defaultings) $ putStrLn $
+ "Fields missing from config defaulted: " ++ intercalate "," defaultings
+
+ conf <- doOpts c o
+ fs <- initFont d (font conf)
+ fl <- mapM (initFont d) (additionalFonts conf)
+ cls <- mapM (parseTemplate conf) (splitTemplate conf)
+ sig <- setupSignalHandler
+ bracket (mapM (mapM $ startCommand sig) cls)
+ cleanupThreads
+ $ \vars -> do
+ (r,w) <- createWin d fs conf
+ let ic = Map.empty
+ to = textOffset conf
+ ts = textOffsets conf ++ replicate (length fl) (-1)
+ startLoop (XConf d r w (fs:fl) (to:ts) ic conf) sig vars
+
+cleanupThreads :: [[([Async ()], a)]] -> IO ()
+cleanupThreads vars =
+ -- putStrLn "In cleanupThreads"
+ for_ (concat vars) $ \(asyncs, _) ->
+ for_ asyncs cancel
+
+-- | Splits the template in its parts
+splitTemplate :: Config -> [String]
+splitTemplate conf =
+ case break (==l) t of
+ (le,_:re) -> case break (==r) re of
+ (ce,_:ri) -> [le, ce, ri]
+ _ -> def
+ _ -> def
+ where [l, r] = alignSep
+ (if length (alignSep conf) == 2 then conf else defaultConfig)
+ t = template conf
+ def = [t, "", ""]
+
+
+-- | Reads the configuration files or quits with an error
+readConfig :: FilePath -> IO (Config,[String])
+readConfig f = do
+ file <- io $ fileExist f
+ s <- io $ if file then readFileSafe f else error $
+ f ++ ": file not found!\n" ++ usage
+ either (\err -> error $ f ++
+ ": configuration file contains errors at:\n" ++ show err)
+ return $ parseConfig s
+
+xdgConfigDir :: IO String
+xdgConfigDir = do env <- getEnvironment
+ case lookup "XDG_CONFIG_HOME" env of
+ Just val -> return val
+ Nothing -> fmap (</> ".config") getHomeDirectory
+
+xmobarConfigDir :: IO FilePath
+xmobarConfigDir = fmap (</> "xmobar") xdgConfigDir
+
+getXdgConfigFile :: IO FilePath
+getXdgConfigFile = fmap (</> "xmobarrc") xmobarConfigDir
+
+-- | Read default configuration file or load the default config
+readDefaultConfig :: IO (Config,[String])
+readDefaultConfig = do
+ xdgConfigFile <- getXdgConfigFile
+ xdgConfigFileExists <- io $ fileExist xdgConfigFile
+ home <- io $ getEnv "HOME"
+ let defaultConfigFile = home ++ "/.xmobarrc"
+ defaultConfigFileExists <- io $ fileExist defaultConfigFile
+ if xdgConfigFileExists
+ then readConfig xdgConfigFile
+ else if defaultConfigFileExists
+ then readConfig defaultConfigFile
+ else return (defaultConfig,[])
+
+data Opts = Help
+ | Version
+ | Font String
+ | BgColor String
+ | FgColor String
+ | Alpha String
+ | T
+ | B
+ | D
+ | AlignSep String
+ | Commands String
+ | AddCommand String
+ | SepChar String
+ | Template String
+ | OnScr String
+ | IconRoot String
+ | Position String
+ | WmClass String
+ | WmName String
+ deriving Show
+
+options :: [OptDescr Opts]
+options =
+ [ Option "h?" ["help"] (NoArg Help) "This help"
+ , Option "V" ["version"] (NoArg Version) "Show version information"
+ , Option "f" ["font"] (ReqArg Font "font name") "The font name"
+ , Option "w" ["wmclass"] (ReqArg WmClass "class") "X11 WM_CLASS property"
+ , Option "n" ["wmname"] (ReqArg WmName "name") "X11 WM_NAME property"
+ , Option "B" ["bgcolor"] (ReqArg BgColor "bg color" )
+ "The background color. Default black"
+ , Option "F" ["fgcolor"] (ReqArg FgColor "fg color")
+ "The foreground color. Default grey"
+ , Option "i" ["iconroot"] (ReqArg IconRoot "path")
+ "Root directory for icon pattern paths. Default '.'"
+ , Option "A" ["alpha"] (ReqArg Alpha "alpha")
+ "The transparency: 0 is transparent, 255 is opaque. Default: 255"
+ , Option "o" ["top"] (NoArg T) "Place xmobar at the top of the screen"
+ , Option "b" ["bottom"] (NoArg B)
+ "Place xmobar at the bottom of the screen"
+ , Option "d" ["dock"] (NoArg D)
+ "Don't override redirect from WM and function as a dock"
+ , Option "a" ["alignsep"] (ReqArg AlignSep "alignsep")
+ "Separators for left, center and right text\nalignment. Default: '}{'"
+ , Option "s" ["sepchar"] (ReqArg SepChar "char")
+ ("The character used to separate commands in" ++
+ "\nthe output template. Default '%'")
+ , Option "t" ["template"] (ReqArg Template "template")
+ "The output template"
+ , Option "c" ["commands"] (ReqArg Commands "commands")
+ "The list of commands to be executed"
+ , Option "C" ["add-command"] (ReqArg AddCommand "command")
+ "Add to the list of commands to be executed"
+ , Option "x" ["screen"] (ReqArg OnScr "screen")
+ "On which X screen number to start"
+ , Option "p" ["position"] (ReqArg Position "position")
+ "Specify position of xmobar. Same syntax as in config file"
+ ]
+
+getOpts :: [String] -> IO ([Opts], [String])
+getOpts argv =
+ case getOpt Permute options argv of
+ (o,n,[]) -> return (o,n)
+ (_,_,errs) -> error (concat errs ++ usage)
+
+usage :: String
+usage = usageInfo header options ++ footer
+ where header = "Usage: xmobar [OPTION...] [FILE]\nOptions:"
+ footer = "\nMail bug reports and suggestions to " ++ mail ++ "\n"
+
+info :: String
+info = "xmobar " ++ showVersion version
+ ++ "\n (C) 2007 - 2010 Andrea Rossato "
+ ++ "\n (C) 2010 - 2018 Jose A Ortega Ruiz\n "
+ ++ mail ++ "\n" ++ license
+
+mail :: String
+mail = "<mail@jao.io>"
+
+license :: String
+license = "\nThis program is distributed in the hope that it will be useful," ++
+ "\nbut WITHOUT ANY WARRANTY; without even the implied warranty of" ++
+ "\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." ++
+ "\nSee the License for more details."
+
+doOpts :: Config -> [Opts] -> IO Config
+doOpts conf [] =
+ return (conf {lowerOnStart = lowerOnStart conf && overrideRedirect conf})
+doOpts conf (o:oo) =
+ case o of
+ Help -> putStr usage >> exitSuccess
+ Version -> putStrLn info >> exitSuccess
+ Font s -> doOpts' (conf {font = s})
+ WmClass s -> doOpts' (conf {wmClass = s})
+ WmName s -> doOpts' (conf {wmName = s})
+ BgColor s -> doOpts' (conf {bgColor = s})
+ FgColor s -> doOpts' (conf {fgColor = s})
+ Alpha n -> doOpts' (conf {alpha = read n})
+ T -> doOpts' (conf {position = Top})
+ B -> doOpts' (conf {position = Bottom})
+ D -> doOpts' (conf {overrideRedirect = False})
+ AlignSep s -> doOpts' (conf {alignSep = s})
+ SepChar s -> doOpts' (conf {sepChar = s})
+ Template s -> doOpts' (conf {template = s})
+ IconRoot s -> doOpts' (conf {iconRoot = s})
+ OnScr n -> doOpts' (conf {position = OnScreen (read n) $ position conf})
+ Commands s -> case readCom 'c' s of
+ Right x -> doOpts' (conf {commands = x})
+ Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1)
+ AddCommand s -> case readCom 'C' s of
+ Right x -> doOpts' (conf {commands = commands conf ++ x})
+ Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1)
+ Position s -> readPosition s
+ where readCom c str =
+ case readStr str of
+ [x] -> Right x
+ _ -> Left ("xmobar: cannot read list of commands " ++
+ "specified with the -" ++ c:" option\n")
+ readStr str = [x | (x,t) <- reads str, ("","") <- lex t]
+ doOpts' opts = doOpts opts oo
+ readPosition string =
+ case readMaybe string of
+ Just x -> doOpts' (conf { position = x })
+ Nothing -> do
+ putStrLn "Can't parse position option, ignoring"
+ doOpts' conf
diff --git a/src/Xmobar.hs b/src/lib/Xmobar.hs
index e4eb4b7..e4eb4b7 100644
--- a/src/Xmobar.hs
+++ b/src/lib/Xmobar.hs
diff --git a/src/Xmobar/Actions.hs b/src/lib/Xmobar/Actions.hs
index 7901845..7901845 100644
--- a/src/Xmobar/Actions.hs
+++ b/src/lib/Xmobar/Actions.hs
diff --git a/src/Xmobar/Bitmap.hs b/src/lib/Xmobar/Bitmap.hs
index 314ce02..314ce02 100644
--- a/src/Xmobar/Bitmap.hs
+++ b/src/lib/Xmobar/Bitmap.hs
diff --git a/src/Xmobar/ColorCache.hs b/src/lib/Xmobar/ColorCache.hs
index f17aa0d..f17aa0d 100644
--- a/src/Xmobar/ColorCache.hs
+++ b/src/lib/Xmobar/ColorCache.hs
diff --git a/src/Xmobar/Commands.hs b/src/lib/Xmobar/Commands.hs
index ececdd9..ececdd9 100644
--- a/src/Xmobar/Commands.hs
+++ b/src/lib/Xmobar/Commands.hs
diff --git a/src/Xmobar/Config.hs b/src/lib/Xmobar/Config.hs
index 21b29fa..21b29fa 100644
--- a/src/Xmobar/Config.hs
+++ b/src/lib/Xmobar/Config.hs
diff --git a/src/Xmobar/Environment.hs b/src/lib/Xmobar/Environment.hs
index 8a9223a..8a9223a 100644
--- a/src/Xmobar/Environment.hs
+++ b/src/lib/Xmobar/Environment.hs
diff --git a/src/Xmobar/IPC/DBus.hs b/src/lib/Xmobar/IPC/DBus.hs
index 894637b..894637b 100644
--- a/src/Xmobar/IPC/DBus.hs
+++ b/src/lib/Xmobar/IPC/DBus.hs
diff --git a/src/Xmobar/Localize.hsc b/src/lib/Xmobar/Localize.hsc
index 984aa2b..984aa2b 100644
--- a/src/Xmobar/Localize.hsc
+++ b/src/lib/Xmobar/Localize.hsc
diff --git a/src/Xmobar/MinXft.hsc b/src/lib/Xmobar/MinXft.hsc
index 0bf36c7..0bf36c7 100644
--- a/src/Xmobar/MinXft.hsc
+++ b/src/lib/Xmobar/MinXft.hsc
diff --git a/src/Xmobar/Parsers.hs b/src/lib/Xmobar/Parsers.hs
index 33afd09..33afd09 100644
--- a/src/Xmobar/Parsers.hs
+++ b/src/lib/Xmobar/Parsers.hs
diff --git a/src/Xmobar/Plugins.hs b/src/lib/Xmobar/Plugins.hs
index 75ee306..75ee306 100644
--- a/src/Xmobar/Plugins.hs
+++ b/src/lib/Xmobar/Plugins.hs
diff --git a/src/Xmobar/Plugins/BufferedPipeReader.hs b/src/lib/Xmobar/Plugins/BufferedPipeReader.hs
index d4d30a1..d4d30a1 100644
--- a/src/Xmobar/Plugins/BufferedPipeReader.hs
+++ b/src/lib/Xmobar/Plugins/BufferedPipeReader.hs
diff --git a/src/Xmobar/Plugins/CommandReader.hs b/src/lib/Xmobar/Plugins/CommandReader.hs
index 80b6299..80b6299 100644
--- a/src/Xmobar/Plugins/CommandReader.hs
+++ b/src/lib/Xmobar/Plugins/CommandReader.hs
diff --git a/src/Xmobar/Plugins/Date.hs b/src/lib/Xmobar/Plugins/Date.hs
index fdc6a56..fdc6a56 100644
--- a/src/Xmobar/Plugins/Date.hs
+++ b/src/lib/Xmobar/Plugins/Date.hs
diff --git a/src/Xmobar/Plugins/DateZone.hs b/src/lib/Xmobar/Plugins/DateZone.hs
index 753f530..753f530 100644
--- a/src/Xmobar/Plugins/DateZone.hs
+++ b/src/lib/Xmobar/Plugins/DateZone.hs
diff --git a/src/Xmobar/Plugins/EWMH.hs b/src/lib/Xmobar/Plugins/EWMH.hs
index 363ec90..363ec90 100644
--- a/src/Xmobar/Plugins/EWMH.hs
+++ b/src/lib/Xmobar/Plugins/EWMH.hs
diff --git a/src/Xmobar/Plugins/Kbd.hsc b/src/lib/Xmobar/Plugins/Kbd.hsc
index 372386e..372386e 100644
--- a/src/Xmobar/Plugins/Kbd.hsc
+++ b/src/lib/Xmobar/Plugins/Kbd.hsc
diff --git a/src/Xmobar/Plugins/Locks.hs b/src/lib/Xmobar/Plugins/Locks.hs
index 9a971e5..9a971e5 100644
--- a/src/Xmobar/Plugins/Locks.hs
+++ b/src/lib/Xmobar/Plugins/Locks.hs
diff --git a/src/Xmobar/Plugins/MBox.hs b/src/lib/Xmobar/Plugins/MBox.hs
index 2281629..2281629 100644
--- a/src/Xmobar/Plugins/MBox.hs
+++ b/src/lib/Xmobar/Plugins/MBox.hs
diff --git a/src/Xmobar/Plugins/Mail.hs b/src/lib/Xmobar/Plugins/Mail.hs
index c41b5b3..c41b5b3 100644
--- a/src/Xmobar/Plugins/Mail.hs
+++ b/src/lib/Xmobar/Plugins/Mail.hs
diff --git a/src/Xmobar/Plugins/MarqueePipeReader.hs b/src/lib/Xmobar/Plugins/MarqueePipeReader.hs
index ad6f27f..ad6f27f 100644
--- a/src/Xmobar/Plugins/MarqueePipeReader.hs
+++ b/src/lib/Xmobar/Plugins/MarqueePipeReader.hs
diff --git a/src/Xmobar/Plugins/Monitors.hs b/src/lib/Xmobar/Plugins/Monitors.hs
index 64d38f0..64d38f0 100644
--- a/src/Xmobar/Plugins/Monitors.hs
+++ b/src/lib/Xmobar/Plugins/Monitors.hs
diff --git a/src/Xmobar/Plugins/Monitors/Alsa.hs b/src/lib/Xmobar/Plugins/Monitors/Alsa.hs
index 21a2786..21a2786 100644
--- a/src/Xmobar/Plugins/Monitors/Alsa.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Alsa.hs
diff --git a/src/Xmobar/Plugins/Monitors/Batt.hs b/src/lib/Xmobar/Plugins/Monitors/Batt.hs
index 80f4275..80f4275 100644
--- a/src/Xmobar/Plugins/Monitors/Batt.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Batt.hs
diff --git a/src/Xmobar/Plugins/Monitors/Bright.hs b/src/lib/Xmobar/Plugins/Monitors/Bright.hs
index fe72219..fe72219 100644
--- a/src/Xmobar/Plugins/Monitors/Bright.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Bright.hs
diff --git a/src/Xmobar/Plugins/Monitors/CatInt.hs b/src/lib/Xmobar/Plugins/Monitors/CatInt.hs
index 781eded..781eded 100644
--- a/src/Xmobar/Plugins/Monitors/CatInt.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/CatInt.hs
diff --git a/src/Xmobar/Plugins/Monitors/Common.hs b/src/lib/Xmobar/Plugins/Monitors/Common.hs
index 272690b..272690b 100644
--- a/src/Xmobar/Plugins/Monitors/Common.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Common.hs
diff --git a/src/Xmobar/Plugins/Monitors/CoreCommon.hs b/src/lib/Xmobar/Plugins/Monitors/CoreCommon.hs
index a84198e..a84198e 100644
--- a/src/Xmobar/Plugins/Monitors/CoreCommon.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/CoreCommon.hs
diff --git a/src/Xmobar/Plugins/Monitors/CoreTemp.hs b/src/lib/Xmobar/Plugins/Monitors/CoreTemp.hs
index 48fe428..48fe428 100644
--- a/src/Xmobar/Plugins/Monitors/CoreTemp.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/CoreTemp.hs
diff --git a/src/Xmobar/Plugins/Monitors/Cpu.hs b/src/lib/Xmobar/Plugins/Monitors/Cpu.hs
index 6befe7d..6befe7d 100644
--- a/src/Xmobar/Plugins/Monitors/Cpu.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Cpu.hs
diff --git a/src/Xmobar/Plugins/Monitors/CpuFreq.hs b/src/lib/Xmobar/Plugins/Monitors/CpuFreq.hs
index 1afedfa..1afedfa 100644
--- a/src/Xmobar/Plugins/Monitors/CpuFreq.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/CpuFreq.hs
diff --git a/src/Xmobar/Plugins/Monitors/Disk.hs b/src/lib/Xmobar/Plugins/Monitors/Disk.hs
index aedad75..aedad75 100644
--- a/src/Xmobar/Plugins/Monitors/Disk.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Disk.hs
diff --git a/src/Xmobar/Plugins/Monitors/MPD.hs b/src/lib/Xmobar/Plugins/Monitors/MPD.hs
index 9525254..9525254 100644
--- a/src/Xmobar/Plugins/Monitors/MPD.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/MPD.hs
diff --git a/src/Xmobar/Plugins/Monitors/Mem.hs b/src/lib/Xmobar/Plugins/Monitors/Mem.hs
index d69921b..d69921b 100644
--- a/src/Xmobar/Plugins/Monitors/Mem.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Mem.hs
diff --git a/src/Xmobar/Plugins/Monitors/Mpris.hs b/src/lib/Xmobar/Plugins/Monitors/Mpris.hs
index 3556649..3556649 100644
--- a/src/Xmobar/Plugins/Monitors/Mpris.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Mpris.hs
diff --git a/src/Xmobar/Plugins/Monitors/MultiCpu.hs b/src/lib/Xmobar/Plugins/Monitors/MultiCpu.hs
index 3db3b5f..3db3b5f 100644
--- a/src/Xmobar/Plugins/Monitors/MultiCpu.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/MultiCpu.hs
diff --git a/src/Xmobar/Plugins/Monitors/Net.hs b/src/lib/Xmobar/Plugins/Monitors/Net.hs
index 81a5f6b..81a5f6b 100644
--- a/src/Xmobar/Plugins/Monitors/Net.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Net.hs
diff --git a/src/Xmobar/Plugins/Monitors/Swap.hs b/src/lib/Xmobar/Plugins/Monitors/Swap.hs
index fcaab84..fcaab84 100644
--- a/src/Xmobar/Plugins/Monitors/Swap.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Swap.hs
diff --git a/src/Xmobar/Plugins/Monitors/Thermal.hs b/src/lib/Xmobar/Plugins/Monitors/Thermal.hs
index 320ae17..320ae17 100644
--- a/src/Xmobar/Plugins/Monitors/Thermal.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Thermal.hs
diff --git a/src/Xmobar/Plugins/Monitors/ThermalZone.hs b/src/lib/Xmobar/Plugins/Monitors/ThermalZone.hs
index bc46b59..bc46b59 100644
--- a/src/Xmobar/Plugins/Monitors/ThermalZone.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/ThermalZone.hs
diff --git a/src/Xmobar/Plugins/Monitors/Top.hs b/src/lib/Xmobar/Plugins/Monitors/Top.hs
index d6df249..d6df249 100644
--- a/src/Xmobar/Plugins/Monitors/Top.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Top.hs
diff --git a/src/Xmobar/Plugins/Monitors/UVMeter.hs b/src/lib/Xmobar/Plugins/Monitors/UVMeter.hs
index 079177f..079177f 100644
--- a/src/Xmobar/Plugins/Monitors/UVMeter.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/UVMeter.hs
diff --git a/src/Xmobar/Plugins/Monitors/Uptime.hs b/src/lib/Xmobar/Plugins/Monitors/Uptime.hs
index 235fc85..235fc85 100644
--- a/src/Xmobar/Plugins/Monitors/Uptime.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Uptime.hs
diff --git a/src/Xmobar/Plugins/Monitors/Volume.hs b/src/lib/Xmobar/Plugins/Monitors/Volume.hs
index 1d3281c..1d3281c 100644
--- a/src/Xmobar/Plugins/Monitors/Volume.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Volume.hs
diff --git a/src/Xmobar/Plugins/Monitors/Weather.hs b/src/lib/Xmobar/Plugins/Monitors/Weather.hs
index cb5bf07..cb5bf07 100644
--- a/src/Xmobar/Plugins/Monitors/Weather.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Weather.hs
diff --git a/src/Xmobar/Plugins/Monitors/Wireless.hs b/src/lib/Xmobar/Plugins/Monitors/Wireless.hs
index 545f6bc..545f6bc 100644
--- a/src/Xmobar/Plugins/Monitors/Wireless.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Wireless.hs
diff --git a/src/Xmobar/Plugins/PipeReader.hs b/src/lib/Xmobar/Plugins/PipeReader.hs
index 7166163..7166163 100644
--- a/src/Xmobar/Plugins/PipeReader.hs
+++ b/src/lib/Xmobar/Plugins/PipeReader.hs
diff --git a/src/Xmobar/Plugins/StdinReader.hs b/src/lib/Xmobar/Plugins/StdinReader.hs
index 372e4f9..372e4f9 100644
--- a/src/Xmobar/Plugins/StdinReader.hs
+++ b/src/lib/Xmobar/Plugins/StdinReader.hs
diff --git a/src/Xmobar/Plugins/Utils.hs b/src/lib/Xmobar/Plugins/Utils.hs
index 6546c15..6546c15 100644
--- a/src/Xmobar/Plugins/Utils.hs
+++ b/src/lib/Xmobar/Plugins/Utils.hs
diff --git a/src/Xmobar/Plugins/XMonadLog.hs b/src/lib/Xmobar/Plugins/XMonadLog.hs
index 6bbba59..6bbba59 100644
--- a/src/Xmobar/Plugins/XMonadLog.hs
+++ b/src/lib/Xmobar/Plugins/XMonadLog.hs
diff --git a/src/Xmobar/Runnable.hs b/src/lib/Xmobar/Runnable.hs
index 164f661..164f661 100644
--- a/src/Xmobar/Runnable.hs
+++ b/src/lib/Xmobar/Runnable.hs
diff --git a/src/Xmobar/Runnable.hs-boot b/src/lib/Xmobar/Runnable.hs-boot
index 0f67322..0f67322 100644
--- a/src/Xmobar/Runnable.hs-boot
+++ b/src/lib/Xmobar/Runnable.hs-boot
diff --git a/src/Xmobar/Signal.hs b/src/lib/Xmobar/Signal.hs
index bdc4be1..bdc4be1 100644
--- a/src/Xmobar/Signal.hs
+++ b/src/lib/Xmobar/Signal.hs
diff --git a/src/Xmobar/StatFS.hsc b/src/lib/Xmobar/StatFS.hsc
index 25de0df..25de0df 100644
--- a/src/Xmobar/StatFS.hsc
+++ b/src/lib/Xmobar/StatFS.hsc
diff --git a/src/Xmobar/Window.hs b/src/lib/Xmobar/Window.hs
index c8228de..c8228de 100644
--- a/src/Xmobar/Window.hs
+++ b/src/lib/Xmobar/Window.hs
diff --git a/src/Xmobar/XPMFile.hsc b/src/lib/Xmobar/XPMFile.hsc
index 03d534f..03d534f 100644
--- a/src/Xmobar/XPMFile.hsc
+++ b/src/lib/Xmobar/XPMFile.hsc
diff --git a/src/Xmobar/XUtil.hsc b/src/lib/Xmobar/XUtil.hsc
index 05e6fad..05e6fad 100644
--- a/src/Xmobar/XUtil.hsc
+++ b/src/lib/Xmobar/XUtil.hsc