summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Thermal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/Monitors/Thermal.hs')
-rw-r--r--Plugins/Monitors/Thermal.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Plugins/Monitors/Thermal.hs b/Plugins/Monitors/Thermal.hs
new file mode 100644
index 0000000..2794a60
--- /dev/null
+++ b/Plugins/Monitors/Thermal.hs
@@ -0,0 +1,37 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : Plugins.Monitors.Thermal
+-- Copyright : (c) Juraj Hercek
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Juraj Hercek <juhe_haskell@hck.sk>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- A thermal monitor for Xmobar
+--
+-----------------------------------------------------------------------------
+
+module Plugins.Monitors.Thermal where
+
+import qualified Data.ByteString.Lazy.Char8 as B
+import Plugins.Monitors.Common
+import System.Posix.Files (fileExist)
+
+thermalConfig :: IO MConfig
+thermalConfig = mkMConfig
+ "Thm: <temp>C" -- template
+ ["temp"] -- available replacements
+
+runThermal :: [String] -> Monitor String
+runThermal _ = do
+ let file = "/proc/acpi/thermal_zone/THM/temperature"
+ exists <- io $ fileExist file
+ case exists of
+ False -> return "Thermal: N/A"
+ True -> do number <- io $ B.readFile file
+ >>= return . (read :: String -> Int)
+ . stringParser (1, 0)
+ thermal <- showWithColors show number
+ parseTemplate [ thermal ]
+