summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Monitors
diff options
context:
space:
mode:
authorMichal Zielonka <michal.zielonka.8001@gmail.com>2022-04-12 12:04:21 +0200
committerMichal Zielonka <michal.zielonka.8001@gmail.com>2022-04-13 15:01:51 +0200
commitc714967eb3cab550ed1387d43182ee3b498124e3 (patch)
tree5f02be84323a6c33c5391e7b6600208fbe12656c /src/Xmobar/Plugins/Monitors
parentdf719c8aa34160a8fc7dd8b427b0b49d4d70799a (diff)
downloadxmobar-c714967eb3cab550ed1387d43182ee3b498124e3.tar.gz
xmobar-c714967eb3cab550ed1387d43182ee3b498124e3.tar.bz2
make small refactoring of load linux code
Add <$> for parsing content of file.
Diffstat (limited to 'src/Xmobar/Plugins/Monitors')
-rw-r--r--src/Xmobar/Plugins/Monitors/Load/Linux.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Load/Linux.hs b/src/Xmobar/Plugins/Monitors/Load/Linux.hs
index 9ba5a5c..19174c7 100644
--- a/src/Xmobar/Plugins/Monitors/Load/Linux.hs
+++ b/src/Xmobar/Plugins/Monitors/Load/Linux.hs
@@ -22,9 +22,9 @@ import System.Posix.Files (fileExist)
-- | Parses the contents of a loadavg proc file, returning
-- the list of load averages
-parseLoadAvgs :: B.ByteString -> [Float]
+parseLoadAvgs :: B.ByteString -> Result
parseLoadAvgs =
- map (read . B.unpack) . take 3 . B.words . head . B.lines
+ Result . map (read . B.unpack) . take 3 . B.words . head . B.lines
fetchLoads :: IO Result
fetchLoads = do
@@ -32,7 +32,6 @@ fetchLoads = do
exists <- fileExist file
if exists then
- (do contents <- B.readFile file
- return $ Result (parseLoadAvgs contents))
+ parseLoadAvgs <$> B.readFile file
else
- return NA
+ return NA