- end
-
- f:close()
-
- notification_preset = {
- title = "Now playing",
- text = mpd_now.artist .. " (" ..
- mpd_now.album .. ") - " ..
- mpd_now.date .. "\n" ..
- mpd_now.title,
- fg = beautiful.fg_normal or "#FFFFFF",
- bg = beautiful.bg_normal or "#000000",
- timeout = 6
- }
-
- settings()
-
- if mpd_now.state == "play"
- then
- if mpd_now.title ~= helpers.get_map("current mpd track")
- then
- helpers.set_map("current mpd track", mpd_now.title)
-
- os.execute(mpdcover .. " '" .. music_dir .. "' '"
- .. mpd_now.file .. "'")
-
- mpd.id = naughty.notify({
- preset = notification_preset,
- icon = "/tmp/mpdcover.png",
- replaces_id = mpd.id
- }).id
+
+ mpd_notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist,
+ mpd_now.album, mpd_now.date, mpd_now.title)
+ widget = mpd.widget
+ settings()
+
+ if mpd_now.state == "play" then
+ if notify == "on" and mpd_now.title ~= helpers.get_map("current mpd track") then
+ helpers.set_map("current mpd track", mpd_now.title)
+
+ if followtag then mpd_notification_preset.screen = focused() end
+
+ local common = {
+ preset = mpd_notification_preset,
+ icon = default_art,
+ icon_size = cover_size,
+ replaces_id = mpd.id
+ }
+
+ if not string.match(mpd_now.file, "http.*://") then -- local file instead of http stream
+ local path = string.format("%s/%s", music_dir, string.match(mpd_now.file, ".*/"))
+ local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", path:gsub("'", "'\\''"), cover_pattern)
+ helpers.async({ shell, "-c", cover }, function(current_icon)
+ common.icon = current_icon:gsub("\n", "")
+ if #common.icon == 0 then common.icon = nil end
+ mpd.id = naughty.notify(common).id
+ end)
+ else
+ mpd.id = naughty.notify(common).id
+ end
+
+ end
+ elseif mpd_now.state ~= "pause" then
+ helpers.set_map("current mpd track", nil)