module Xmobar.Plugins.Monitors.CoreTemp where
import Xmobar.Plugins.Monitors.Common
import Data.Char (isDigit)
coreTempConfig :: IO MConfig
coreTempConfig :: IO MConfig
coreTempConfig = String -> [String] -> IO MConfig
mkMConfig
String
"Temp: <core0>C"
(forall a b. (a -> b) -> [a] -> [b]
map (forall a. [a] -> [a] -> [a]
(++) String
"core" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show) [Int
0 :: Int ..])
runCoreTemp :: [String] -> Monitor String
runCoreTemp :: [String] -> Monitor String
runCoreTemp [String]
_ = do
Int
dn <- forall a. Selector a -> Monitor a
getConfigValue MConfig -> IORef Int
decDigits
String
failureMessage <- forall a. Selector a -> Monitor a
getConfigValue MConfig -> IORef String
naString
let path :: [String]
path = [String
"/sys/bus/platform/devices/coretemp.", String
"/temp", String
"_input"]
path' :: [String]
path' = [String
"/sys/bus/platform/devices/coretemp.", String
"/hwmon/hwmon", String
"/temp", String
"_input"]
lbl :: Maybe (String, String -> Int)
lbl = forall a. a -> Maybe a
Just (String
"_label", forall a. Read a => String -> a
read forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
isDigit))
divisor :: Double
divisor = Double
1e3 :: Double
show' :: Double -> String
show' = forall a. RealFloat a => Int -> a -> String
showDigits (forall a. Ord a => a -> a -> a
max Int
0 Int
dn)
forall a.
(Ord a, Num a) =>
String
-> [[String]]
-> Maybe (String, String -> Int)
-> (Double -> a)
-> (a -> String)
-> Monitor String
checkedDataRetrieval String
failureMessage [[String]
path, [String]
path'] Maybe (String, String -> Int)
lbl (forall a. Fractional a => a -> a -> a
/Double
divisor) Double -> String
show'