Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'soul9-disk'

  • Loading branch information...
commit 8218d04c0c0bec2aa04068541ced5cebb888d9dc 2 parents 2910cf9 + 3090297
@jaor authored
View
1  news.md
@@ -20,6 +20,7 @@ _New features_
Trofimovich).
- Dependencies on the deprecated dbus-core removed in favour of
dbus 0.10 (thanks to Jochen Keil).
+ - MPris2 now includes genre and composer among its fields.
_Bug fixes_
View
17 readme.md
@@ -906,13 +906,22 @@ something like:
- Default template: `<artist> - <title>`
- Example:
- Run Mpris1 "clementine" ["-t",
- "<artist> - [<tracknumber>] <title>"] 10
+ Run Mpris1 "clementine" ["-t", "<artist> - [<tracknumber>] <title>"] 10
### `Mpris2 PlayerName Args RefreshRate`
-- Just like Mpris1.
- Supposed to be used with mediaplayers which support MPRIS v2.
+- Aliases to `mpris1`
+- Requires [dbus] and [text] packages.
+ To activate, pass `--flags="with_mpris"` during compilation.
+- PlayerName: player supporting MPRIS v2 protocol, in lowercase.
+- Args: default monitor arguments.
+- Variables that can be used with the `-t`/`--template` argument:
+ `album`, `artist`, `arturl`, `length`, `title`,
+ `tracknumber`, `composer`, `genre`
+- Default template: `<artist> - <title>`
+- Example:
+
+ Run Mpris2 "clementine" ["-t", "<artist> - [<composer>] <title>"] 10
### `Mail Args Alias`
View
34 src/Plugins/Monitors/Disk.hs
@@ -43,7 +43,7 @@ mountedDevices req = do
parse `fmap` mapM canon (devs s)
where
canon (d, p) = do {d' <- canonicalizePath d; return (d', p)}
- devs = filter isDev . map (firstTwo . B.words) . B.lines
+ devs = filter isDev . map (firstTwo . B.words) . B.lines
parse = map undev . filter isReq
firstTwo (a:b:_) = (B.unpack a, B.unpack b)
firstTwo _ = ("", "")
@@ -51,6 +51,26 @@ mountedDevices req = do
isReq (d, p) = p `elem` req || drop 5 d `elem` req
undev (d, f) = (drop 5 d, f)
+diskDevices :: [String] -> IO [(DevName, Path)]
+diskDevices req = do
+ s <- B.readFile "/proc/diskstats"
+ parse `fmap` mapM canon (devs s)
+ where
+ canon (d, p) = do {d' <- canonicalizePath (d); return (d', p)}
+ devs = map (third . B.words) . B.lines
+ parse = map undev . filter isReq
+ third (_:_:c:_) = ("/dev/" ++ (B.unpack c), B.unpack c)
+ third _ = ("", "")
+ isReq (d, p) = p `elem` req || drop 5 d `elem` req
+ undev (d, f) = (drop 5 d, f)
+
+mountedOrDiskDevices :: [String] -> IO [(DevName, Path)]
+mountedOrDiskDevices req = do
+ mnt <- mountedDevices req
+ case mnt of
+ [] -> diskDevices req
+ other -> return other
+
diskData :: IO [(DevName, [Float])]
diskData = do
s <- B.readFile "/proc/diskstats"
@@ -109,17 +129,17 @@ runDiskIO' (tmp, xs) = do
runDiskIO :: DevDataRef -> [(String, String)] -> [String] -> Monitor String
runDiskIO dref disks _ = do
- mounted <- io $ mountedDevices (map fst disks)
- dat <- io $ mountedData dref (map fst mounted)
- strs <- mapM runDiskIO' $ devTemplates disks mounted dat
+ dev <- io $ mountedOrDiskDevices (map fst disks)
+ dat <- io $ mountedData dref (map fst dev)
+ strs <- mapM runDiskIO' $ devTemplates disks dev dat
return $ unwords strs
startDiskIO :: [(String, String)] ->
[String] -> Int -> (String -> IO ()) -> IO ()
startDiskIO disks args rate cb = do
- mounted <- mountedDevices (map fst disks)
- dref <- newIORef (map (\d -> (fst d, repeat 0)) mounted)
- _ <- mountedData dref (map fst mounted)
+ dev <- mountedOrDiskDevices (map fst disks)
+ dref <- newIORef (map (\d -> (fst d, repeat 0)) dev)
+ _ <- mountedData dref (map fst dev)
runM args diskIOConfig (runDiskIO dref disks) rate cb
fsStats :: String -> IO [Integer]
View
7 src/Plugins/Monitors/Mpris.hs
@@ -66,12 +66,15 @@ instance MprisVersion MprisVersion2 where
["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 :: DC.Client
Please sign in to comment.
Something went wrong with that request. Please try again.