http://kfl62.trst.ro/kfl62's blog2010-10-28T21:00:00ZFerenc-Loránt Kisshttp://kfl62.trst.rotag:kfl62.trst.ro,2010-10-29:/en/2010/10/29/kopete_nowplaying_mpd.htmlKopete NowPlaying MPD2010-10-28T21:00:00Z2010-10-30T18:09:19Z<p>Once, long ago, <a href="http://kopete.kde.org/" title="Kopete">Kopete</a> had support for <a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon">MPD</a>, but as it's seen, not anymore <a href="https://bugs.kde.org/show_bug.cgi?id=139563" title="Some bug">(until when it is not known)</a> quite frustrating but...</p>
<p><a href="http://kopete.kde.org/" title="Kopete">Kopete</a> is connected to dbus, so the problem is reduced to sending the information to the right address in dbus, unfortunately, as it is in the <a href="http://www.musicpd.org/forum/index.php?action=printpage;topic=570.0" title="Forum discussion">discussion</a>, <a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon">MPD</a> has no (and will not have any) support for dbus.</p>
<p>In conclusion, in order to share with your friends what you are listening too, a communication interface is required for <a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon">MPD</a> with Kopete's dbus.<br>
After a long session in the Google search (my friend), I found some articles (see Resources) and I wrote MPD-DBus-Kopete.</p>
<p><strong>Requirements</strong></p>
<ol>
<li>Ruby 1.9 mostly for encoding issues (Tested on 1.9.2.p0);</li>
<li><p>Ruby D-Bus ( I use <a href="http://github.com/mvidner/ruby-dbus" title="Martin Vidner">most active fork</a> from GitHub) there is no gem provided on <a href="http://rubygems.org">http://rubygems.org</a> but you can:</p>
<p> <script src="http://gist.github.com/647266.js"></script></p>
<p> or download the <a href="http://github.com/mvidner/ruby-dbus" title="Martin Vidner">tarball from here</a> and follow steps as advised on download page.</p></li>
</ol>
<p><em>Note: Embedded libraries</em><br>
1. <code>librmpd2</code> library which handles <a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon">MPD</a> related stuff, comes from <a href="http://github.com/jeffayle/rMPD/blob/master/librmpd.rb" title="Jeffrey Aylesworth">Jeffrey Aylesworth's rMPD</a>, without any modifications;<br>
2. <code>simple-daemon</code> library, is borrowed from <a href="http://github.com/bryanl/simple-daemon" title="Bryan Liles">Bryan Liles's simple-daemon</a>, slightly modified to suit specific needs;<br>
So all merits are theirs :).</p>
<p><em>Note: 1.8.7 support</em><br>
I made some changes regarding compatibility with Ruby 1.8.7, now you can use it, but <strong>warning</strong> you may have strange behavior caused by lack of encoding support on this version. You just been warned, it is your choice...</p>
<p><strong>Install</strong></p>
<p>First of all, since most of Linux distributions comes with Ruby 1.8.7, you need to install the newer Ruby version. I strongly recommend to do this using <a href="http://rvm.beginrescueend.com/">Ruby Version Manager (RVM)</a>.<br>
At this moment, and in near future, there is no gem install, so <code>cd</code> in your prefered location and <code>git clone git://github.com/kfl62/MPD-DBus-Kopete.git</code>, after this you may <code>cd MPD-DBus-Kopete && ln -s mpd2kopete ~/bin/mpd2kopete</code><br>
You can also <a href="http://github.com/kfl62/MPD-DBus-Kopete/tarball/master">Download tar.gz</a> or <a href="http://github.com/kfl62/MPD-DBus-Kopete/zipball/master">Download zip</a>, if you don't want to bother with version control. In this case you just need to create a symbolic link somewhere in your PATH pointing to <code>mpd2kopete</code>.</p>
<p>By default, the runtime and log files will be placed in <code>~/.mpd2kopete</code>, which for, before first run, you need to <code>mkdir ~/.mpd2kopete</code> (to change defaults edit <code>config.rb</code>).<br>
That is all :)</p>
<p>I have no solution to start the daemon on login and stop it on logout. Posted a question on <a href="http://stackoverflow.com/q/3950585/374578">stackoverflow</a>, so for actualised info access the link. Even better, <strong>notify me if you have one</strong> :).</p>
<p><strong>Usage</strong></p>
<p><span class="nojust"><strong>Good to know:</strong> The shebang in <code>mpd2kopete</code> executable looks like <code>#!/usr/bin/env ruby</code>, so if the freshly installed/existing Ruby 1.9.2 is not your default, you need to <code>rvm use 1.9.2</code>, before any attempt to start daemon!</span></p>
<ul>
<li>for start logging and setting the <a href="http://kopete.kde.org/" title="Kopete">Kopete</a>'s status message => <code>mpd2kopete start</code> :);<br></li>
<li>for stop => <code>mpd2kopete stop</code>;</li>
<li><code>mpd2kopete restart</code> well... as you guess :) will restart the daemon.</li>
</ul>
<p><span class="nojust">There is no <code>force-restart</code> option, so if you forgotten to stop the daemon before logout, you need to manually remove the pid file <code>rm ~/.mpd2kopete/mpd2kopete.pid</code>, before a new start.</span><br>
The daemon's logs and mpd history are placed in two separate file. You may consult them <code>tail [-f] mpd2kopete_daemon.log</code> or <code>tail [-f] mpd_history.log</code>.<br>
As I mentioned before the default options are set in <code>~/install_dir/config.rb</code><br></p>
<p>More info in API docs(check the Links bellow).</p>
<p><strong>can_handle?</strong></p>
<p><strong>true</strong></p>
<pre><code>TODO description of features
</code></pre>
<p><strong>false</strong></p>
<pre><code>TODO enumerate what will never do
</code></pre>
<p><strong>maybe</strong></p>
<pre><code>TODO enumerate planned features
</code></pre>
<p><strong>Links</strong></p>
<ol>
<li><a href="http://rubydoc.info/github/kfl62/MPD-DBus-Kopete/master/frames">API docs</a> - quite easy to maintain thanks to <a href="http://rubydoc.info">RubyDoc Info</a>.</li>
</ol>
<p><strong>Helpful resources:</strong></p>
<ol>
<li><a href="http://dbus.freedesktop.org/doc/dbus-tutorial.html">D-Bus tutorial</a></li>
<li><a href="http://trac.luon.net/data/ruby-dbus/tutorial/index.html">Ruby D-Bus tutorial</a></li>
<li>Of course the <a href="http://github.com/search?type=Everything&language=rb&q=dbus&repo=&langOverride=&x=21&y=16&start_value=1">github</a></li>
</ol>