packages feed

xmonad-volume (empty) → 0.1.0.0

raw patch · 6 files changed

+144/−0 lines, 6 filesdep +X11dep +alsa-mixerdep +base

Dependencies added: X11, alsa-mixer, base, composition-prelude, containers, transformers, xmonad

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# xmonad-volume++## 0.1.0.0++Initial release
+ LICENSE view
@@ -0,0 +1,11 @@+Copyright Vanessa McHale (c) 2018++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,3 @@+# xmonad-volume++Facilities to control volume within XMonad.
+ cabal.project.local view
@@ -0,0 +1,6 @@+constraints: xmonad-volume +development+tests: True+benchmarks: True+documentation: True+haddock-hoogle: True+haddock-internal: True
+ src/XMonad/Util/ALSA.hs view
@@ -0,0 +1,62 @@+{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}+{-# LANGUAGE TupleSections #-}++-- | This uses ALSA to control the volume.+module XMonad.Util.ALSA ( toggleMute+                        , raiseVolume+                        , lowerVolume+                        -- * Default keybindings+                        , volumeKeys+                        ) where++import           Control.Arrow                (first)+import           Control.Composition+import           Control.Monad+import qualified Data.Map                     as M+import           Graphics.X11.ExtraTypes.XF86+import           Graphics.X11.Types+import           Sound.ALSA.Mixer+import           XMonad++-- | Mute/unmute within the `X` Monad.+toggleMute :: MonadIO m => m ()+toggleMute = liftIO $+    withMixer "default" $ \mixer -> do+        Just control <- getControlByName mixer "Master"+        let Just playbackSwitch = playback $ switch control+        Just sw <- getChannel FrontLeft playbackSwitch+        setChannel FrontLeft playbackSwitch $ not sw++changeVolume :: MonadIO m+             => Channel+             -> Integer -- ^ Percentage+             -> m ()+changeVolume channel i = liftIO $+    withMixer "default" $ \mixer -> do+        Just control <- getControlByName mixer "Master"+        let Just playbackVolume = playback $ volume control+        (min', max') <- getRange playbackVolume+        Just vol <- getChannel channel $ value playbackVolume+        let i' = i * ((max' - min') `div` 100)+        when ((i' > 0 && vol < max') || (i' < 0 && vol > min')) $+            setChannel channel (value playbackVolume) $ vol + i'++-- | Raise volume+raiseVolume :: Integer -> X ()+raiseVolume = axe [ changeVolume FrontLeft, changeVolume FrontRight ]++-- | Lower volume+lowerVolume :: Integer -> X ()+lowerVolume = axe [ changeVolume FrontLeft, changeVolume FrontRight ] . negate++-- | Given your keymaps, add volume control keybindings.+volumeKeys :: M.Map (KeyMask, KeySym) (X ()) -> M.Map (KeyMask, KeySym) (X ())+volumeKeys = M.union mediaKeyMap+    where mediaKeyMap = M.fromList volumeKeyList++volumeKeyList :: [((KeyMask, KeySym), X ())]+volumeKeyList = go <$> [ (xF86XK_AudioMute, toggleMute)+                       , (xF86XK_AudioLowerVolume, lowerVolume 5)+                       , (xF86XK_AudioRaiseVolume, raiseVolume 5)+                       ]+    where go = first (0 ,)
+ xmonad-volume.cabal view
@@ -0,0 +1,57 @@+cabal-version: 1.18+name: xmonad-volume+version: 0.1.0.0+license: BSD3+license-file: LICENSE+copyright: Copyright: (c) 2018 Vanessa McHale+maintainer: vanessa.mchale@iohk.io+author: Vanessa McHale+homepage: https://github.com/vmchale/xmonad-volume#readme+synopsis: XMonad volume controls+description:+    XMonad volume controls using ALSA+category: XMonad+build-type: Simple+extra-source-files:+    cabal.project.local+extra-doc-files: README.md+                 CHANGELOG.md++source-repository head+    type: darcs+    location: https://hub.darcs.net/vamchale/xmonad-volume++flag development+    description:+        Enable `-Werror`+    default: False+    manual: True++library+    exposed-modules:+        XMonad.Util.ALSA+    hs-source-dirs: src+    default-language: Haskell98+    other-extensions: TupleSections+    ghc-options: -Wall+    build-depends:+        base >=4.3 && <5,+        alsa-mixer -any,+        xmonad -any,+        X11 -any,+        containers -any,+        composition-prelude -any+    +    if flag(development)+        ghc-options: -Werror+    +    if !impl(ghc >=8.0)+        build-depends:+            transformers -any+    +    if impl(ghc >=8.0)+        ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates+                     -Wredundant-constraints -Widentities+    +    if impl(ghc >=8.4)+        ghc-options: -Wmissing-export-lists