summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Common.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/Monitors/Common.hs')
-rw-r--r--Plugins/Monitors/Common.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Plugins/Monitors/Common.hs b/Plugins/Monitors/Common.hs
index e177e19..cc1a6a7 100644
--- a/Plugins/Monitors/Common.hs
+++ b/Plugins/Monitors/Common.hs
@@ -47,6 +47,8 @@ module Plugins.Monitors.Common (
, takeDigits
, showDigits
, floatToPercent
+ , parseFloat
+ , parseInt
, stringParser
-- * Threaded Actions
-- $thread
@@ -335,6 +337,16 @@ padString mnw mxw pad pr s =
else let ps = take (rlen - len) (cycle pad)
in if pr then s ++ ps else ps ++ s
+parseFloat :: String -> Float
+parseFloat s = case readFloat s of
+ (v, _):_ -> v
+ _ -> 0
+
+parseInt :: String -> Int
+parseInt s = case readDec s of
+ (v, _):_ -> v
+ _ -> 0
+
floatToPercent :: Float -> Monitor String
floatToPercent n =
do pad <- getConfigValue ppad