MPD information with mpdcron

From awesome
Jump to: navigation, search

You'll only need mpdcron and (of course) a running MPD-server.

Place into your ~/.mpdcron/mpdcron.conf (to mpd section):

events = player

Of course you can add more events if you want.

Your ~/.mpdcron/hooks/player:

echo "mpdcron({state=\"$MPD_STATUS_STATE\", \
   artist=\"$MPD_SONG_TAG_ARTIST\", title=\"$MPD_SONG_TAG_TITLE\"})" | awesome-client

Create a textbox widget named mpdtextbox and put into your awesome's rc.lua:

function mpdcron (mpdinf)
   local mpdtext = ""
   if (mpdinf.state=="play") then
       mpdtext = mpdinf.artist .. " - " .. mpdinf.title
   elseif (mpdinf.state=="pause") then
       mpdtext = " [[[ " .. mpdinf.artist .. " - " .. mpdinf.title .. " ]]]"
   else
       mpdtext = " [ leállítva ] "
   end
   mpdtextbox.text = awful.util.escape(mpdtext)
end

Run mpdcron and enjoy!