diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | plugins/gtkui/Makefile.am | 4 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 51 | ||||
-rw-r--r-- | plugins/notification/Makefile.am | 5 | ||||
-rw-r--r-- | plugins/notification/notification.c | 63 |
6 files changed, 70 insertions, 73 deletions
diff --git a/Makefile.am b/Makefile.am index 1276047a..26e75e20 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,7 +9,6 @@ SUBDIRS = gme/Game_Music_Emu-0.5.2\ plugins/nullout\ plugins/vtx\ plugins/adplug\ - plugins/notification\ ${ALSA_DIR}\ ${LFM_DIR}\ ${MPGMAD_DIR}\ @@ -22,6 +21,7 @@ SUBDIRS = gme/Game_Music_Emu-0.5.2\ ${GTKUI_DIR}\ ${FFMPEG_DIR}\ ${OSS_DIR} +# ${NOTIFY_DIR} dumbpath=@top_srcdir@/dumb sidpath=@top_srcdir@/sid/sidplay-libs-2.1.0 diff --git a/configure.ac b/configure.ac index e3d1eafa..8dac0985 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,13 @@ PKG_CHECK_MODULES(DEPS, samplerate) PKG_CHECK_MODULES(GTKUI_DEPS, gtk+-2.0 >= 2.12 gthread-2.0 glib-2.0, HAVE_GTK=1, NO_GTK=1) PKG_CHECK_MODULES(ALSA_DEPS, alsa, HAVE_ALSA=1, NO_ALSA=1) PKG_CHECK_MODULES(FFMPEG_DEPS, libavcodec >= 51.0.0 libavutil libavformat >= 52.0.0, HAVE_FFMPEG=1, NO_FFMPEG=1) + +AC_ARG_ENABLE(libnotify, [ --enable-libnotify Enable support for OSD notifications], [libnotify=yes]) + +if test "x${libnotify}" = "xyes" ; then +PKG_CHECK_MODULES(NOTIFY_DEPS, libnotify >= 0.4.4, HAVE_NOTIFY=1, NO_NOTIFY=1) +fi + AC_CHECK_LIB([pthread], [main]) AC_CHECK_LIB([dl], [main]) AC_CHECK_LIB([iconv], [main], [have_iconv=yes], [have_iconv=no]) @@ -182,6 +189,15 @@ if test ${HAVE_FFMPEG}; then AC_SUBST(FFMPEG_DIR) fi +AM_CONDITIONAL(HAVE_NOTIFY, test $HAVE_NOTIFY) +if test ${HAVE_NOTIFY}; then + AC_DEFINE(HAVE_NOTIFY,1,[Use libnotify]) + NOTIFY_DIR="plugins/notification" + AC_SUBST(NOTIFY_DEPS_CFLAGS) + AC_SUBST(NOTIFY_DEPS_LIBS) + AC_SUBST(NOTIFY_DIR) +fi + dnl *** OSS output (partly stolen from audacious) have_oss=no @@ -262,8 +278,8 @@ PRINT_PLUGIN_INFO([vfs_curl],[http/ftp streaming support],[test $HAVE_CURL]) dnl PRINT_PLUGIN_INFO([faad2],[aac/mp4 player],[test $HAVE_FAAD && test $HAVE_MP4FF]) PRINT_PLUGIN_INFO([cdda],[cd audio player],[test $HAVE_CDIO && test $HAVE_CDDB]) PRINT_PLUGIN_INFO([gtkui],[GTK user interface],[test $HAVE_GTK]) +PRINT_PLUGIN_INFO([libnotify],[Current track notification],[test $HAVE_NOTIFY]) PRINT_PLUGIN_INFO([ffmpeg],[ffmpeg codecs],[test $HAVE_FFMPEG]) -PRINT_PLUGIN_INFO([notification],[Current track notification],[true]) PRINT_PLUGIN_INFO([oss],[oss output plugin],[test "x$have_oss" = "xyes"]) echo diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am index aaf9c56a..146e76db 100644 --- a/plugins/gtkui/Makefile.am +++ b/plugins/gtkui/Makefile.am @@ -13,6 +13,6 @@ gtkui_la_SOURCES = gtkui.c gtkui.h\ gtkui_la_LDFLAGS = -module -gtkui_la_LIBADD = $(LDADD) $(GTKUI_DEPS_LIBS) -AM_CFLAGS = -std=c99 $(GTKUI_DEPS_CFLAGS) +gtkui_la_LIBADD = $(LDADD) $(GTKUI_DEPS_LIBS) $(NOTIFY_DEPS_LIBS) +AM_CFLAGS = -std=c99 $(GTKUI_DEPS_CFLAGS) $(NOTIFY_DEPS_CFLAGS) endif diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index c4aacb95..279d281f 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -18,6 +18,12 @@ */ #include "../../deadbeef.h" #include <gtk/gtk.h> +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif +#if HAVE_NOTIFY +#include <libnotify/notify.h> +#endif #include <string.h> #include <stdlib.h> #include <math.h> @@ -52,6 +58,11 @@ static int sb_context_id = -1; static char sb_text[512]; static float last_songpos = -1; +#if HAVE_NOTIFY +#define NOTIFY_DEFAULT_FORMAT "%a - %t" +static NotifyNotification* notification; +#endif + static gboolean update_songinfo (gpointer ctx) { char sbtext_new[512] = "-"; @@ -250,6 +261,27 @@ gtkui_on_activate (DB_event_t *ev, uintptr_t data) { static int gtkui_on_songchanged (DB_event_trackchange_t *ev, uintptr_t data) { gtkpl_songchanged_wrapper (ev->from, ev->to); +#if HAVE_NOTIFY + if (deadbeef->conf_get_int ("libnotify.enable", 0)) { + DB_playItem_t *track = deadbeef->pl_get_for_idx (ev->to); + if (track) { + char cmd [1024]; + deadbeef->pl_format_title (track, -1, cmd, sizeof (cmd), -1, deadbeef->conf_get_str ("libnotify.format", NOTIFY_DEFAULT_FORMAT)); + if (notify_is_initted ()) { + if (notification) { + notify_notification_close (notification, NULL); + } + else { + notification = notify_notification_new ("DeaDBeeF", cmd, NULL, NULL); + } + if (notification) { + notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT); + notify_notification_show (notification, NULL); + } + } + } + } +#endif return 0; } @@ -365,6 +397,10 @@ gtkui_thread (void *ctx) { gdk_threads_init (); gdk_threads_enter (); gtk_set_locale (); +#if HAVE_NOTIFY + notify_init ("DeaDBeeF"); +#endif + int argc = 1; const char **argv = alloca (sizeof (char *)); argv[0] = "deadbeef"; @@ -439,6 +475,9 @@ gtkui_thread (void *ctx) { gtk_widget_show (mainwin); gtk_main (); +#if HAVE_NOTIFY + notify_uninit (); +#endif gdk_threads_leave (); } @@ -495,6 +534,13 @@ gtkui_load (DB_functions_t *api) { return DB_PLUGIN (&plugin); } +#if HAVE_NOTIFY +static const char settings_dlg[] = + "property \"Enable OSD notifications\" checkbox libnotify.enable 0;\n" + "property \"Notification format\" entry libnotify.format \"" NOTIFY_DEFAULT_FORMAT "\";\n" +; +#endif + // define plugin interface static DB_gui_t plugin = { DB_PLUGIN_SET_API_VERSION @@ -508,5 +554,8 @@ static DB_gui_t plugin = { .plugin.email = "waker@users.sourceforge.net", .plugin.website = "http://deadbeef.sf.net", .plugin.start = gtkui_start, - .plugin.stop = gtkui_stop + .plugin.stop = gtkui_stop, +#if HAVE_NOTIFY + .plugin.configdialog = settings_dlg, +#endif }; diff --git a/plugins/notification/Makefile.am b/plugins/notification/Makefile.am deleted file mode 100644 index 5a9f7f65..00000000 --- a/plugins/notification/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -notificationdir = $(libdir)/$(PACKAGE) -pkglib_LTLIBRARIES = notification.la -notification_la_SOURCES = notification.c -notification_la_LDFLAGS = -module -AM_CFLAGS = -std=c99 diff --git a/plugins/notification/notification.c b/plugins/notification/notification.c deleted file mode 100644 index dc5b669f..00000000 --- a/plugins/notification/notification.c +++ /dev/null @@ -1,63 +0,0 @@ -#include "../../deadbeef.h" - -#include <stdio.h> -#include <stdlib.h> - -static DB_misc_t plugin; -static DB_functions_t *deadbeef; - -#define DEFAULT_COMMAND "notify-send '%t' '%a - %b'" - -static const char settings_dlg[] = - "property Command entry notification.command \"" DEFAULT_COMMAND "\";\n" -; - -static void -show_notification (DB_playItem_t *track) -{ - char cmd [1024]; - deadbeef->pl_format_title (track, -1, cmd, sizeof (cmd), -1, deadbeef->conf_get_str ("notification.command", DEFAULT_COMMAND)); - //system (cmd); -} - -static int -songchanged (DB_event_trackchange_t *ev, uintptr_t data) { - DB_playItem_t *track = deadbeef->pl_get_for_idx (ev->to); - if (track) { - show_notification (track); - } - return 0; -} - -static int -notification_stop (void) { - deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (songchanged), 0); - return 0; -} - -static int -notification_start (void) { - deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (songchanged), 0); - return 0; -} - -DB_plugin_t * -notification_load (DB_functions_t *api) { - deadbeef = api; - return DB_PLUGIN (&plugin); -} - -// define plugin interface -static DB_misc_t plugin = { - DB_PLUGIN_SET_API_VERSION - .plugin.type = DB_PLUGIN_MISC, - .plugin.name = "Current track notification", - .plugin.descr = "Displays notification when current track is changed", - .plugin.author = "Viktor Semykin", - .plugin.email = "thesame.ml@gmail.com", - .plugin.website = "http://deadbeef.sf.net", - .plugin.start = notification_start, - .plugin.stop = notification_stop, - .plugin.configdialog = settings_dlg -}; - |