summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors/CpuFreq.hs
diff options
context:
space:
mode:
authorNorbert Zeh <nzeh@cs.dal.ca>2011-08-08 17:40:04 -0300
committerNorbert Zeh <nzeh@cs.dal.ca>2011-08-08 17:40:04 -0300
commiteab5960f5d2d6bd15119ff8f613b8d8f2df88287 (patch)
tree0a0f47c3ba0832508103c9c25f74b700fd9af022 /src/Plugins/Monitors/CpuFreq.hs
parentd533011ff9bbc082d445efb3dd1f4ad64a5e9c5f (diff)
downloadxmobar-eab5960f5d2d6bd15119ff8f613b8d8f2df88287.tar.gz
xmobar-eab5960f5d2d6bd15119ff8f613b8d8f2df88287.tar.bz2
Cope with new file system layout of CPU temperature sensor readings
Either due to a change in lm_sensors or in the kernel itself, the core temperature readings are no longer found in one directory per core but in multiple files in the same directory. What's worse is that the file names have little to do with the actual core number. This patch addresses this and is flexible enough to handle the old layout and the new one.
Diffstat (limited to 'src/Plugins/Monitors/CpuFreq.hs')
-rw-r--r--src/Plugins/Monitors/CpuFreq.hs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Plugins/Monitors/CpuFreq.hs b/src/Plugins/Monitors/CpuFreq.hs
index 4f01922..dcf75e5 100644
--- a/src/Plugins/Monitors/CpuFreq.hs
+++ b/src/Plugins/Monitors/CpuFreq.hs
@@ -28,16 +28,12 @@ cpuFreqConfig = mkMConfig
-- replacements
-- |
--- Function retrieves monitor string holding the cpu frequency (or
--- frequencies)
+-- Function retrieves monitor string holding the cpu frequency (or frequencies)
runCpuFreq :: [String] -> Monitor String
-runCpuFreq _ = do
- let dir = "/sys/devices/system/cpu"
- file = "cpufreq/scaling_cur_freq"
- pattern = "cpu"
- divisor = 1e6 :: Double
- failureMessage = "CpuFreq: N/A"
- fmt x | x < 1 = show (round (x * 1000) :: Integer) ++ "MHz"
- | otherwise = showDigits 1 x ++ "GHz"
- checkedDataRetrieval failureMessage dir file pattern (/divisor) fmt
+runCpuFreq _ = let path = ["/sys/devices/system/cpu/cpu", "/cpufreq/scaling_cur_freq"]
+ divisor = 1e6 :: Double
+ failureMessage = "CpuFreq: N/A"
+ fmt x | x < 1 = (show (round (x * 1000) :: Integer)) ++ "MHz"
+ | otherwise = (show x) ++ "GHz"
+ in checkedDataRetrieval failureMessage path Nothing (/divisor) fmt