From 6ac13d70d701bc6f0e8a24ef4fa67e501403fe81 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 11 Dec 2010 14:18:49 -0500 Subject: Don't hard code the number of values Make an infinite list of empty strings so that if something is asked for and cannot be provided, index errors don't occur. --- Plugins/Monitors/Cpu.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Plugins/Monitors/Cpu.hs') diff --git a/Plugins/Monitors/Cpu.hs b/Plugins/Monitors/Cpu.hs index 71e8ac3..fb5e9e2 100644 --- a/Plugins/Monitors/Cpu.hs +++ b/Plugins/Monitors/Cpu.hs @@ -39,7 +39,7 @@ parseCPU = return percent formatCpu :: [Float] -> Monitor [String] -formatCpu [] = return [""] +formatCpu [] = return $ repeat "" formatCpu xs = do let t = foldr (+) 0 $ take 3 xs b <- showPercentBar (100 * t) t -- cgit v1.2.3 From 096aee3a1667e056fe906967cc2b078e8122e2b4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 11 Dec 2010 14:19:42 -0500 Subject: Use `head' rather than `flip (!!) 0' --- Plugins/Monitors/Cpu.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Plugins/Monitors/Cpu.hs') diff --git a/Plugins/Monitors/Cpu.hs b/Plugins/Monitors/Cpu.hs index fb5e9e2..ab89246 100644 --- a/Plugins/Monitors/Cpu.hs +++ b/Plugins/Monitors/Cpu.hs @@ -28,7 +28,7 @@ cpuData = do s <- B.readFile "/proc/stat" cpuParser :: B.ByteString -> [Float] cpuParser = - map (read . B.unpack) . tail . B.words . flip (!!) 0 . B.lines + map (read . B.unpack) . tail . B.words . head . B.lines parseCPU :: IO [Float] parseCPU = -- cgit v1.2.3