- end
-
- f:close()
-
- 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 mpd_now.title ~= helpers.get_map("current mpd track")
- then
- helpers.set_map("current mpd track", mpd_now.title)
-
- os.execute(string.format("%s %q %q %d %q", mpdcover, music_dir,
- mpd_now.file, cover_size, default_art))
-
- mpd.id = naughty.notify({
- preset = mpd_notification_preset,
- icon = "/tmp/mpdcover.png",
- replaces_id = mpd.id,
- screen = client.focus and client.focus.screen or 1
- }).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, cover_pattern)
+ helpers.async({ shell, "-c", cover }, function(current_icon)
+ common.icon = current_icon:gsub("\n", "")
+ 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)