diff options
author | slotThe <soliditsallgood@tuta.io> | 2020-02-03 09:38:02 +0100 |
---|---|---|
committer | slotThe <soliditsallgood@tuta.io> | 2020-02-05 09:21:44 +0100 |
commit | ceece8eb3de04edbc84deb683225f05c763aa1b0 (patch) | |
tree | 9cc04b3d12dbb17b3ca630f554dfc851a8fb3d6e /src/Xmobar/Plugins/Monitors/Common | |
parent | 1ddcc4d35ddee16e49b74acb4d94c66aecd52041 (diff) | |
download | xmobar-ceece8eb3de04edbc84deb683225f05c763aa1b0.tar.gz xmobar-ceece8eb3de04edbc84deb683225f05c763aa1b0.tar.bz2 |
New function `getArgvs` to get all values from user input
Diffstat (limited to 'src/Xmobar/Plugins/Monitors/Common')
-rw-r--r-- | src/Xmobar/Plugins/Monitors/Common/Run.hs | 8 | ||||
-rw-r--r-- | src/Xmobar/Plugins/Monitors/Common/Types.hs | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Common/Run.hs b/src/Xmobar/Plugins/Monitors/Common/Run.hs index 74a7695..a73a6fb 100644 --- a/src/Xmobar/Plugins/Monitors/Common/Run.hs +++ b/src/Xmobar/Plugins/Monitors/Common/Run.hs @@ -19,6 +19,7 @@ module Xmobar.Plugins.Monitors.Common.Run ( runM , runMD , runMB , runMBD + , getArgvs ) where import Control.Exception (SomeException,handle) @@ -55,6 +56,13 @@ options = , Option "E" ["maxtwidthellipsis"] (ReqArg MaxTotalWidthEllipsis "Maximum total width ellipsis") "Ellipsis to be added to the total text when it has reached its max width." ] +-- | Get all argument values out of a list of arguments. +getArgvs :: [String] -> [String] +getArgvs args = + case getOpt Permute options args of + (_, n, [] ) -> n + (_, _, errs) -> errs + doArgs :: [String] -> ([String] -> Monitor String) -> ([String] -> Monitor Bool) diff --git a/src/Xmobar/Plugins/Monitors/Common/Types.hs b/src/Xmobar/Plugins/Monitors/Common/Types.hs index c36a562..fc71da3 100644 --- a/src/Xmobar/Plugins/Monitors/Common/Types.hs +++ b/src/Xmobar/Plugins/Monitors/Common/Types.hs @@ -25,8 +25,9 @@ module Xmobar.Plugins.Monitors.Common.Types ( Monitor , io ) where -import Data.IORef -import Control.Monad.Reader +import Control.Monad.Reader (ReaderT, ask, liftIO) +import Data.IORef (IORef, modifyIORef, newIORef, readIORef) + type Monitor a = ReaderT MConfig IO a |