You are not logged in.
Pages: 1
I use dzen bar to keep track of some stuff, like battery and what mpd is playing. I would like to know how much time is left to a song end, the thing is, how can I get this information easilly from mpd?
Last edited by hack.augusto (2008-12-10 16:28:24)
Offline
I believe there is a way to get the total time and the current position from MPD. If this is so, I imagine you could write a script to subtract the current position from the total time. I tried it out in Ruby, but failed. If you want to try to build off of my source, go ahead:
total = `mpc|grep playing|cut -c25-25`
curre = `mpc|grep playing|cut -c20-20`
f = total.to_i - curre.to_i
tot = `mpc|grep playing|cut -c27-27`
cur = `mpc|grep playing|cut -c22-22`
s = tot.to_i - cur.to_i
tota = `mpc|grep playing|cut -c28-28`
curr = `mpc|grep playing|cut -c23-23`
t = tota.to_i - curr.to_i
puts "#{f}:#{s}#{t}"
[ lamy + pilot ] [ arch64 | wmii ] [ ati + amd ]
Offline
echo -e 'status\nclose' | nc localhost 6600 | awk -F: '/time/{print $3-$2}'
Offline
echo -e 'status\nclose' | nc localhost 6600 | awk -F: '/time/{print $3-$2}'
great! it redeuced 9 lines of code, thanks
Offline
Pages: 1