summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorSam Kirby <sam.kirby94@hotmail.co.uk>2021-05-18 14:15:10 +0100
committerSam Kirby <sam.kirby94@hotmail.co.uk>2021-05-19 16:04:52 +0100
commit7d27b92f7e8104283bd71e3c5bbdcb7b7ec54301 (patch)
tree90f5b6c32a6de4f788ce1ea0923ac65deddae195 /src
parent4bfad37993331e12b0915a1db0e4639b8931236b (diff)
downloadxmobar-7d27b92f7e8104283bd71e3c5bbdcb7b7ec54301.tar.gz
xmobar-7d27b92f7e8104283bd71e3c5bbdcb7b7ec54301.tar.bz2
Add k10temp plugin
The existing support for the coretemp kernel driver only works with Intel CPUs. This commit extends support for temperature monitoring to AMD CPUs. k10temp is a kernel driver for monitoring the temperature of AMD processors. It supports everything from AMD's 10h (Opteron/Athlon) family of processors to the latest 19h (Zen 3) family. Reference: https://www.kernel.org/doc/html/latest/hwmon/k10temp.html The meaning of the various temperatures made available has changed over the years and only `Tctl` is available on processors prior to the 17h family. Labels for these temperatures are present but as Tctl and Tdie do not contain a number I could not find a way to use these as `checkedDataRetrieval` expects an integer label. It is a PCI device and so an address needs to be supplied as part of the configuration. Example configuration: `Run K10Temp "0000:00:18.3" ["--template", "T: <Tdie>C | <Tccd1>C"] 60`
Diffstat (limited to 'src')
-rw-r--r--src/Xmobar/Plugins/Monitors.hs5
-rw-r--r--src/Xmobar/Plugins/Monitors/K10Temp.hs43
2 files changed, 48 insertions, 0 deletions
diff --git a/src/Xmobar/Plugins/Monitors.hs b/src/Xmobar/Plugins/Monitors.hs
index 594065c..13e5694 100644
--- a/src/Xmobar/Plugins/Monitors.hs
+++ b/src/Xmobar/Plugins/Monitors.hs
@@ -35,6 +35,7 @@ import Xmobar.Plugins.Monitors.ThermalZone
import Xmobar.Plugins.Monitors.CpuFreq
import Xmobar.Plugins.Monitors.CoreTemp
import Xmobar.Plugins.Monitors.MultiCoreTemp
+import Xmobar.Plugins.Monitors.K10Temp
import Xmobar.Plugins.Monitors.Disk
import Xmobar.Plugins.Monitors.Top
import Xmobar.Plugins.Monitors.Uptime
@@ -74,6 +75,7 @@ data Monitors = Network Interface Args Rate
| CpuFreq Args Rate
| CoreTemp Args Rate
| MultiCoreTemp Args Rate
+ | K10Temp Slot Args Rate
| TopProc Args Rate
| TopMem Args Rate
| Uptime Args Rate
@@ -113,6 +115,7 @@ type ZoneNo = Int
type Interface = String
type Rate = Int
type DiskSpec = [(String, String)]
+type Slot = String
instance Exec Monitors where
#ifdef WEATHER
@@ -136,6 +139,7 @@ instance Exec Monitors where
alias (TopMem _ _) = "topmem"
alias (CoreTemp _ _) = "coretemp"
alias (MultiCoreTemp _ _) = "multicoretemp"
+ alias (K10Temp _ _ _) = "k10temp"
alias DiskU {} = "disku"
alias DiskIO {} = "diskio"
alias (Uptime _ _) = "uptime"
@@ -181,6 +185,7 @@ instance Exec Monitors where
start (CpuFreq a r) = runM a cpuFreqConfig runCpuFreq r
start (CoreTemp a r) = runM a coreTempConfig runCoreTemp r
start (MultiCoreTemp a r) = startMultiCoreTemp a r
+ start (K10Temp s a r) = runM (a ++ [s]) k10TempConfig runK10Temp r
start (DiskU s a r) = runM a diskUConfig (runDiskU s) r
start (DiskIO s a r) = startDiskIO s a r
start (Uptime a r) = runM a uptimeConfig runUptime r
diff --git a/src/Xmobar/Plugins/Monitors/K10Temp.hs b/src/Xmobar/Plugins/Monitors/K10Temp.hs
new file mode 100644
index 0000000..ea2856d
--- /dev/null
+++ b/src/Xmobar/Plugins/Monitors/K10Temp.hs
@@ -0,0 +1,43 @@
+-----------------------------------------------------------------------------
+-- |
+-- 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
+
+import Data.Char (isDigit)
+
+-- |
+-- 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'