summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2011-08-31 05:55:43 -0700
committerjao <jao@gnu.org>2011-08-31 05:55:43 -0700
commit5183d786ad76719159f5678b878e37b2cb004f4e (patch)
tree0fb9ec48cd3cd3bab30213e18a658f6e7bc4a960
parent991af6b4be4a8062b8b61ce73ea93149d9886ded (diff)
parent23a3b81bfd480e5a1d63bbad91e2b611b99758e1 (diff)
downloadxmobar-5183d786ad76719159f5678b878e37b2cb004f4e.tar.gz
xmobar-5183d786ad76719159f5678b878e37b2cb004f4e.tar.bz2
Merge pull request #26 from skinner33/alsadb
catch alsa exception on decibel acquire
-rw-r--r--README8
-rw-r--r--src/Plugins/Monitors/Volume.hs5
-rw-r--r--xmobar.cabal1
3 files changed, 10 insertions, 4 deletions
diff --git a/README b/README
index caaa882..7acb0c8 100644
--- a/README
+++ b/README
@@ -603,10 +603,12 @@ Monitors have default aliases.
- `--lowd` _number_ Low threshold for dB. Defaults to -30.0.
- Variables that can be used with the `-t`/`--template` argument:
`volume`, `volumebar`, `dB`, `status`
+- Note that `dB` might only return 0 on your system. This is known
+ to happen on systems with a pulseaudio backend.
- Default template: `Vol: <volume>% <status>`
-- Requires the package [alsa-mixer] installed in your system. In addition,
- to activate this plugin you must pass `--flags="with_alsa"` during
- compilation.
+- Requires the package [alsa-core] and [alsa-mixer] installed in your
+ system. In addition, to activate this plugin you must pass
+ `--flags="with_alsa"` during compilation.
`MPD Args RefreshRate`
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
diff --git a/xmobar.cabal b/xmobar.cabal
index ecafe1d..5d77997 100644
--- a/xmobar.cabal
+++ b/xmobar.cabal
@@ -122,6 +122,7 @@ executable xmobar
if flag(with_alsa) || flag(all_extensions)
build-depends: alsa-mixer == 0.1.*
+ build-depends: alsa-core == 0.5.*
other-modules: Plugins.Monitors.Volume
cpp-options: -DALSA