Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Album artwork via Ueberzug #437

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9d0d830
Artwork: Album art proof of concert
evanc577 Jan 3, 2021
745ae13
Artwork: Use POSIX_SPAWN_SETPGROUP rather than setsid
evanc577 Jan 4, 2021
af5f1c9
Artwork: exec ueberzug directly without bash
evanc577 Jan 5, 2021
c8bc015
Artwork: albumart_default_path and albumart_scaler config options
evanc577 Jan 5, 2021
a335f61
Artwork: modular backend, fix artwork after popup
evanc577 Jan 6, 2021
029ab43
Artwork: update config, bindings, and manpage
evanc577 Jan 6, 2021
702b8d9
Artwork: reap forked process if exec() ueberzug fails
evanc577 Jan 6, 2021
6d4216d
Artwork: Use boost::process instead of fork/exec
evanc577 Jan 6, 2021
d2c287f
Artwork: Minor fixes
evanc577 Jan 7, 2021
a0bc7be
Configure: check for boost::process
evanc577 Jan 10, 2021
e31a33e
Artwork: Use boost::json
evanc577 Jan 10, 2021
1bcd124
Artwork: Use boost::property_tree rather than boost::json
evanc577 Jan 21, 2021
8c54843
Artwork: Various style fixes
evanc577 Jan 24, 2021
7429a55
Artwork: Use MPD albumart API
evanc577 Jan 24, 2021
22bc159
Artwork: Add readpicture support for embedded art
evanc577 Jan 25, 2021
d0483a1
Artwork: Use queue of std::functions for worker
evanc577 Jan 28, 2021
d4f51ca
Artwork: Don't send too many requests to MPD
evanc577 Jan 29, 2021
c4caee6
Artwork: re-support local artwork
evanc577 Feb 26, 2021
39c408b
Artwork: Allow configuration of album artwork sources
evanc577 Feb 26, 2021
9a30dde
Artwork: Proof of concept Kitty backend
evanc577 Feb 28, 2021
60584bc
Artwork: Find Magick++ library and headers
evanc577 Feb 28, 2021
3bf04f4
Artwork: Usable kitty backend
evanc577 Mar 7, 2021
dc6d4ab
Artwork: Optimize kitty backend
evanc577 Mar 7, 2021
54aaf00
Artwork: Postproccess all images
evanc577 Mar 7, 2021
b5ac3ba
Artwork: Support artwork alignment
evanc577 Mar 7, 2021
f96595e
Artwork: clean up some code
evanc577 Mar 7, 2021
16c6b60
Artwork: Fix checking wrong buffer after getting artwork from mpd
evanc577 Mar 11, 2021
5d8865e
Artwork: Fix wrong positioning with some images
evanc577 May 4, 2021
ba77987
Visualizer: Remove Kitty backend from docs
evanc577 May 5, 2021
4d76a25
Artwork: Tidy up for merge
evanc577 May 5, 2021
6fa0595
Artwork: Don't allow empty albumart_sources config
evanc577 May 5, 2021
d91fe7e
Artwork: Allow manual font size and image offset
evanc577 May 5, 2021
95ee2a2
Artwork: Fix compilation with artwork disabled
evanc577 May 5, 2021
f2ca15a
Workaround for <IM6 Blob::base64() being non-const
evanc577 Jun 28, 2022
ce41769
Merge remote-tracking branch 'upstream/master' into artwork
evanc577 Jun 28, 2022
fa6b2d9
Merge remote-tracking branch 'upstream/master' into HEAD
evanc577 Feb 7, 2023
fdcf5c2
Artwork: Fix scrolling art off screen when user scrolls
evanc577 Sep 27, 2022
55a13dc
Artwork: Change static functions to methods
evanc577 Feb 7, 2023
d8fba89
Artwork: Fix screen switching data races
evanc577 Feb 7, 2023
1075bcc
Visualizer: fix logspace calculation
evanc577 May 30, 2023
07a199b
Artwork: allow setting custom local files
evanc577 May 30, 2023
bcd0b5f
Artwork: Allow globs in albumart_filenames
evanc577 May 30, 2023
f976e5b
Artwork: Re-order includes to fix compilation on some systems
evanc577 Jun 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Darby Payne <[email protected]>
David Coppa <[email protected]>
Dmitriy Kusterskiy <[email protected]>
Eric Izoita <[email protected]>
Evan Chang <[email protected]>
Frank Blendinger <[email protected]>
greenbagels <[email protected]>
Hamuko <[email protected]>
Expand Down
9 changes: 8 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AC_PROG_LIBTOOL
AC_ARG_ENABLE(outputs, AS_HELP_STRING([--enable-outputs], [Enable outputs screen @<:@default=no@:>@]), [outputs=$enableval], [outputs=no])
AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music visualizer screen @<:@default=no@:>@]), [visualizer=$enableval], [visualizer=no])
AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no])
AC_ARG_ENABLE(artwork, AS_HELP_STRING([--enable-artwork], [Enable artwork screen @<:@default=no@:>@]), [artwork=$enableval], [artwork=no])

AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto])
AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto])
Expand All @@ -27,6 +28,10 @@ if test "$clock" = "yes"; then
AC_DEFINE([ENABLE_CLOCK], [1], [enables clock screen])
fi

if test "$artwork" = "yes"; then
AC_DEFINE([ENABLE_ARTWORK], [1], [enables artwork screen])
fi

# -flto
if test "$lto" != "no"; then
AC_MSG_CHECKING([whether compiler supports -flto])
Expand Down Expand Up @@ -91,7 +96,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[auto f = [](auto n) { return n*n; }; f(
)

# boost
BOOST_REQUIRE([1.60])
BOOST_REQUIRE([1.64])
AC_SUBST(BOOST_CPPFLAGS)
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"

Expand All @@ -105,6 +110,8 @@ BOOST_RANGE
BOOST_TOKENIZER
BOOST_TUPLE
BOOST_VARIANT
BOOST_PROCESS
BOOST_PROPERTY_TREE

BOOST_DATE_TIME
AC_SUBST(BOOST_DATE_TIME_LDFLAGS)
Expand Down
3 changes: 3 additions & 0 deletions doc/bindings
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@
#def_key "8"
# show_visualizer
#
#def_key "9"
# show_artwork
#
#def_key "="
# show_clock
#
Expand Down
24 changes: 24 additions & 0 deletions doc/config
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,30 @@
#
#visualizer_spectrum_hz_max = 20000
#
##### in-terminal artwork #####
##
## ncmpcpp can display artwork in the terminal. The artwork is shown in the
## "artwork" screen, which can be optionally be displayed side-by-side with
## another screen via ncmpcpp's slave screen functionality.
##
## The "mpd_music_dir" config option should be set accordingly. ncmpcpp will
## attempt to find and display an image named "cover.png", "cover.jpg",
## "cover.tiff", or "cover.bmp" in the same directory as the current playing
## song.
##
## Ueberzug must be installed and visible in PATH for artwork to be displayed.
##
#
## Fallback to this image if no album cover art is found in the music library.
#
#albumart_default_path = ""
#
## Passed directly to Ueberzug to configure how artwork fills the screen. One of
## "crop", "distort", "fit_contain", "contain", "forced_cover", "cover". See the
## Ueberzug documentation for full descriptions or updated scalers.
#
#albumart_scaler = "fit_contain"
#
##### system encoding #####
##
## ncmpcpp should detect your charset encoding but if it failed to do so, you
Expand Down
6 changes: 6 additions & 0 deletions doc/ncmpcpp.1
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ For spectrum visualizer, left-most frequency of visualizer, must be less than HZ
.B visualizer_spectrum_hz_max = Hz
For spectrum visualizer, right-most frequency of visualizer, must be greater than HZ MIN.
.TP
.B albumart_default_path = PATH
Fallback to this image if no album cover art is found in the music library.
.TP
.B albumart_scaler = STRING
Passed directly to Ueberzug to configure how artwork fills the screen. One of "crop", "distort", "fit_contain", "contain", "forced_cover", "cover". See the Ueberzug documentation for full descriptions or updated scalers.
.TP
.B system_encoding = ENCODING
If you use encoding other than utf8, set it in order to handle utf8 encoded strings properly.
.TP
Expand Down
25 changes: 25 additions & 0 deletions m4/boost.m4
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,17 @@ BOOST_DEFUN([Hash],
[BOOST_FIND_HEADER([boost/functional/hash.hpp])])


# BOOST_JSON([PREFERRED-RT-OPT])
# -----------------------------------
# Look for Boost.JSON. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([JSON],
[BOOST_FIND_LIB([json], [$1],
[boost/json.hpp],
[boost::json::value v;])
])# BOOST_JSON


# BOOST_LAMBDA()
# --------------
# Look for Boost.Lambda
Expand Down Expand Up @@ -996,6 +1007,20 @@ BOOST_DEFUN([Preprocessor],
[BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])


# BOOST_PROCESS()
# ------------
# Look for Boost.Process
BOOST_DEFUN([Process],
[BOOST_FIND_HEADER([boost/process.hpp])])


# BOOST_PROPERTY_TREE()
# ------------
# Look for Boost.PropertyTree
BOOST_DEFUN([Property_Tree],
[BOOST_FIND_HEADER([boost/property_tree/ptree.hpp])])


