Kopete NowPlaying MPD

Published at 2010-10-29 • in Other

Once, long ago, Kopete had support for MPD, but as it's seen, not anymore (until when it is not known) quite frustrating but...

Kopete 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 discussion, MPD has no (and will not have any) support for dbus.

In conclusion, in order to share with your friends what you are listening too, a communication interface is required for MPD with Kopete's dbus.
After a long session in the Google search (my friend), I found some articles (see Resources) and I wrote MPD-DBus-Kopete.

Requirements

  1. Ruby 1.9 mostly for encoding issues (Tested on 1.9.2.p0);
  2. Ruby D-Bus ( I use most active fork from GitHub) there is no gem provided on http://rubygems.org but you can:

    or download the tarball from here and follow steps as advised on download page.

Note: Embedded libraries
1. librmpd2 library which handles MPD related stuff, comes from Jeffrey Aylesworth's rMPD, without any modifications;
2. simple-daemon library, is borrowed from Bryan Liles's simple-daemon, slightly modified to suit specific needs;
So all merits are theirs :).

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

Install

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 Ruby Version Manager (RVM).
At this moment, and in near future, there is no gem install, so cd in your prefered location and git clone git://github.com/kfl62/MPD-DBus-Kopete.git, after this you may cd MPD-DBus-Kopete && ln -s mpd2kopete ~/bin/mpd2kopete
You can also Download tar.gz or Download zip, 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 mpd2kopete.

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

I have no solution to start the daemon on login and stop it on logout. Posted a question on stackoverflow, so for actualised info access the link. Even better, notify me if you have one :).

Usage

Good to know: The shebang in mpd2kopete executable looks like #!/usr/bin/env ruby, so if the freshly installed/existing Ruby 1.9.2 is not your default, you need to rvm use 1.9.2, before any attempt to start daemon!

  • for start logging and setting the Kopete's status message => mpd2kopete start :);
  • for stop => mpd2kopete stop;
  • mpd2kopete restart well... as you guess :) will restart the daemon.

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

More info in API docs(check the Links bellow).

can_handle?

true

TODO description of features

false

TODO enumerate what will never do 

maybe

TODO enumerate planned features

Links

  1. API docs - quite easy to maintain thanks to RubyDoc Info.

Helpful resources:

  1. D-Bus tutorial
  2. Ruby D-Bus tutorial
  3. Of course the github