dbus monitor track changes rhythmbox

raw

cli.sh

1
2
3
$ dbus-monitor --session "path=/org/mpris/MediaPlayer2,member=PropertiesChanged" --monitor\
 | stdbuf -i0 -oL grep xesam:title\
 | stdbuf -i0 -oL xargs -L 1 sendsongtoslack
raw

phork0.txt

$ dbus-monitor --session "path=/org/mpris/MediaPlayer2,member=PropertiesChanged" --monitor
signal sender=org.freedesktop.DBus -> dest=:1.461 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.461"
signal sender=:1.128 -> dest=(null destination) serial=949 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.mpris.MediaPlayer2.Player"
   array [
      dict entry(
         string "Volume"
         variant             double 0.50769
      )
   ]
   array [
   ]
signal sender=:1.128 -> dest=(null destination) serial=950 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.mpris.MediaPlayer2.Player"
   array [
      dict entry(
         string "Volume"
         variant             double 0.50769
      )
   ]
   array [
   ]
signal sender=:1.128 -> dest=(null destination) serial=951 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.mpris.MediaPlayer2.Player"
   array [
      dict entry(
         string "Volume"
         variant             double 0.50769
      )
   ]
   array [
   ]
signal sender=:1.128 -> dest=(null destination) serial=958 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.mpris.MediaPlayer2.Player"
   array [
      dict entry(
         string "CanSeek"
         variant             boolean false
      )
      dict entry(
         string "Metadata"
         variant             array [
               dict entry(
                  string "mpris:trackid"
                  variant                      string "/org/mpris/MediaPlayer2/Track/993"
               )
               dict entry(
                  string "xesam:url"
                  variant                      string "file:///home/cweiske/Musik/Alben/Britney%20Spears/Oops!..%20I%20did%20it%20again/Britney%20Spears%20-%20Oops!..%20I%20did%20it%20again%20-%20Lucky.ogg"
               )
               dict entry(
                  string "xesam:title"
                  variant                      string "Lucky"
               )
               dict entry(
                  string "xesam:artist"
                  variant                      array [
                        string "Britney Spears"
                     ]
               )
               dict entry(
                  string "xesam:album"
                  variant                      string "Oops!..I Did It Again"
               )
               dict entry(
                  string "xesam:genre"
                  variant                      array [
                        string "Pop"
                     ]
               )
               dict entry(
                  string "xesam:audioBitrate"
                  variant                      int32 196608
               )
               dict entry(
                  string "xesam:contentCreated"
                  variant                      string "2000-01-01T00:00:00Z"
               )
               dict entry(
                  string "xesam:lastUsed"
                  variant                      string "2016-03-10T11:40:55Z"
               )
               dict entry(
                  string "mpris:length"
                  variant                      int64 206000000
               )
               dict entry(
                  string "xesam:trackNumber"
                  variant                      int32 0
               )
               dict entry(
                  string "xesam:useCount"
                  variant                      int32 3
               )
               dict entry(
                  string "xesam:userRating"
                  variant                      double 0
               )
               dict entry(
                  string "mpris:artUrl"
                  variant                      string "file:///home/cweiske/.cache/rhythmbox/album-art/00000029"
               )
            ]
      )
      dict entry(
         string "PlaybackStatus"
         variant             string "Playing"
      )
   ]
   array [
   ]
raw
1
2
3
4
dbus-monitor --session "path=/org/mpris/MediaPlayer2,member=PropertiesChanged" --monitor\
 | stdbuf -i0 -oL grep xesam:title\
 | xargs -L 1 rhythmbox-client --print-playing
 
raw

sendsongtoslack.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env php
<?php
/**
 * https://api.slack.com/incoming-webhooks
 * https://my.slack.com/services/new/incoming-webhook/
 */
$url = 'https://hooks.slack.com/services/foo';
$payload = array(
    'text' => file_get_contents('php://stdin')
);
$context = stream_context_create(
    array(
        'http' => array(
            'method'  => 'POST',
            'header'  => 'Content-Type: application/json',
            'content' => json_encode($payload)
        )
    )
);
$response = file_get_contents($url, false, $context);
echo $response . "\n";
?>
 
raw

sendsongtoslack.sh

1
2
3
#!/bin/sh
rhythmbox-client --print-playing | sendtoslack.php
 
Christian Weiske Christian Weiske
owner

History