diff options
author | Felix Springer <felixspringer149@gmail.com> | 2019-07-10 18:19:57 +0200 |
---|---|---|
committer | Felix Springer <felixspringer149@gmail.com> | 2019-07-10 18:19:57 +0200 |
commit | 8e6b88a68acf40b2402d03a5a2564b6ebea63585 (patch) | |
tree | ae15b54862b9e87ff65e5466a8e088937497fabe /src | |
parent | ac38c7988355c7922ce3131500a16f1bc31f8c99 (diff) | |
download | xmobar-8e6b88a68acf40b2402d03a5a2564b6ebea63585.tar.gz xmobar-8e6b88a68acf40b2402d03a5a2564b6ebea63585.tar.bz2 |
touched up CoreTemp to use startCoreTemp
Diffstat (limited to 'src')
-rw-r--r-- | src/Xmobar/Plugins/Monitors.hs | 2 | ||||
-rw-r--r-- | src/Xmobar/Plugins/Monitors/CoreTemp.hs | 40 |
2 files changed, 22 insertions, 20 deletions
diff --git a/src/Xmobar/Plugins/Monitors.hs b/src/Xmobar/Plugins/Monitors.hs index 8ce5300..63bd0eb 100644 --- a/src/Xmobar/Plugins/Monitors.hs +++ b/src/Xmobar/Plugins/Monitors.hs @@ -174,7 +174,7 @@ instance Exec Monitors where start (BatteryN s a r _) = runM a battConfig (runBatt' s) r start (Brightness a r) = runM a brightConfig runBright r start (CpuFreq a r) = runM a cpuFreqConfig runCpuFreq r - start (CoreTemp a r) = runM a coreTempConfig runCoreTemp r + start (CoreTemp a r) = startCoreTemp a 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/CoreTemp.hs b/src/Xmobar/Plugins/Monitors/CoreTemp.hs index 3e462ce..3b9bd53 100644 --- a/src/Xmobar/Plugins/Monitors/CoreTemp.hs +++ b/src/Xmobar/Plugins/Monitors/CoreTemp.hs @@ -1,10 +1,11 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.CoreTemp --- Copyright : (c) Juraj Hercek +-- Copyright : (c) 2019 Felix Springer +-- (c) Juraj Hercek -- License : BSD-style (see LICENSE) -- --- Maintainer : Juraj Hercek <juhe_haskell@hck.sk> +-- Maintainer : Felix Springer <felixspringer149@gmail.com> -- Stability : unstable -- Portability : unportable -- @@ -12,32 +13,33 @@ -- ----------------------------------------------------------------------------- -module Xmobar.Plugins.Monitors.CoreTemp where +module Xmobar.Plugins.Monitors.CoreTemp (startCoreTemp) where import Xmobar.Plugins.Monitors.Common - import Data.Char (isDigit) --- | --- Core temperature default configuration. Default template contains only one --- core temperature, user should specify custom template in order to get more --- core frequencies. +-- | Generate Config with a default template and options. coreTempConfig :: IO MConfig -coreTempConfig = mkMConfig - "Temp: <core0>C" -- template - (map ((++) "core" . show) [0 :: Int ..]) -- available - -- replacements +coreTempConfig = mkMConfig coreTempTemplate coreTempOptions + where coreTempTemplate = "Temp: <total>°C" + coreTempOptions = map ((++) "core" . show) [0 :: Int ..] --- | --- Function retrieves monitor string holding the core temperature --- (or temperatures) +-- | FilePaths to read temperature from. Strings are seperated, where to +-- insert numbers. +coreTempFilePaths :: [[FilePath]] +coreTempFilePaths = [ ["/sys/bus/platform/devices/coretemp." , "/temp" , "_input"] + , ["/sys/bus/platform/devices/coretemp.", "/hwmon/hwmon", "/temp", "_input"] + ] + +-- | Retrieves Monitor String holding the core temperatures. runCoreTemp :: [String] -> Monitor String runCoreTemp _ = do dn <- getConfigValue decDigits failureMessage <- getConfigValue naString - let path = ["/sys/bus/platform/devices/coretemp.", "/temp", "_input"] - path' = ["/sys/bus/platform/devices/coretemp.", "/hwmon/hwmon", "/temp", "_input"] - lbl = Just ("_label", read . dropWhile (not . isDigit)) + let lbl = Just ("_label", read . dropWhile (not . isDigit)) divisor = 1e3 :: Double show' = showDigits (max 0 dn) - checkedDataRetrieval failureMessage [path, path'] lbl (/divisor) show' + checkedDataRetrieval failureMessage coreTempFilePaths lbl (/divisor) show' + +startCoreTemp :: [String] -> Int -> (String -> IO ()) -> IO () +startCoreTemp a r cb = runM a coreTempConfig runCoreTemp r cb |