summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Monitors/Common/Run.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xmobar/Plugins/Monitors/Common/Run.hs')
-rw-r--r--src/Xmobar/Plugins/Monitors/Common/Run.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Common/Run.hs b/src/Xmobar/Plugins/Monitors/Common/Run.hs
index 760eab1..9b0c1b7 100644
--- a/src/Xmobar/Plugins/Monitors/Common/Run.hs
+++ b/src/Xmobar/Plugins/Monitors/Common/Run.hs
@@ -23,6 +23,8 @@ module Xmobar.Plugins.Monitors.Common.Run ( runM
, runMLD
, getArgvs
, doArgs
+ , computePureConfig
+ , commonOptions
) where
import Control.Exception (SomeException,handle)
@@ -33,6 +35,8 @@ import System.Console.GetOpt
import Xmobar.Plugins.Monitors.Common.Types
import Xmobar.Run.Exec (doEveryTenthSeconds)
+commonOptions = options
+
options :: [OptDescr Opts]
options =
[
@@ -66,6 +70,8 @@ getArgvs args =
(_, n, [] ) -> n
(_, _, errs) -> errs
+
+
doArgs :: [String]
-> ([String] -> Monitor String)
-> ([String] -> Monitor Bool)
@@ -140,3 +146,18 @@ runMLD args conf action looper detect cb = handle (cb . showException) loop
showException :: SomeException -> String
showException = ("error: "++) . show . flip asTypeOf undefined
+
+computePureConfig :: [String] -> IO MConfig -> IO PureConfig
+computePureConfig args mconfig = do
+ newConfig <- getMConfig args mconfig
+ getPureConfig newConfig
+
+getMConfig :: [String] -> IO MConfig -> IO MConfig
+getMConfig args mconfig = do
+ config <- mconfig
+ runReaderT (updateOptions args >> ask) config
+
+updateOptions :: [String] -> Monitor ()
+updateOptions args= case getOpt Permute options args of
+ (o, _, []) -> doConfigOptions o
+ _ -> return ()