Rmpc Notify

What is it? For people like me using the MPD Music Server, I present a simple notification daemon written in Ruby using the ruby-libnotify and librmpd libraries.

Better than words, let the screenshots explain!

Screen Shots

The current song notification, displayed on song changes:

current song

The notification if MPD becomes stopped:

stopped

The notification if MPD becomes paused:

paused

Usage

First make sure you have the necessary dependencies installed. Besides MPD, you need ruby-libnotify and librmpd.

Once you have those installed, download Rmpc Notify and that's it! Everything you need is contained in the file rmpc-notify.rb. There are two ways to run Rmpc Notify, the first is to just let it run in the foreground, and the second is to fork it as a daemon.

Forking it as a daemon is preferred; you get your controlling terminal back and you have a few extra features. First let's see what we can do:

andy$ ./rmpc-notify.rb --help
rmpc-notify.rb usage:
    -h host - MPD hostname (default: localhost)
    -p port - MPD port (default: 6600)
    -d      - enable daemon mode (default: off)
    -s      - Tells the currently running daemon to
              display the current song
    -k      - stop an already running copy
    --help  - print this help

So we have some options! First, we can specify the host and port of the MPD server to connect to. If left off, these default to localhost and 6600 respectively. For example, if your MPD server is running on mpdserver at port 7700:

andy$ ./rmpc-notify.rb -h mpdserver -p 7700

Next comes the optional daemon mode. Without the -d flag, the process will stay in the foreground and will terminate when you close the terminal. You probably don't want that. Specifying the -d flag will cause a file named .rmpcnotify.pid to be created in your home directory. This contains the process ID so that the daemon can later be shutdown

andy$ ./rmpc-notify.rb -d

Now we can use the other options. -s will cause an already running daemon to display the currently playing song:

andy$ ./rmpc-notify.rb -s

Finally, -k will kill a currently running daemon:

andy$ ./rmpc-notify.rb -k
Stopped rmpc-notify (pid 16345)