self._connection:send("status", function(_, s) status = s end)
local song = nil
- self._connection:send("currentsong", function(_, s) song = s end)
- self._connection:send("ping", function()
+ 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
- local info = {}
- 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)
+ 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)
end
if self._notification then return end
self._notification = naughty.notify(
{ title = table.title
- -- , icon = img
+ , icon = table.icon
+ , icon_size = 64
, text = table.text
, timeout = 0
, destroy = function() self._timer:stop(); self._notification = nil end