-function widget:get_info(callback)
- local status = nil
- self._connection:send("status", function(_, s) status = s end)
-
- local song = nil
-
- self._connection:send("currentsong", function(_, s)
- song = s
- self._connection:albumart(song.file, function(_, art)
- local info = {}
- if art and art.binary then
- info.icon = '/tmp/test.jpg'
- local f = io.open(info.icon, 'w')
- f:write(art.binary)
- f:close()
- end
-
- info.title = status.state .. " " .. status.song .. "/" .. status.playlistlength .. " " .. song_duration(status.elapsed, status.duration)
- if not song.artist then
- info.text = string.format("%s", song.title or song.file)
- else
- info.text = string.format("%s - %s", song.artist, song.title)
- end
- if song.album then
- info.text = info.text .. "\n" .. tostring(song.album or "")
- end
- callback(info)
- end)
- end)
+local dbg = require("gears.debug")
+function widget:get_albumart()
+ local art = self._albumart
+ -- dbg.dump(art)
+ -- dbg.dump(self._albumart.binary)
+ if art and art.binary then
+ local path = '/tmp/test.jpg'
+ local f = io.open(path, 'w')
+ f:write(art.binary)
+ f:close()
+ return path
+ else
+ return beautiful.mpd_default_album
+ end
+end
+
+function widget:get_info()
+ local info = {}
+ local status, song = self._status, self._currentsong
+ info.title = status.state .. " " .. status.song .. "/" .. status.playlistlength .. " " .. song_duration(status.elapsed, status.duration)
+ if not song.artist then
+ info.text = string.format("%s", song.title or song.file)
+ else
+ info.text = string.format("%s - %s", song.artist, song.title)
+ end
+ if song.album then
+ info.text = info.text .. "\n" .. tostring(song.album or "")
+ end
+
+ return info