summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Monitors/K10Temp.hs
blob: e76d01a176000566129127690b5a36762ffee90a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-----------------------------------------------------------------------------
-- |
-- Module      :  Plugins.Monitors.CoreTemp
-- Copyright   :  (c) Juraj Hercek
-- License     :  BSD-style (see LICENSE)
--
-- Maintainer  :  Juraj Hercek <juhe_haskell@hck.sk>
-- Stability   :  unstable
-- Portability :  unportable
--
-- A temperature monitor that works with AMD CPUs for Xmobar
--
-----------------------------------------------------------------------------

module Xmobar.Plugins.Monitors.K10Temp where

import Xmobar.Plugins.Monitors.Common

-- |
-- K10 temperature default configuration. Default template contains only the
-- die temperature, user should specify custom template in order to get more
-- ccd or IO die temperatures.
k10TempConfig :: IO MConfig
k10TempConfig = mkMConfig
       "Temp: <Tdie>C" -- template
       ["Tctl", "Tdie", "Tccd1", "Tccd2", "Tccd3"
       ,"Tccd4", "Tccd5", "Tccd6", "Tccd7", "Tccd8"
       ] -- available replacements

-- |
-- Function retrieves monitor string holding the temperature
-- (or temperatures)
runK10Temp :: [String] -> Monitor String
runK10Temp args = do
   dn <- getConfigValue decDigits
   failureMessage <- getConfigValue naString
   let slot = head args
       path = ["/sys/bus/pci/drivers/k10temp/" ++ slot ++ "/hwmon/hwmon", "/temp", "_input"]
       divisor = 1e3 :: Double
       show' = showDigits (max 0 dn)
   checkedDataRetrieval failureMessage [path] Nothing (/divisor) show'