#!/usr/bin/env ruby require 'mpd' m = MPD.new def format(m) if m.strf("%A") > "0" return m.strf("%a - %t (from %A) [%e/%l]") else return m.strf("%a - %t [%e/%l]") end end if (m.status["state"] == "play") or # Do the if statement which formats the song npEcho = "np: #{format(m)}" elsif m.status["state"] == "pause" # Do the if statement which formats the song npEcho = "np: #{format(m)} PAUSED" else # Do not do it here npEcho = "np: nothing" end puts npEcho