summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2015-03-08 20:27:36 +0100
committerjao <jao@gnu.org>2015-03-08 20:27:36 +0100
commit5823b1a2c9a2ef16922b6a74ec1553da19460a0c (patch)
treefd7b6a42f92cf6284479261bad0eaa3c75fa4f12 /src/Plugins
parentee3507aae36a8f007fcc7b933f0b6909b2bbb25a (diff)
downloadxmobar-5823b1a2c9a2ef16922b6a74ec1553da19460a0c.tar.gz
xmobar-5823b1a2c9a2ef16922b6a74ec1553da19460a0c.tar.bz2
Better error control in Volume monitor
Diffstat (limited to 'src/Plugins')
-rw-r--r--src/Plugins/Monitors/Volume.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Plugins/Monitors/Volume.hs b/src/Plugins/Monitors/Volume.hs
index 8c39b9f..9f33b3e 100644
--- a/src/Plugins/Monitors/Volume.hs
+++ b/src/Plugins/Monitors/Volume.hs
@@ -154,18 +154,19 @@ runVolume mixerName controlName argv = do
liftMonitor Nothing = unavailable
liftMonitor (Just m) = m
+ channel v r = AE.catch (getChannel FrontLeft v) (const $ return $ Just r)
+
getDB :: Maybe Volume -> IO (Maybe Integer)
getDB Nothing = return Nothing
- getDB (Just v) = AE.catch (getChannel FrontLeft $ dB v)
- (const $ return $ Just 0)
+ getDB (Just v) = channel (dB v) 0
getVal :: Maybe Volume -> IO (Maybe Integer)
getVal Nothing = return Nothing
- getVal (Just v) = getChannel FrontLeft $ value v
+ getVal (Just v) = channel (value v) 0
getSw :: Maybe Switch -> IO (Maybe Bool)
getSw Nothing = return Nothing
- getSw (Just s) = getChannel FrontLeft s
+ getSw (Just s) = channel s False
getFormatDB :: VolumeOpts -> Maybe Integer -> Monitor String
getFormatDB _ Nothing = unavailable