<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://kfl62.trst.ro/</id>
  <title>kfl62's blog</title>
  <updated>2010-10-28T21:00:00Z</updated>
  <link rel="alternate" href="http://kfl62.trst.ro/"/>
  <link rel="self" href="http://kfl62.trst.ro/atom_en.xml"/>
  <author>
    <name>Ferenc-Lor&#225;nt Kiss</name>
    <uri>http://kfl62.trst.ro</uri>
  </author>
  <entry>
    <id>tag:kfl62.trst.ro,2010-10-29:/en/2010/10/29/kopete_nowplaying_mpd.html</id>
    <title type="html">Kopete NowPlaying MPD</title>
    <published>2010-10-28T21:00:00Z</published>
    <updated>2010-10-30T18:09:19Z</updated>
    <link rel="alternate" href="http://kfl62.trst.ro/en/2010/10/29/kopete_nowplaying_mpd.html"/>
    <content type="html">&lt;p&gt;Once, long ago, &lt;a href="http://kopete.kde.org/" title="Kopete"&gt;Kopete&lt;/a&gt; had support for &lt;a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon"&gt;MPD&lt;/a&gt;, but as it's seen, not anymore &lt;a href="https://bugs.kde.org/show_bug.cgi?id=139563" title="Some bug"&gt;(until when it is not known)&lt;/a&gt; quite frustrating but...&lt;/p&gt;

&lt;p&gt;&lt;a href="http://kopete.kde.org/" title="Kopete"&gt;Kopete&lt;/a&gt; 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 &lt;a href="http://www.musicpd.org/forum/index.php?action=printpage;topic=570.0" title="Forum discussion"&gt;discussion&lt;/a&gt;, &lt;a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon"&gt;MPD&lt;/a&gt; has no (and will not have any) support for dbus.&lt;/p&gt;

&lt;p&gt;In conclusion, in order to share with your friends what you are listening too, a communication interface is required for &lt;a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon"&gt;MPD&lt;/a&gt; with Kopete's dbus.&lt;br&gt;
After a long session in the Google search (my friend), I found some articles (see Resources) and I wrote MPD-DBus-Kopete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ruby 1.9 mostly for encoding issues (Tested on 1.9.2.p0);&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ruby D-Bus ( I use &lt;a href="http://github.com/mvidner/ruby-dbus" title="Martin Vidner"&gt;most active fork&lt;/a&gt; from GitHub) there is no gem provided on &lt;a href="http://rubygems.org"&gt;http://rubygems.org&lt;/a&gt; but you can:&lt;/p&gt;

&lt;p&gt; &lt;script src="http://gist.github.com/647266.js"&gt;&lt;/script&gt;&lt;/p&gt;

&lt;p&gt; or download the &lt;a href="http://github.com/mvidner/ruby-dbus" title="Martin Vidner"&gt;tarball from here&lt;/a&gt; and follow steps as advised on download page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&lt;em&gt;Note: Embedded libraries&lt;/em&gt;&lt;br&gt;
1. &lt;code&gt;librmpd2&lt;/code&gt; library which handles &lt;a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" title="Music Player Daemon"&gt;MPD&lt;/a&gt; related stuff, comes from &lt;a href="http://github.com/jeffayle/rMPD/blob/master/librmpd.rb" title="Jeffrey Aylesworth"&gt;Jeffrey Aylesworth's rMPD&lt;/a&gt;, without any modifications;&lt;br&gt;
2. &lt;code&gt;simple-daemon&lt;/code&gt; library, is borrowed from &lt;a href="http://github.com/bryanl/simple-daemon" title="Bryan Liles"&gt;Bryan Liles's simple-daemon&lt;/a&gt;, slightly modified to suit specific needs;&lt;br&gt;
So all merits are theirs :).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: 1.8.7 support&lt;/em&gt;&lt;br&gt;
I made some changes regarding compatibility with Ruby 1.8.7, now you can use it, but &lt;strong&gt;warning&lt;/strong&gt; you may have strange behavior caused by lack of encoding support on this version. You just been warned, it is your choice...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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 &lt;a href="http://rvm.beginrescueend.com/"&gt;Ruby Version Manager (RVM)&lt;/a&gt;.&lt;br&gt;
At this moment, and in near future, there is no gem install, so &lt;code&gt;cd&lt;/code&gt; in your prefered location and &lt;code&gt;git clone git://github.com/kfl62/MPD-DBus-Kopete.git&lt;/code&gt;, after this you may &lt;code&gt;cd MPD-DBus-Kopete &amp;amp;&amp;amp; ln -s mpd2kopete ~/bin/mpd2kopete&lt;/code&gt;&lt;br&gt;
You can also &lt;a href="http://github.com/kfl62/MPD-DBus-Kopete/tarball/master"&gt;Download tar.gz&lt;/a&gt; or &lt;a href="http://github.com/kfl62/MPD-DBus-Kopete/zipball/master"&gt;Download zip&lt;/a&gt;, 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 &lt;code&gt;mpd2kopete&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;By default, the runtime and log files will be placed in &lt;code&gt;~/.mpd2kopete&lt;/code&gt;, which for, before first run, you need to &lt;code&gt;mkdir ~/.mpd2kopete&lt;/code&gt; (to change defaults edit &lt;code&gt;config.rb&lt;/code&gt;).&lt;br&gt;
That is all :)&lt;/p&gt;

