summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ca8a4cf)
raw | patch | inline | side by side (parent: ca8a4cf)
author | Max Kellermann <max@duempel.org> | |
Tue, 23 Sep 2008 11:15:42 +0000 (13:15 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 23 Sep 2008 11:15:42 +0000 (13:15 +0200) |
The lyrics library loads all plugins from the directory configured
with "--with-lyrics-plugin-dir".
with "--with-lyrics-plugin-dir".
Makefile.am | patch | blob | history | |
configure.ac | patch | blob | history | |
src/lyrics.c | patch | blob | history |
diff --git a/Makefile.am b/Makefile.am
index 456cb532c6abaebb2a37cab3ab798f19e1364d41..419bd097c4f97deb85e665e578db3aa3a9c2c429 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
EXTRA_DIST = \
$(doc_DATA)
+
+#
+# lyrics plugins
+#
+
+lyrics_plugin_dir = @lyrics_plugin_dir@
+lyrics_plugins = hd.py leoslyrics.py lyricswiki.rb
+
+install-exec-local:
+ install -m 0755 -d $(lyrics_plugin_dir)
+ install -m 0755 $(addprefix lyrics/,$(lyrics_plugins)) $(lyrics_plugin_dir)
diff --git a/configure.ac b/configure.ac
index e04cea920f25138581509a95c47cba54b4111f88..3fa9ca6b71b839145d3f566ec0aa5e66833dda49 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_MSG_RESULT([$lyrics_screen])
+AC_ARG_WITH([lyrics-plugin-dir],
+ AC_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
+ [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
+ [lyrics_plugin_dir=$withval],
+ [lyrics_plugin_dir="$prefix/lib/ncmpc/lyrics"])
+AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
+ [Directory to search for lyrics plugins])
+AC_SUBST(lyrics_plugin_dir)
+
dnl Default host
AC_MSG_CHECKING([for default MPD host])
AC_ARG_WITH([default-host],
diff --git a/src/lyrics.c b/src/lyrics.c
index 7a6124b6908be941383a4338dac6934f862822fd..e6cb5d2b3101213b162c82098366994b7e86b773 100644 (file)
--- a/src/lyrics.c
+++ b/src/lyrics.c
#include "lyrics.h"
#include "gcc.h"
+#include "../config.h"
#include <assert.h>
#include <stdlib.h>
void lyrics_init(void)
{
+ GDir *dir;
+
plugins = g_ptr_array_new();
- /* XXX configurable paths */
- lyrics_register_plugin("./lyrics/hd.py");
- lyrics_register_plugin("./lyrics/leoslyrics.py");
- lyrics_register_plugin("./lyrics/lyricswiki.rb");
+ dir = g_dir_open(LYRICS_PLUGIN_DIR, 0, NULL);
+ if (dir != NULL) {
+ const char *name;
+ char path[sizeof(LYRICS_PLUGIN_DIR) + 128];
+
+ memcpy(path, LYRICS_PLUGIN_DIR, sizeof(LYRICS_PLUGIN_DIR) - 1);
+ path[sizeof(LYRICS_PLUGIN_DIR) - 1] = G_DIR_SEPARATOR;
+
+ while ((name = g_dir_read_name(dir)) != NULL) {
+ g_strlcpy(path + sizeof(LYRICS_PLUGIN_DIR), name,
+ sizeof(path) - sizeof(LYRICS_PLUGIN_DIR));
+ lyrics_register_plugin(path);
+ }
+
+ g_dir_close(dir);
+ }
}
void lyrics_deinit(void)