Enable MPRIS support.
OK kili@
This commit is contained in:
parent
8d8f15fff5
commit
4bace6fd19
@ -1,9 +1,9 @@
|
||||
# $OpenBSD: Makefile,v 1.16 2012/10/11 14:23:50 dcoppa Exp $
|
||||
# $OpenBSD: Makefile,v 1.17 2012/10/22 12:44:32 dcoppa Exp $
|
||||
|
||||
COMMENT = minimalistic text based status bar
|
||||
|
||||
DISTNAME = xmobar-0.15
|
||||
REVISION = 1
|
||||
REVISION = 2
|
||||
CATEGORIES = x11
|
||||
HOMEPAGE = http://projects.haskell.org/xmobar
|
||||
|
||||
@ -16,20 +16,22 @@ PERMIT_DISTFILES_CDROM =Yes
|
||||
PERMIT_DISTFILES_FTP = Yes
|
||||
|
||||
WANTLIB = X11 Xext Xft Xinerama Xrandr c m pthread \
|
||||
util
|
||||
util xml2
|
||||
|
||||
MODULES = lang/ghc converters/libiconv
|
||||
|
||||
MODGHC_BUILD = cabal hackage nort
|
||||
MODGHC_SETUP_CONF_ARGS = --flags="with_xft with_mpd"
|
||||
MODGHC_SETUP_CONF_ARGS = --flags="with_xft with_mpd with_mpris"
|
||||
|
||||
BUILD_DEPENDS = devel/hs-mtl \
|
||||
devel/hs-parsec \
|
||||
devel/hs-stm \
|
||||
x11/hs-X11>=1.3.0 \
|
||||
x11/hs-X11-xft>=0.2 \
|
||||
x11/hs-dbus>=0.10 \
|
||||
audio/hs-libmpd>=0.5
|
||||
|
||||
LIB_DEPENDS = textproc/libxml
|
||||
|
||||
EXAMPLEDIR = ${PREFIX}/share/examples/xmobar
|
||||
|
||||
|
112
x11/xmobar/patches/patch-src_Plugins_Monitors_Mpris_hs
Normal file
112
x11/xmobar/patches/patch-src_Plugins_Monitors_Mpris_hs
Normal file
@ -0,0 +1,112 @@
|
||||
$OpenBSD: patch-src_Plugins_Monitors_Mpris_hs,v 1.1 2012/10/22 12:44:32 dcoppa Exp $
|
||||
|
||||
Fix the MPRIS plugin to work with DBus >= 0.10
|
||||
(upstream git commit 73e70006694a559f816536aae68965b2220fced1)
|
||||
|
||||
--- src/Plugins/Monitors/Mpris.hs.orig Mon Jun 4 02:55:49 2012
|
||||
+++ src/Plugins/Monitors/Mpris.hs Fri Oct 12 11:59:09 2012
|
||||
@@ -21,54 +21,64 @@ module Plugins.Monitors.Mpris ( mprisConfig, runMPRIS1
|
||||
import Plugins.Monitors.Common
|
||||
|
||||
import Text.Printf (printf)
|
||||
-import qualified DBus.Client.Simple as C
|
||||
-import DBus.Types
|
||||
-import DBus.Connection ( ConnectionError )
|
||||
+
|
||||
+import DBus
|
||||
+import qualified DBus.Client as DC
|
||||
+
|
||||
import Data.Maybe ( fromJust )
|
||||
import Data.Int ( Int32, Int64 )
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
-import qualified Data.Text as T
|
||||
|
||||
import Control.Exception (try)
|
||||
|
||||
class MprisVersion a where
|
||||
- getProxy :: a -> C.Client -> String -> IO C.Proxy
|
||||
- getMetadataReply :: a -> C.Client -> String -> IO [Variant]
|
||||
+ getMethodCall :: a -> String -> MethodCall
|
||||
+ getMetadataReply :: a -> DC.Client -> String -> IO [Variant]
|
||||
+ getMetadataReply mv c p = fmap methodReturnBody (DC.call_ c $ getMethodCall mv p)
|
||||
fieldsList :: a -> [String]
|
||||
|
||||
data MprisVersion1 = MprisVersion1
|
||||
instance MprisVersion MprisVersion1 where
|
||||
- getProxy MprisVersion1 c p = do
|
||||
- let playerBusName = T.concat ["org.mpris.", T.pack p]
|
||||
- C.proxy c (C.busName_ playerBusName) "/Player"
|
||||
- getMetadataReply MprisVersion1 c p = do
|
||||
- player <- getProxy MprisVersion1 c p
|
||||
- C.call player "org.freedesktop.MediaPlayer" "GetMetadata" []
|
||||
- fieldsList MprisVersion1 = [ "album", "artist", "arturl", "mtime", "title", "tracknumber" ]
|
||||
+ getMethodCall MprisVersion1 p = (methodCall objectPath interfaceName memberName)
|
||||
+ { methodCallDestination = Just busName
|
||||
+ }
|
||||
+ where
|
||||
+ busName = busName_ $ "org.mpris." ++ p
|
||||
+ objectPath = objectPath_ $ "/Player"
|
||||
+ interfaceName = interfaceName_ $ "org.freedesktop.MediaPlayer"
|
||||
+ memberName = memberName_ $ "GetMetadata"
|
||||
|
||||
+ fieldsList MprisVersion1 = [ "album", "artist", "arturl", "mtime", "title"
|
||||
+ , "tracknumber" ]
|
||||
+
|
||||
data MprisVersion2 = MprisVersion2
|
||||
instance MprisVersion MprisVersion2 where
|
||||
- getProxy MprisVersion2 c p = do
|
||||
- let playerBusName = T.concat ["org.mpris.MediaPlayer2.", T.pack p]
|
||||
- C.proxy c (C.busName_ playerBusName) "/org/mpris/MediaPlayer2"
|
||||
- getMetadataReply MprisVersion2 c p = do
|
||||
- player <- getProxy MprisVersion2 c p
|
||||
- C.call player "org.freedesktop.DBus.Properties"
|
||||
- "Get"
|
||||
- (map (toVariant::String -> Variant)
|
||||
- ["org.mpris.MediaPlayer2.Player", "Metadata"]
|
||||
- )
|
||||
+ getMethodCall MprisVersion2 p = (methodCall objectPath interfaceName memberName)
|
||||
+ { methodCallDestination = Just busName
|
||||
+ , methodCallBody = arguments
|
||||
+ }
|
||||
+ where
|
||||
+ busName = busName_ $ "org.mpris.MediaPlayer2." ++ p
|
||||
+ objectPath = objectPath_ $ "/org/mpris/MediaPlayer2"
|
||||
+ interfaceName = interfaceName_ $ "org.freedesktop.DBus.Properties"
|
||||
+ memberName = memberName_ $ "Get"
|
||||
+ arguments = map (toVariant::String -> Variant)
|
||||
+ ["org.mpris.MediaPlayer2.Player", "Metadata"]
|
||||
+
|
||||
fieldsList MprisVersion2 = [ "xesam:album", "xesam:artist", "mpris:artUrl"
|
||||
- , "mpris:length", "xesam:title", "xesam:trackNumber"
|
||||
+ , "mpris:length", "xesam:title",
|
||||
+ "xesam:trackNumber", "xesam:composer",
|
||||
+ "xesam:genre"
|
||||
]
|
||||
|
||||
mprisConfig :: IO MConfig
|
||||
mprisConfig = mkMConfig "<artist> - <title>"
|
||||
- [ "album", "artist", "arturl", "length" , "title", "tracknumber"
|
||||
+ [ "album", "artist", "arturl", "length"
|
||||
+ , "title", "tracknumber" , "composer", "genre"
|
||||
]
|
||||
|
||||
-dbusClient :: C.Client
|
||||
-dbusClient = unsafePerformIO C.connectSession
|
||||
+dbusClient :: DC.Client
|
||||
+dbusClient = unsafePerformIO DC.connectSession
|
||||
|
||||
runMPRIS :: (MprisVersion a) => a -> String -> [String] -> Monitor String
|
||||
runMPRIS version playerName _ = do
|
||||
@@ -95,10 +105,10 @@ unpackMetadata xs = ((map (\(k, v) -> (fromVar k, from
|
||||
TypeStructure _ -> unpack $ head $ structureItems $ fromVar v
|
||||
_ -> []
|
||||
|
||||
-getMetadata :: (MprisVersion a) => a -> C.Client -> String -> IO [(String, Variant)]
|
||||
+getMetadata :: (MprisVersion a) => a -> DC.Client -> String -> IO [(String, Variant)]
|
||||
getMetadata version client player = do
|
||||
reply <- try (getMetadataReply version client player) ::
|
||||
- IO (Either ConnectionError [Variant])
|
||||
+ IO (Either DC.ClientError [Variant])
|
||||
return $ case reply of
|
||||
Right metadata -> unpackMetadata metadata;
|
||||
Left _ -> []
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-xmobar_cabal,v 1.4 2012/09/26 07:09:20 dcoppa Exp $
|
||||
$OpenBSD: patch-xmobar_cabal,v 1.5 2012/10/22 12:44:32 dcoppa Exp $
|
||||
--- xmobar.cabal.orig Mon Jun 4 02:55:49 2012
|
||||
+++ xmobar.cabal Mon Sep 24 21:53:14 2012
|
||||
+++ xmobar.cabal Fri Oct 12 11:44:41 2012
|
||||
@@ -85,9 +85,10 @@ executable xmobar
|
||||
Plugins.Monitors.Swap, Plugins.Monitors.Thermal,
|
||||
Plugins.Monitors.ThermalZone, Plugins.Monitors.Top,
|
||||
@ -22,3 +22,11 @@ $OpenBSD: patch-xmobar_cabal,v 1.4 2012/09/26 07:09:20 dcoppa Exp $
|
||||
parsec == 3.1.*,
|
||||
stm == 2.3.*
|
||||
|
||||
@@ -162,6 +163,6 @@ executable xmobar
|
||||
cpp-options: -DDATEZONE
|
||||
|
||||
if flag(with_mpris) || flag(all_extensions)
|
||||
- build-depends: dbus-core >= 0.9.2.1, text >= 0.11.1.5 && < 0.12
|
||||
+ build-depends: dbus >= 0.10
|
||||
other-modules: Plugins.Monitors.Mpris
|
||||
cpp-options: -DMPRIS
|
||||
|
Loading…
Reference in New Issue
Block a user