summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors
diff options
context:
space:
mode:
authorMartin Perner <martin@perner.cc>2011-08-30 16:38:04 +0200
committerMartin Perner <martin@perner.cc>2011-08-30 16:44:23 +0200
commit23a3b81bfd480e5a1d63bbad91e2b611b99758e1 (patch)
tree01c49d1fc6b67e49d92552cbe29638d4632dffd2 /src/Plugins/Monitors
parentd17958115fbb80d5baf58830f33390cd21acedac (diff)
downloadxmobar-23a3b81bfd480e5a1d63bbad91e2b611b99758e1.tar.gz
xmobar-23a3b81bfd480e5a1d63bbad91e2b611b99758e1.tar.bz2
catch alsa exception on decibel acquire
This closes #17. For some reasons the alsa interface does not provide a dB value on all systems. Instead an error is returned. The alsa-mixer library checks for such return values and throws an exception if one is detected. This patch catches the exception and returns 0 as dB value.
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r--src/Plugins/Monitors/Volume.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Plugins/Monitors/Volume.hs b/src/Plugins/Monitors/Volume.hs
index 50a6ed4..3e3a8b9 100644
--- a/src/Plugins/Monitors/Volume.hs
+++ b/src/Plugins/Monitors/Volume.hs
@@ -14,10 +14,12 @@
module Plugins.Monitors.Volume (runVolume, volumeConfig) where
+import Prelude hiding ( catch )
import Control.Monad ( liftM, mplus )
import Data.Maybe
import Plugins.Monitors.Common
import Sound.ALSA.Mixer
+import Sound.ALSA.Exception ( catch )
import System.Console.GetOpt
volumeConfig :: IO MConfig
@@ -115,7 +117,8 @@ runVolume mixerName controlName argv = do
maybeNA = maybe (return "N/A")
(lo, hi) <- io $ getRange volumeControl
val <- io $ getChannel FrontLeft $ value volumeControl
- db <- io $ getChannel FrontLeft $ dB volumeControl
+ db <- io $ catch (getChannel FrontLeft $ dB volumeControl)
+ (\_ -> return $ Just 0)
sw <- io $ getChannel FrontLeft switchControl
p <- maybeNA (formatVol lo hi) val
b <- maybeNA (formatVolBar lo hi) val