summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Disk.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-01-25 21:18:07 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-01-25 21:18:07 +0100
commitf8697fd2cd0e234876174df4fa03a2d0da7d4768 (patch)
tree2873a08df8c6a6c0f73fab9cdc23adf58dce096f /Plugins/Monitors/Disk.hs
parent5cc61bd61e64d35f7e0053920b45a5cafea0db64 (diff)
downloadxmobar-f8697fd2cd0e234876174df4fa03a2d0da7d4768.tar.gz
xmobar-f8697fd2cd0e234876174df4fa03a2d0da7d4768.tar.bz2
Inconsequential refactoring of Disk.
Ignore-this: b1d249892a8a8a44bdbe0dad9e366bcb darcs-hash:20100125201807-1d908-15da5af6614e14470544c5d4439b6bc027b9a0cf.gz
Diffstat (limited to 'Plugins/Monitors/Disk.hs')
-rw-r--r--Plugins/Monitors/Disk.hs23
1 files changed, 9 insertions, 14 deletions
diff --git a/Plugins/Monitors/Disk.hs b/Plugins/Monitors/Disk.hs
index 6b825d2..76116fb 100644
--- a/Plugins/Monitors/Disk.hs
+++ b/Plugins/Monitors/Disk.hs
@@ -77,20 +77,15 @@ formatDev path (dev, xs) =
in (dev, path, dat)
speedToStr :: Int -> Float -> String
-speedToStr n x =
- let units = ["B", "K", "M", "T"]
- toI = round :: Float -> Integer
- s y j = y ++ units !! j
- in
- if n > 2 || x < 103 then
- s (show $ toI x) n
- else
- if x < 1024 then
- let (ds, _) = floatToDigits 10 (x / 1024)
- tr = if length ds > 1 then show $ ds !! 1 else "0"
- in s ("0." ++ show (head ds) ++ tr) (n + 1)
- else
- speedToStr (n + 1) (x / 1024)
+speedToStr n x
+ | n > 2 || x < 103 = show (rInt x) ++ units !! n
+ | x < 1024 = "0." ++ s2 ds ++ units !! (n + 1)
+ | otherwise = speedToStr (n + 1) (x / 1024)
+ where units = ["B", "K", "M", "T"]
+ rInt = round :: Float ->Integer
+ s2 (a:b:_) = show a ++ show b
+ s2 as = show (head as) ++ "0"
+ (ds, _) = floatToDigits 10 (x / 1024)
runDisk' :: String -> [Float] -> Monitor String
runDisk' tmp xs = do