+function set_mpd_song( key, val) {
+ key = $2
+ shift()
+ shift()
+ val = $0
+ db_mpd_song[key] = val
+ debug("set_mpd_song", "", db_mpd_song)
+}
+
+function set_mpd_playing( \
+ currently_playing, name, title, file, last, parts\
+) {
+ debug("set_mpd_playing", "", db_mpd_song)
+ name = db_mpd_song["Name:"]
+ title = db_mpd_song["Title:"]
+ file = db_mpd_song["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 = ""
+ }
+ db["mpd_playing_prev"] = db["mpd_playing_curr"]
+ db["mpd_playing_curr"] = currently_playing
+
+ alert_check_mpd()
+}
+
+function alert_check_mpd( curr, prev, name, body) {
+ prev = db["mpd_playing_prev"]
+ curr = db["mpd_playing_curr"]
+ if (curr && curr != prev) {
+ name = db_mpd_song["Name:"]
+ if (name) {
+ body = name
+ } else {
+ body = \
+ db_mpd_song["Artist:"] \
+ " - " db_mpd_song["Album:"] \
+ " - " db_mpd_song["Title:"]
+ }
+ alert_trigger_low("alert_check_mpd", "NowPlaying", body)
+ }
+}
+