From a8653d8712c2d218adf3f70cef7e511060bed695 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Wed, 18 Jul 2007 17:12:11 +0200 Subject: Monitors are now a Plugin that can be removed from Config.hs darcs-hash:20070718151211-d6583-7e0e49c22d07feda72d03370fd592c196dfcc9c1.gz --- Monitors/Batt.hs | 67 -------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 Monitors/Batt.hs (limited to 'Monitors/Batt.hs') diff --git a/Monitors/Batt.hs b/Monitors/Batt.hs deleted file mode 100644 index 57e9f6f..0000000 --- a/Monitors/Batt.hs +++ /dev/null @@ -1,67 +0,0 @@ ------------------------------------------------------------------------------ --- | --- Module : Monitors.Batt --- Copyright : (c) Andrea Rossato --- License : BSD-style (see LICENSE) --- --- Maintainer : Andrea Rossato --- Stability : unstable --- Portability : unportable --- --- A battery monitor for Xmobar --- ------------------------------------------------------------------------------ - -module Monitors.Batt where - -import qualified Data.ByteString.Lazy.Char8 as B -import System.Posix.Files - -import Monitors.Common - -battConfig :: IO MConfig -battConfig = mkMConfig - "Batt: " -- template - ["left"] -- available replacements - -fileB1 :: (String, String) -fileB1 = ("/proc/acpi/battery/BAT1/info", "/proc/acpi/battery/BAT1/state") - -fileB2 :: (String, String) -fileB2 = ("/proc/acpi/battery/BAT2/info", "/proc/acpi/battery/BAT2/state") - -checkFileBatt :: (String, String) -> IO Bool -checkFileBatt (i,_) = - fileExist i - -readFileBatt :: (String, String) -> IO (B.ByteString, B.ByteString) -readFileBatt (i,s) = - do a <- B.readFile i - b <- B.readFile s - return (a,b) - -parseBATT :: IO Float -parseBATT = - do (a1,b1) <- readFileBatt fileB1 - c <- checkFileBatt fileB2 - let sp p s = read $ stringParser p s - (fu, pr) = (sp (3,2) a1, sp (2,4) b1) - case c of - True -> do (a2,b2) <- readFileBatt fileB1 - let full = fu + (sp (3,2) a2) - present = pr + (sp (2,4) b2) - return $ present / full - _ -> return $ pr / fu - - -formatBatt :: Float -> Monitor [String] -formatBatt x = - do let f s = floatToPercent (s / 100) - l <- showWithColors f (x * 100) - return [l] - -runBatt :: [String] -> Monitor String -runBatt _ = - do c <- io $ parseBATT - l <- formatBatt c - parseTemplate l -- cgit v1.2.3