From 66698921f766b569c784a58d12ca912b32fd94ed Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 28 Jul 2021 20:47:34 -0400 Subject: [PATCH] mpdmenu: Use embedded cover art. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the server supports embedded cover art, all we need to do now is pass --embedded to the thumbnailer and everything will Just Work™ --- mpdmenu.pl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mpdmenu.pl b/mpdmenu.pl index 15a49b2..e536470 100755 --- a/mpdmenu.pl +++ b/mpdmenu.pl @@ -35,7 +35,7 @@ use constant { my $SELF = "$FindBin::Bin/$FindBin::Script"; my $MUSIC = $ENV{MUSIC} // "/srv/music"; -my $sock; +my ($sock, $mpd_have_binarylimit); my ($albumid, $albumname, $trackid, $recordingid); my ($topmenu, $menu); @@ -134,6 +134,13 @@ sub get_item_thumbnails { $c = "%"; } + if ($mpd_have_binarylimit) { + # --embedded implies and requires binarylimit support + push @opts, "--embedded"; + } else { + push @opts, "--no-binarylimit"; + } + open THUMB, "-|", "$FindBin::Bin/mpdthumb.sh", @opts, "--", @_; foreach (@_) { my $thumb = ; @@ -613,6 +620,12 @@ $sock = MPD::connect(); die("MPD version $MPD::major.$MPD::minor.$MPD::revision insufficient.") unless MPD::min_version(MPD_MJR_MIN, MPD_MNR_MIN, MPD_REV_MIN); +MPD::exec("binarylimit", 64); +while (<$sock>) { + $mpd_have_binarylimit = 1 if /^OK/; + last if /^OK/ or /^ACK/; +} + if ($mode eq "top") { my %current; my %state; -- 2.43.2