&lt;p&gt;I have no solution to start the daemon on login and stop it on logout. Posted a question on &lt;a href="http://stackoverflow.com/q/3950585/374578"&gt;stackoverflow&lt;/a&gt;, so for actualised info access the link. Even better, &lt;strong&gt;notify me if you have one&lt;/strong&gt; :).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="nojust"&gt;&lt;strong&gt;Good to know:&lt;/strong&gt; The shebang in &lt;code&gt;mpd2kopete&lt;/code&gt; executable looks like &lt;code&gt;#!/usr/bin/env ruby&lt;/code&gt;, so if the freshly installed/existing Ruby 1.9.2 is not your default, you need to &lt;code&gt;rvm use 1.9.2&lt;/code&gt;, before any attempt to start daemon!&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;for start logging and setting the &lt;a href="http://kopete.kde.org/" title="Kopete"&gt;Kopete&lt;/a&gt;'s status message =&gt; &lt;code&gt;mpd2kopete start&lt;/code&gt; :);&lt;br&gt;&lt;/li&gt;
&lt;li&gt;for stop =&gt; &lt;code&gt;mpd2kopete stop&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mpd2kopete restart&lt;/code&gt; well... as you guess :) will restart the daemon.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&lt;span class="nojust"&gt;There is no &lt;code&gt;force-restart&lt;/code&gt; option, so if you forgotten to stop the daemon before logout, you need to manually remove the pid file &lt;code&gt;rm ~/.mpd2kopete/mpd2kopete.pid&lt;/code&gt;, before a new start.&lt;/span&gt;&lt;br&gt;
The daemon's logs and mpd history are placed in two separate file. You may consult them &lt;code&gt;tail [-f] mpd2kopete_daemon.log&lt;/code&gt; or &lt;code&gt;tail [-f] mpd_history.log&lt;/code&gt;.&lt;br&gt;
As I mentioned before the default options are set in &lt;code&gt;~/install_dir/config.rb&lt;/code&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;More info in API docs(check the Links bellow).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;can_handle?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;true&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;TODO description of features
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;false&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;TODO enumerate what will never do 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;maybe&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;TODO enumerate planned features
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://rubydoc.info/github/kfl62/MPD-DBus-Kopete/master/frames"&gt;API docs&lt;/a&gt; - quite easy to maintain thanks to &lt;a href="http://rubydoc.info"&gt;RubyDoc Info&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&lt;strong&gt;Helpful resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://dbus.freedesktop.org/doc/dbus-tutorial.html"&gt;D-Bus tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://trac.luon.net/data/ruby-dbus/tutorial/index.html"&gt;Ruby D-Bus tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Of course the &lt;a href="http://github.com/search?type=Everything&amp;amp;language=rb&amp;amp;q=dbus&amp;amp;repo=&amp;amp;langOverride=&amp;amp;x=21&amp;amp;y=16&amp;amp;start_value=1"&gt;github&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</content>
  </entry>
</feed>

