module Xmobar.Plugins.Monitors.Thermal where
import qualified Data.ByteString.Lazy.Char8 as B
import Xmobar.Plugins.Monitors.Common
import System.Posix.Files (fileExist)
thermalConfig :: IO MConfig
thermalConfig :: IO MConfig
thermalConfig = String -> [String] -> IO MConfig
mkMConfig
String
"Thm: <temp>C"
[String
"temp"]
runThermal :: [String] -> Monitor String
runThermal :: [String] -> Monitor String
runThermal [String]
args = do
let zone :: String
zone = forall a. [a] -> a
head [String]
args
file :: String
file = String
"/proc/acpi/thermal_zone/" forall a. [a] -> [a] -> [a]
++ String
zone forall a. [a] -> [a] -> [a]
++ String
"/temperature"
Bool
exists <- forall a. IO a -> Monitor a
io forall a b. (a -> b) -> a -> b
$ String -> IO Bool
fileExist String
file
if Bool
exists
then do Int
number <- forall a. IO a -> Monitor a
io forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((forall a. Read a => String -> a
read :: String -> Int) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pos -> ByteString -> String
stringParser (Int
1, Int
0)) (String -> IO ByteString
B.readFile String
file)
String
thermal <- forall a. (Num a, Ord a) => (a -> String) -> a -> Monitor String
showWithColors forall a. Show a => a -> String
show Int
number
[String] -> Monitor String
parseTemplate [ String
thermal ]
else forall a. Selector a -> Monitor a
getConfigValue MConfig -> IORef String
naString