xmonad-extras 0.10.1.1 → 0.10.1.2
raw patch · 3 files changed
+15/−31 lines, 3 filesdep +bytestringdep ~libmpddep ~splitPVP ok
version bump matches the API change (PVP)
Dependencies added: bytestring
Dependency ranges changed: libmpd, split
API changes (from Hackage documentation)
Files
- XMonad/Prompt/MPD.hs +12/−7
- XMonad/Prompt/MPD/Compat.hs +0/−20
- xmonad-extras.cabal +3/−4
XMonad/Prompt/MPD.hs view
@@ -25,15 +25,14 @@ ,findOrAdd ) where import Control.Monad+import qualified Data.ByteString as B import Data.Char-import Data.Either import qualified Data.Map as M import Data.Maybe import Network.MPD import XMonad import XMonad.Prompt import Data.List as L (nub,isPrefixOf,find)-import qualified XMonad.Prompt.MPD.Compat as Compat -- $usage --@@ -72,7 +71,7 @@ -- | Extracts the given metadata attribute from a Song extractMetadata :: Metadata -> Song -> String extractMetadata meta = fromMaybe "Unknown" . join . fmap listToMaybe .- M.lookup meta . sgTags+ M.lookup meta . M.map (map toString) . sgTags -- | Creates a case-insensitive completion function from a list. mkComplLst :: [String] -> String -> IO [String]@@ -90,24 +89,30 @@ Just input -> return $ filter ((==input) . extractMetadata meta) songs Nothing -> return [] +extractSongs :: [LsResult] -> [Song]+extractSongs = mapMaybe extractSong+ where extractSong (LsSong s) = Just s+ extractSong _ = Nothing+ -- | Lets the user filter out non-matching songs. For example, if given -- [Artist, Album] as third argument, this will prompt the user for an -- artist(with tab-completion), then for an album by that artist and then -- returns the songs from that album. findMatching :: RunMPD -> XPConfig -> [Metadata] -> X [Song] findMatching runMPD xp metas = do- resp <- io . runMPD . listAllInfo $ ""+ resp <- io . runMPD . fmap extractSongs . listAllInfo $ Path B.empty case resp of Left err -> trace ("XMonad.Prompt.MPD: MPD returned an error: " ++ show err) >> return []- Right songs -> foldM (findMatching' xp) (rights songs) metas+ Right songs -> foldM (findMatching' xp) songs metas -- | Determine playlist position of the song and add it, if it isn't present. findOrAdd :: Song -> MPD Int findOrAdd s = playlistInfo Nothing >>= \pl -> case L.find ((== sgFilePath s) . sgFilePath) pl of Just (Song { sgIndex = Just i }) -> return i- _ -> fmap Compat.unwrapId . flip addId Nothing . sgFilePath $ s+ _ -> fmap unwrapId . flip addId Nothing . sgFilePath $ s+ where unwrapId (Id i) = i -- | Add all selected songs to the playlist if they are not in it. addMatching :: RunMPD -> XPConfig -> [Metadata] -> X [Int]@@ -119,4 +124,4 @@ addAndPlay :: RunMPD -> XPConfig -> [Metadata] -> X () addAndPlay runMPD xp ms = do ids <- addMatching runMPD xp ms- whenJust (listToMaybe ids) ((>> return ()) . io . runMPD . playId . Compat.wrapId)+ whenJust (listToMaybe ids) ((>> return ()) . io . runMPD . playId . Id)
− XMonad/Prompt/MPD/Compat.hs
@@ -1,20 +0,0 @@-{-# LANGUAGE CPP #-}--module XMonad.Prompt.MPD.Compat (wrapId, unwrapId) where--#if MIN_VERSION_libmpd(0,7,0)--import Network.MPD (Id(..))-wrapId = Id-unwrapId (Id i) = i--#else--type Id = Int-wrapId = id-unwrapId = id--#endif--wrapId :: Int -> Id-unwrapId :: Id -> Int
xmonad-extras.cabal view
@@ -1,5 +1,5 @@ name: xmonad-extras-version: 0.10.1.1+version: 0.10.1.2 homepage: http://projects.haskell.org/xmonad-extras synopsis: Third party extensions for xmonad with wacky dependencies description: Various modules for xmonad that cannot be added to xmonad-contrib@@ -59,7 +59,7 @@ ghc-options: --disable-optimizations if flag(with_parsec) && flag(with_split)- build-depends: parsec >= 2 && < 4, split >= 0.1 && < 0.2+ build-depends: parsec >= 2 && < 4, split >= 0.1 && < 0.3 exposed-modules: XMonad.Actions.Volume if flag(with_hint)@@ -71,9 +71,8 @@ -- XMonad.Hooks.EvalServer if flag(with_mpd)- build-depends: libmpd >= 0.6 && < 0.8+ build-depends: libmpd >= 0.8 && < 0.9, bytestring >= 0.9 && < 0.11 exposed-modules: XMonad.Prompt.MPD- other-modules: XMonad.Prompt.MPD.Compat if flag(with_regex_posix) build-depends: regex-posix