diff options
author | Sibi Prabakaran <sibi@psibi.in> | 2020-06-14 09:46:47 +0530 |
---|---|---|
committer | jao <jao@gnu.org> | 2020-06-23 16:38:20 +0100 |
commit | b4f0f35ef118064bc7829b6224a896b448a37bc4 (patch) | |
tree | ccee394fdd32d6bb4d65bf21648cab3b00274883 /src/Xmobar/Plugins/Monitors/Common/Run.hs | |
parent | 2b13b5cf6595d81280c95eb9cf507a9817e3f641 (diff) | |
download | xmobar-b4f0f35ef118064bc7829b6224a896b448a37bc4.tar.gz xmobar-b4f0f35ef118064bc7829b6224a896b448a37bc4.tar.bz2 |
Optimize CPU monitor
Diffstat (limited to 'src/Xmobar/Plugins/Monitors/Common/Run.hs')
-rw-r--r-- | src/Xmobar/Plugins/Monitors/Common/Run.hs | 21 |
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 () |