summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/Plugins')
-rw-r--r--src/Plugins/Monitors/ThermalZone.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Plugins/Monitors/ThermalZone.hs b/src/Plugins/Monitors/ThermalZone.hs
index 838a7f5..a4744b4 100644
--- a/src/Plugins/Monitors/ThermalZone.hs
+++ b/src/Plugins/Monitors/ThermalZone.hs
@@ -34,12 +34,16 @@ runThermalZone :: [String] -> Monitor String
runThermalZone args = do
let zone = head args
file = "/sys/class/thermal/thermal_zone" ++ zone ++ "/temp"
- handleIOError :: IOException -> IO B.ByteString
- handleIOError _ = return (B.pack "-1")
+ handleIOError :: IOException -> IO (Maybe B.ByteString)
+ handleIOError _ = return Nothing
parse = return . (read :: String -> Int) . B.unpack
exists <- io $ fileExist file
if exists
- then do mdegrees <- io $ catch ( B.readFile file) handleIOError >>= parse
- temp <- showWithColors show (mdegrees `quot` 1000)
- parseTemplate [ temp ]
+ then do contents <- io $ catch (fmap Just $ B.readFile file) handleIOError
+ case contents of
+ Just d -> do
+ mdegrees <- parse d
+ temp <- showWithColors show (mdegrees `quot` 1000)
+ parseTemplate [ temp ]
+ Nothing -> getConfigValue naString
else getConfigValue naString