packages feed

xmonad-spotify (empty) → 0.1.0.0

raw patch · 6 files changed

+135/−0 lines, 6 filesdep +X11dep +basedep +containers

Dependencies added: X11, base, containers, dbus, transformers, xmonad, xmonad-contrib

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# xmonad-spotify++## 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-spotify++This library provides some functionality related to Spotify via `dbus`.
+ cabal.project.local view
@@ -0,0 +1,6 @@+constraints: xmonad-spotify +development+tests: True+benchmarks: True+documentation: True+haddock-hoogle: True+haddock-internal: True
+ src/XMonad/Util/Spotify.hs view
@@ -0,0 +1,55 @@+{-# LANGUAGE TupleSections #-}++-- | Bind media keys for Spotify using @dbus@.+module XMonad.Util.Spotify ( -- * default keybindings+                             mediaKeys+                           -- * media control in the 'X' monad+                           , audioPrev+                           , audioNext+                           , audioPlayPause+                           ) where++import           Control.Arrow                (first)+import           Control.Monad.IO.Class+import qualified Data.Map                     as M+import           DBus+import           DBus.Client+import           Graphics.X11.ExtraTypes.XF86+import           Graphics.X11.Types+import           XMonad.Core++-- | Given your keymaps, add the media keybindings. Currently they are set up+-- for Spotify.+mediaKeys :: M.Map (KeyMask, KeySym) (X ()) -> M.Map (KeyMask, KeySym) (X ())+mediaKeys = M.union mediaKeyMap+    where mediaKeyMap = M.fromList mediaKeyList++mediaKeyList :: [((KeyMask, KeySym), X ())]+mediaKeyList = go <$> [ (xF86XK_AudioNext, audioNext)+                      , (xF86XK_AudioPrev, audioPrev)+                      , (xF86XK_AudioPlay, audioPlayPause)+                      ]+    where go = first (0 ,)++spIO :: String -> IO ()+spIO str =  do+    client <- connectSession+    _ <- call_ client (methodCall (objectPath_ "/org/mpris/MediaPlayer2") (interfaceName_ "org.mpris.MediaPlayer2.Player") (memberName_ str))+        { methodCallDestination = Just (busName_ "org.mpris.MediaPlayer2.spotify") }+    disconnect client++-- | Helper function for use with dbus+sp :: String -> X ()+sp = liftIO . spIO++-- | Action in the 'X' monad to go to next+audioNext :: X ()+audioNext = sp "Next"++-- | Action in the 'X' monad to go the previous+audioPrev :: X ()+audioPrev = sp "Previous"++-- | Action in the 'X' monad to play/pause+audioPlayPause :: X ()+audioPlayPause = sp "PlayPause"
+ xmonad-spotify.cabal view
@@ -0,0 +1,55 @@+cabal-version: 1.18+name: xmonad-spotify+version: 0.1.0.0+license: BSD3+license-file: LICENSE+copyright: Copyright: (c) 2018 Vanessa McHale+maintainer: vanessa.mchale@iohk.io+author: Vanessa McHale+synopsis: Bind media keys to work with Spotify+description:+    Bind media keys to work with Spotify using dbus.+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/vmchale/xmonad-spotify++flag development+    description:+        Enable `-Werror`+    default: False+    manual: True++library+    exposed-modules:+        XMonad.Util.Spotify+    hs-source-dirs: src+    default-language: Haskell2010+    ghc-options: -Wall+    build-depends:+        base >=4.8 && <5,+        xmonad -any,+        xmonad-contrib -any,+        dbus -any,+        containers -any,+        X11 -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