summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-24 19:06:43 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-24 19:06:43 +0200
commit96e1563c37087d506a4842c1a5f96488ee7aa049 (patch)
tree2bd9d3944c11a76b1979109cb158989238a94ced /Plugins/Monitors
parent899ff351ce1a0a1499672020a94b4e27fcb0b4d9 (diff)
downloadxmobar-96e1563c37087d506a4842c1a5f96488ee7aa049.tar.gz
xmobar-96e1563c37087d506a4842c1a5f96488ee7aa049.tar.bz2
Batt: we check if the file exists instead of catching an exception
darcs-hash:20070724170643-d6583-85533ce12993f9de7582b776e8d8644ac541ab81.gz
Diffstat (limited to 'Plugins/Monitors')
-rw-r--r--Plugins/Monitors/Batt.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/Plugins/Monitors/Batt.hs b/Plugins/Monitors/Batt.hs
index c4e463a..bf490f7 100644
--- a/Plugins/Monitors/Batt.hs
+++ b/Plugins/Monitors/Batt.hs
@@ -16,6 +16,7 @@ module Plugins.Monitors.Batt where
import qualified Data.ByteString.Lazy.Char8 as B
import Plugins.Monitors.Common
+import System.Posix.Files (fileExist)
data Batt = Batt Float
| NA
@@ -33,9 +34,12 @@ fileB2 = ("/proc/acpi/battery/BAT2/info", "/proc/acpi/battery/BAT2/state")
readFileBatt :: (String, String) -> IO (B.ByteString, B.ByteString)
readFileBatt (i,s) =
- do a <- catch (B.readFile i) (const $ return B.empty)
- b <- catch (B.readFile s) (const $ return B.empty)
+ do a <- rf i
+ b <- rf s
return (a,b)
+ where rf file = do
+ f <- fileExist file
+ if f then B.readFile file else return B.empty
parseBATT :: IO Batt
parseBATT =