summaryrefslogtreecommitdiffhomepage
path: root/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/Monitors/CoreCommon.hs8
-rw-r--r--Plugins/Monitors/CoreTemp.hs8
-rw-r--r--Plugins/Monitors/CpuFreq.hs7
-rw-r--r--Plugins/Monitors/Thermal.hs4
4 files changed, 27 insertions, 0 deletions
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: <core0>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: <core0>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: <temp>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