diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-01-25 21:48:39 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-01-25 21:48:39 +0100 |
commit | fe4c609e699237f7b272c56506106153f363dcb2 (patch) | |
tree | a094f40ece298a1c9a8f38300440712299abe77f | |
parent | f8697fd2cd0e234876174df4fa03a2d0da7d4768 (diff) | |
download | xmobar-fe4c609e699237f7b272c56506106153f363dcb2.tar.gz xmobar-fe4c609e699237f7b272c56506106153f363dcb2.tar.bz2 |
Another tiny refactoring.
Ignore-this: 50e76f6d7eb97924b10842a597a00066
darcs-hash:20100125204839-1d908-d067391e30d3ba383d1172c4ce4d00bbc799d171.gz
-rw-r--r-- | Plugins/Monitors/Disk.hs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Plugins/Monitors/Disk.hs b/Plugins/Monitors/Disk.hs index 76116fb..4f42218 100644 --- a/Plugins/Monitors/Disk.hs +++ b/Plugins/Monitors/Disk.hs @@ -78,14 +78,12 @@ formatDev path (dev, xs) = speedToStr :: Int -> Float -> String 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 + | n > 2 || x < 103 = show (round x :: Int) ++ units n + | x < 1024 = "0." ++ s2 (fst (floatToDigits 10 (x/1024))) ++ units (n+1) + | otherwise = speedToStr (n+1) (x/1024) + where units = (!!) ["B", "K", "M", "T"] 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 |