From 438a19d8759f4367f4bb2e24a31f1918332d82b1 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 13 Jun 2020 20:44:28 +0100 Subject: Look up only the first coretemp.N/hwmon dir in MultiCoreTemp --- src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs b/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs index a030943..8c1d1ad 100644 --- a/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs +++ b/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs @@ -76,19 +76,23 @@ cTConfig = mkMConfig cTTemplate cTOptions ] ++ map (("core" ++) . show) [0 :: Int ..] --- | Returns the first coretemp.N path found, or /sys/class. -coretempPath :: IO String +-- | Returns the first coretemp.N path found. +coretempPath :: IO (Maybe String) coretempPath = do xs <- filterM doesDirectoryExist ps - return (if null xs then "/sys/class/" else head xs) + return (if null xs then Nothing else Just $ head xs) where ps = [ "/sys/bus/platform/devices/coretemp." ++ show (x :: Int) ++ "/" | x <- [0..9] ] -- | Returns the first hwmonN in coretemp path found or the ones in sys/class. hwmonPaths :: IO [String] hwmonPaths = do p <- coretempPath - let cps = [ p ++ "hwmon/hwmon" ++ show (x :: Int) ++ "/" + let (sc, path) = case p of + Just s -> (False, s) + Nothing -> (True, "/sys/class/") + let cps = [ path ++ "hwmon/hwmon" ++ show (x :: Int) ++ "/" | x <- [0..9] ] - filterM doesDirectoryExist cps + ecps <- filterM doesDirectoryExist cps + return $ if sc || null ecps then ecps else [head ecps] -- | Checks Labels, if they refer to a core and returns Strings of core- -- temperatures. -- cgit v1.2.3