diff options
author | jao <jao@gnu.org> | 2020-06-13 20:44:28 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2020-06-13 20:44:28 +0100 |
commit | 438a19d8759f4367f4bb2e24a31f1918332d82b1 (patch) | |
tree | 599f23a9569c0016b5183dbcbb8c2ae971783c32 /src/Xmobar/Plugins/Monitors | |
parent | 53a07a4179eaecb3493e56fc2dc03447b2753af0 (diff) | |
download | xmobar-438a19d8759f4367f4bb2e24a31f1918332d82b1.tar.gz xmobar-438a19d8759f4367f4bb2e24a31f1918332d82b1.tar.bz2 |
Look up only the first coretemp.N/hwmon dir in MultiCoreTemp
Diffstat (limited to 'src/Xmobar/Plugins/Monitors')
-rw-r--r-- | src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs | 14 |
1 files 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. |