db["volume"] = $0
}
-/^in:MPD_STATE/\
+/^in:MPD_SONG +file:/\
{
fields_shift()
- db["mpd_state"] = $1
- db["mpd_curr_song_time"] = $2
- db["mpd_curr_song_percent"] = $3
+ fields_shift()
+ db["mpd_song_curr_file"] = $0
}
-/^in:MPD_SONG/\
+/^in:MPD_SONG +Title:/\
{
fields_shift()
- db["mpd_curr_song_name"] = $0
+ fields_shift()
+ db["mpd_song_curr_title"] = $0
+}
+/^in:MPD_SONG +Name:/\
+{
+ fields_shift()
+ fields_shift()
+ db["mpd_song_curr_name"] = $0
+}
+
+/^in:MPD_STATE /\
+{
+ fields_shift()
+ db["mpd_status_state"] = $1
+ db["mpd_status_time"] = $2
+ db["mpd_status_percent"] = $3
}
/^in:WEATHER/\
}
function make_status_mpd( state, status) {
- state = db["mpd_state"]
+ state = db["mpd_status_state"]
if (state == "play") {
status = make_status_mpd_state_known("▶")
return sprintf("[%s]", status)
}
-function make_status_mpd_state_known(symbol) {
+function make_status_mpd_state_known(symbol, \
+ currently_playing, name, title, file\
+) {
+ name = db["mpd_song_curr_name"]
+ title = db["mpd_song_curr_title:"]
+ file = db["mpd_song_curr_file"]
+
+ if (name) {
+ currently_playing = name
+ } else if (title) {
+ currently_playing = title
+ } else if (file) {
+ last = split(file, parts, "/")
+ currently_playing = parts[last]
+ } else {
+ currently_playing = ""
+ }
return sprintf(\
"%s %s %s %s",
symbol,
- db["mpd_curr_song_time"],
- db["mpd_curr_song_percent"],
- substr(db["mpd_curr_song_name"], 1, opt_mpd_song_max_chars)\
+ db["mpd_status_time"],
+ db["mpd_status_percent"],
+ substr(currently_playing, 1, opt_mpd_song_max_chars)\
)
}