summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2014-03-09 14:00:13 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2014-03-09 14:00:13 +0100
commit870e95d778703ce5c02aa25a6af74c7e8052e8b3 (patch)
tree29d1d50251e9188a50944476f86a4739beba4207 /src
parent21b3a615d08f6b6019c0e8ab0a3f8f21d0de4204 (diff)
parentb87ed38376361259fb1aa8cef7fd9c34414b98ee (diff)
downloadxmobar-870e95d778703ce5c02aa25a6af74c7e8052e8b3.tar.gz
xmobar-870e95d778703ce5c02aa25a6af74c7e8052e8b3.tar.bz2
Merge remote-tracking branch 'rethab/master'
Diffstat (limited to 'src')
-rw-r--r--src/Plugins/Monitors/Disk.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Plugins/Monitors/Disk.hs b/src/Plugins/Monitors/Disk.hs
index 73bd5b7..cf4fa00 100644
--- a/src/Plugins/Monitors/Disk.hs
+++ b/src/Plugins/Monitors/Disk.hs
@@ -23,7 +23,8 @@ import Control.Exception (SomeException, handle)
import Control.Monad (zipWithM)
import qualified Data.ByteString.Lazy.Char8 as B
import Data.List (isPrefixOf, find)
-import System.Directory (canonicalizePath)
+import Data.Maybe (catMaybes)
+import System.Directory (canonicalizePath, doesFileExist)
diskIOConfig :: IO MConfig
diskIOConfig = mkMConfig "" ["total", "read", "write",
@@ -40,11 +41,15 @@ type DevDataRef = IORef [(DevName, [Float])]
mountedDevices :: [String] -> IO [(DevName, Path)]
mountedDevices req = do
s <- B.readFile "/etc/mtab"
- parse `fmap` mapM canon (devs s)
+ parse `fmap` mapM mbcanon (devs s)
where
+ mbcanon (d, p) = doesFileExist d >>= \e ->
+ if e
+ then Just `fmap` canon (d,p)
+ else return Nothing
canon (d, p) = do {d' <- canonicalizePath d; return (d', p)}
devs = filter isDev . map (firstTwo . B.words) . B.lines
- parse = map undev . filter isReq
+ parse = map undev . filter isReq . catMaybes
firstTwo (a:b:_) = (B.unpack a, B.unpack b)
firstTwo _ = ("", "")
isDev (d, _) = "/dev/" `isPrefixOf` d