diff options
| author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-07 20:47:35 +0100 | 
|---|---|---|
| committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-07 20:47:35 +0100 | 
| commit | 68dada84d0e3f820a38395051b374d14e12d5ff1 (patch) | |
| tree | de3f4df24922822a352b5c2d39a88e123f068180 | |
| parent | 9ee314056f6db2596477978a297692869a7a78ed (diff) | |
| download | xmobar-68dada84d0e3f820a38395051b374d14e12d5ff1.tar.gz xmobar-68dada84d0e3f820a38395051b374d14e12d5ff1.tar.bz2 | |
New Monitor option to enable/disable '%' in displayed percentages
The option is -P, and takes either "True" (the default) or anything
else to denote False.
| -rw-r--r-- | Plugins/Monitors/Common.hs | 12 | ||||
| -rw-r--r-- | README | 1 | 
2 files changed, 11 insertions, 2 deletions
| diff --git a/Plugins/Monitors/Common.hs b/Plugins/Monitors/Common.hs index b00deb6..637dbd9 100644 --- a/Plugins/Monitors/Common.hs +++ b/Plugins/Monitors/Common.hs @@ -88,6 +88,7 @@ data MConfig =         , barBack     :: IORef String         , barFore     :: IORef String         , barWidth    :: IORef Int +       , usePercent  :: IORef Bool         }  -- | from 'http:\/\/www.haskell.org\/hawiki\/MonadState' @@ -129,7 +130,8 @@ mkMConfig tmpl exprts =         bb <- newIORef ":"         bf <- newIORef "#"         bw <- newIORef 10 -       return $ MC nc l lc h hc t e p mn mx pc pr bb bf bw +       up <- newIORef True +       return $ MC nc l lc h hc t e p mn mx pc pr bb bf bw up  data Opts = HighColor String            | NormalColor String @@ -146,6 +148,7 @@ data Opts = HighColor String            | BarBack String            | BarFore String            | BarWidth String +          | UsePercent String  options :: [OptDescr Opts]  options = @@ -155,6 +158,7 @@ options =      , Option "n"  ["normal"]   (ReqArg NormalColor "color number"  )  "Color for the normal threshold: ex \"#00FF00\""      , Option "l"  ["low"]      (ReqArg LowColor "color number"     )  "Color for the low threshold: ex \"#0000FF\""      , Option "t"  ["template"] (ReqArg Template "output template"  )  "Output template." +    , Option "P"  ["percent"]  (ReqArg UsePercent "True/False"     )  "Use % to display percents."      , Option "p"  ["ppad"]     (ReqArg PercentPad "percent padding")  "Minimum percentage width."      , Option "m"  ["minwidth"] (ReqArg MinWidth "minimum width"    )  "Minimum field width"      , Option "M"  ["maxwidth"] (ReqArg MaxWidth "maximum width"    )  "Maximum field width" @@ -180,6 +184,7 @@ doConfigOptions [] = io $ return ()  doConfigOptions (o:oo) =      do let next = doConfigOptions oo             nz s = let x = read s in max 0 x +           bool s = s == "True"         case o of           High         h -> setConfigValue (read h) high >> next           Low          l -> setConfigValue (read l) low >> next @@ -197,6 +202,7 @@ doConfigOptions (o:oo) =           BarBack     bb -> setConfigValue bb barBack >> next           BarFore     bf -> setConfigValue bf barFore >> next           BarWidth    bw -> setConfigValue (nz bw) barWidth >> next +         UsePercent  up -> setConfigValue (bool up) usePercent >> next  runM :: [String] -> IO MConfig -> ([String] -> Monitor String) -> Int -> (String -> IO ()) -> IO ()  runM args conf action r cb = go @@ -339,8 +345,10 @@ floatToPercent n =    do pad <- getConfigValue ppad       pc <- getConfigValue padChars       pr <- getConfigValue padRight +     up <- getConfigValue usePercent       let p = showDigits 0 (n * 100) -     return $ padString pad pad pc pr p ++ "%" +         ps = if up then "%" else "" +     return $ padString pad pad pc pr p ++ ps  stringParser :: Pos -> B.ByteString -> String  stringParser (x,y) = @@ -535,6 +535,7 @@ These are the arguments that can be used for internal commands in the      -h color number     --high=color number         Color for the high threshold: es "#FF0000"      -n color number     --normal=color number       Color for the normal threshold: es "#00FF00"      -l color number     --low=color number          Color for the low threshold: es "#0000FF" +    -P True/False       --percent=True/False        Use % to display percents (default: True)      -p number           --ppad=number               Pad percentages to given width      -m number           --minwidth=number           Minimum field width      -M number           --maxwidth=number           Maximum field width | 
