From: Nick Bowler Date: Thu, 29 Jul 2021 00:47:34 +0000 (-0400) Subject: mpdmenu: Use embedded cover art. X-Git-Url: https://git.draconx.ca/gitweb/mpdhacks.git/commitdiff_plain/66698921f766b569c784a58d12ca912b32fd94ed mpdmenu: Use embedded cover art. If the server supports embedded cover art, all we need to do now is pass --embedded to the thumbnailer and everything will Just Work™ --- 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;