Music Player Daemon (MPD)

From awesome
Jump to: navigation, search

Print mpd information

You will need mpc (and mpd - of course).

Create a textbox with name tb_mpd:

textbox tb_mpd { x=290 width = 610 align = "left" }

Create an awk-file with name ~/awesome-mpd.awk:

#!/bin/awk -f
function print_data()
{
    data =  "0 widget_tell tb_mpd "mpd_msg"\n";
    print data;
}
BEGIN {
  INTERVAL = 1;             # in seconds
}
{ 
  while (!system("sleep " INTERVAL))
  {
    mpd_lines=0
    while ( ("mpc" | getline) > 0){
        mpd_info[mpd_lines]=$0
        if (mpd_lines==1) {mpd_time=$3}
        mpd_lines+=1;
    }
    close("mpc");
    if (mpd_lines==1) {
        mpd_msg="mpd not playing";
    } else {
        mpd_msg=mpd_info[0];
        if (mpd_info[1]~/paused/) { mpd_msg="<"mpd_msg">" }
        mpd_msg=mpd_msg" ("mpd_time")"
    }
    print_data();
  }
}

This awk-script based on calmar-awesome-status, and you can put this (or any other) awk-file.

If you start awesome with startx then put your ~/.xinitrc (before awesome):

awk -f ~/awesome-mpd.awk <<< "" &

See: Making_a_Status_Bar_II

Personal tools