# BOOST_RANGE()
# --------------------
# Look for Boost.Range
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ncmpcpp_SOURCES = \
screens/tag_editor.cpp \
screens/tiny_tag_editor.cpp \
screens/visualizer.cpp \
screens/artwork.cpp \
utility/comparators.cpp \
utility/html.cpp \
utility/option_parser.cpp \
Expand Down Expand Up @@ -84,6 +85,7 @@ noinst_HEADERS = \
screens/tag_editor.h \
screens/tiny_tag_editor.h \
screens/visualizer.h \
screens/artwork.h \
utility/comparators.h \
utility/const.h \
utility/conversion.h \
Expand Down
25 changes: 25 additions & 0 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "screens/tag_editor.h"
#include "screens/tiny_tag_editor.h"
#include "screens/visualizer.h"
#include "screens/artwork.h"
#include "title.h"
#include "tags.h"

Expand Down Expand Up @@ -159,6 +160,10 @@ void initializeScreens()
# ifdef ENABLE_VISUALIZER
myVisualizer = new Visualizer;
# endif // ENABLE_VISUALIZER

# ifdef ENABLE_ARTWORK
myArtwork = new Artwork;
# endif // ENABLE_ARTWORK

# ifdef ENABLE_OUTPUTS
myOutputs = new Outputs;
Expand Down Expand Up @@ -194,6 +199,10 @@ void setResizeFlags()
myVisualizer->hasToBeResized = 1;
# endif // ENABLE_VISUALIZER

# ifdef ENABLE_ARTWORK
myArtwork->hasToBeResized = 1;
# endif // ENABLE_ARTWORK

# ifdef ENABLE_OUTPUTS
myOutputs->hasToBeResized = 1;
# endif // ENABLE_OUTPUTS
Expand Down Expand Up @@ -2746,6 +2755,21 @@ void ShowServerInfo::run()
myServerInfo->switchTo();
}

bool ShowArtwork::canBeRun()
{
#ifdef ENABLE_ARTWORK
return myScreen != myArtwork;
#else
return false;
#endif // ENABLE_ARTWORK
}

void ShowArtwork::run() {
#ifdef ENABLE_ARTWORK
myArtwork->switchTo();
#endif // ENABLE_ARTWORK
}

}

namespace {
Expand Down Expand Up @@ -2884,6 +2908,7 @@ void populateActions()
insert_action(new Actions::ShowVisualizer());
insert_action(new Actions::ShowClock());
insert_action(new Actions::ShowServerInfo());
insert_action(new Actions::ShowArtwork());
for (size_t i = 0; i < AvailableActions.size(); ++i)
{
if (AvailableActions[i] == nullptr)
Expand Down
10 changes: 10 additions & 0 deletions src/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ enum class Type
ShowVisualizer,
ShowClock,
ShowServerInfo,
ShowArtwork,
_numberOfActions // needed to dynamically calculate size of action array
};

Expand Down Expand Up @@ -1425,6 +1426,15 @@ struct ShowServerInfo: BaseAction
virtual void run() override;
};

struct ShowArtwork: BaseAction
{
ShowArtwork(): BaseAction(Type::ShowArtwork, "show_artwork") { }

private:
virtual bool canBeRun() override;
virtual void run() override;
};

}

#endif // NCMPCPP_ACTIONS_H
2 changes: 2 additions & 0 deletions src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ void BindingsConfiguration::generateDefaults()
bind(k, Actions::Type::ShowOutputs);
if (notBound(k = stringToKey("8")))
bind(k, Actions::Type::ShowVisualizer);
if (notBound(k = stringToKey("9")))
bind(k, Actions::Type::ShowArtwork);
if (notBound(k = stringToKey("=")))
bind(k, Actions::Type::ShowClock);
if (notBound(k = stringToKey("@")))
Expand Down
15 changes: 14 additions & 1 deletion src/ncmpcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "actions.h"
#include "bindings.h"
#include "screens/artwork.h"
#include "screens/browser.h"
#include "charset.h"
#include "configuration.h"
Expand All @@ -47,6 +48,7 @@
#include "screens/visualizer.h"
#include "title.h"
#include "utility/conversion.h"
#include "screens/screen.h"

namespace ph = std::placeholders;

Expand All @@ -57,7 +59,7 @@ std::streambuf *cerr_buffer;
std::streambuf *clog_buffer;

volatile bool run_resize_screen = false;

void sighandler(int sig)
{
if (sig == SIGWINCH)
Expand Down Expand Up @@ -235,6 +237,17 @@ int main(int argc, char **argv)
Statusbar::printf("Action aborted");
}

# ifdef ENABLE_ARTWORK
evanc577 marked this conversation as resolved.
Show resolved Hide resolved
if (!isVisible(myArtwork) && myArtwork->drawn)
{
myArtwork->removeArtwork();
}
else if (isVisible(myArtwork) && !myArtwork->drawn)
{
myArtwork->updateArtwork();
}
# endif

if (myScreen == myPlaylist)
myPlaylist->enableHighlighting();
}
Expand Down