From 81a2809683ceda6475d6d42df644dce102dd290b Mon Sep 17 00:00:00 2001 From: Juraj Hercek Date: Sun, 23 Dec 2007 00:14:19 +0100 Subject: Added documentation. - added Thermal, CoreTemp, CpuFreq documentation to README file - added haddock documentation darcs-hash:20071222231419-f49a6-beadaa214bd80a9eb12f568dbff8dcf0d88ecfe7.gz --- Plugins/Monitors/CoreCommon.hs | 8 ++++++++ Plugins/Monitors/CoreTemp.hs | 8 ++++++++ Plugins/Monitors/CpuFreq.hs | 7 +++++++ Plugins/Monitors/Thermal.hs | 4 ++++ 4 files changed, 27 insertions(+) (limited to 'Plugins') diff --git a/Plugins/Monitors/CoreCommon.hs b/Plugins/Monitors/CoreCommon.hs index de737d4..9a19cd5 100644 --- a/Plugins/Monitors/CoreCommon.hs +++ b/Plugins/Monitors/CoreCommon.hs @@ -18,6 +18,10 @@ import Plugins.Monitors.Common import System.Posix.Files (fileExist) import System.Directory +-- | +-- Function checks the existence of first file specified by pattern and if the +-- file doesn't exists failure message is shown, otherwise the data retrieval +-- is performed. checkedDataRetrieval :: String -> String -> String -> String -> Double -> Monitor String checkedDataRetrieval failureMessage dir file pattern divisor = do exists <- io $ fileExist $ foldl (++) dir ["/", pattern, "0/", file] @@ -25,6 +29,10 @@ checkedDataRetrieval failureMessage dir file pattern divisor = do False -> return failureMessage True -> retrieveData dir file pattern divisor +-- | +-- Function retrieves data from files in directory dir specified by pattern. +-- String values are converted to double and adjusted with divisor. Final array +-- is processed by template parser function and returned as monitor string. retrieveData :: String -> String -> String -> Double -> Monitor String retrieveData dir file pattern divisor = do count <- io $ dirCount dir pattern diff --git a/Plugins/Monitors/CoreTemp.hs b/Plugins/Monitors/CoreTemp.hs index e59f0d3..f014335 100644 --- a/Plugins/Monitors/CoreTemp.hs +++ b/Plugins/Monitors/CoreTemp.hs @@ -17,11 +17,19 @@ module Plugins.Monitors.CoreTemp where import Plugins.Monitors.Common import Plugins.Monitors.CoreCommon +-- | +-- Core temperature default configuration. Default template contains only one +-- core temperature, user should specify custom template in order to get more +-- core frequencies. coreTempConfig :: IO MConfig coreTempConfig = mkMConfig "Temp: C" -- template (zipWith (++) (repeat "core") (map show [0 :: Int ..])) -- available -- replacements + +-- | +-- Function retrieves monitor string holding the core temperature +-- (or temperatures) runCoreTemp :: [String] -> Monitor String runCoreTemp _ = do let dir = "/sys/bus/platform/devices" diff --git a/Plugins/Monitors/CpuFreq.hs b/Plugins/Monitors/CpuFreq.hs index 0258037..0bd99bb 100644 --- a/Plugins/Monitors/CpuFreq.hs +++ b/Plugins/Monitors/CpuFreq.hs @@ -17,11 +17,18 @@ module Plugins.Monitors.CpuFreq where import Plugins.Monitors.Common import Plugins.Monitors.CoreCommon +-- | +-- Cpu frequency default configuration. Default template contains only one +-- core frequency, user should specify custom template in order to get more +-- cpu frequencies. cpuFreqConfig :: IO MConfig cpuFreqConfig = mkMConfig "Freq: GHz" -- template (zipWith (++) (repeat "core") (map show [0 :: Int ..])) -- available -- replacements + +-- | +-- Function retrieves monitor string holding the cpu frequency (or frequencies) runCpuFreq :: [String] -> Monitor String runCpuFreq _ = do let dir = "/sys/devices/system/cpu" diff --git a/Plugins/Monitors/Thermal.hs b/Plugins/Monitors/Thermal.hs index 4814aa5..a3ffe6d 100644 --- a/Plugins/Monitors/Thermal.hs +++ b/Plugins/Monitors/Thermal.hs @@ -18,11 +18,15 @@ import qualified Data.ByteString.Lazy.Char8 as B import Plugins.Monitors.Common import System.Posix.Files (fileExist) +-- | Default thermal configuration. thermalConfig :: IO MConfig thermalConfig = mkMConfig "Thm: C" -- template ["temp"] -- available replacements +-- | Retrieves thermal information. Argument is name of thermal directory in +-- \/proc\/acpi\/thermal_zone. Returns the monitor string parsed according to +-- template (either default or user specified). runThermal :: [String] -> Monitor String runThermal args = do let zone = head args -- cgit v1.2.3