--- /dev/null
+Licensed under GPLv2, see debian/copyright for more information.
+
--- /dev/null
+Now Playing Notifications:
+--------------------------
+
+See "brainstorm" talk thread here:
+http://talk.maemo.org/showthread.php?p=550825
+
+Thanks to mottis for idea!
+Thanks to qwerty12 for his sample code!
+
+Beware:
+------
+This is currently alpha quality hack!
+
nowplayingd (0.1-1) fremantle; urgency=low
- * Initial release, barely compiles
+ * Initial release, compiles and installs as daemon, thats it
- -- Tuomo Tanskanen <tumi@tumi.fi> Mon, 01 Mar 2010 12:31:48 +0200
+ -- Tuomo Tanskanen <tumi@tumi.fi> Mon, 01 Mar 2010 13:43:51 +0200
Section: user/multimedia
Priority: extra
Maintainer: Tuomo Tanskanen <tumi@tumi.fi>
-Build-Depends: debhelper (>= 7), libhildonnotify-dev, libmafw0-dev, libmafw-shared0-dev, libglib2.0-dev
+Build-Depends: debhelper (>= 5), libhildonnotify-dev, libmafw0-dev, libmafw-shared0-dev, libglib2.0-dev
Standards-Version: 3.8.1
-Homepage: http://nowplayingd.garage.maemo.org/
+XB-Homepage: http://nowplayingd.garage.maemo.org/
Package: nowplayingd
Architecture: any
Shows clickable notifications when currently playing song changes.
When notification is clicked, it opens "Now Playing" view in Media
Player.
- App idea by mottis. Sample mafw code by qwerty12. Thanks guys!
-
+ Note: Requires reboot to complete install or removal!
+ App idea by mottis. Sample code by qwerty12. Thanks guys!
+XB-Maemo-Display-Name: Now Playing Notifications
+++ /dev/null
-# Defaults for nowplayingd initscript
-# sourced by /etc/init.d/nowplayingd
-# installed at /etc/default/nowplayingd by the maintainer scripts
-
-#
-# This is a POSIX shell fragment
-#
-
-# Additional options that are passed to the Daemon.
-DAEMON_OPTS=""
dh_testdir
# Add here commands to compile the package.
- $(MAKE)
+ # $(MAKE)
#docbook-to-man debian/nowplayingd.sgml > nowplayingd.1
-
+ gcc -Wall `pkg-config --cflags --libs hildon-notify glib-2.0 mafw mafw-shared` nowplaying.c -o nowplayingd
+
touch $@
clean:
rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
- $(MAKE) clean
+ # $(MAKE) clean
dh_clean
install: build
dh_testdir
dh_testroot
- dh_prep
dh_installdirs
# Add here commands to install the package into debian/nowplayingd.
- $(MAKE) DESTDIR=$(CURDIR)/debian/nowplayingd install
+ # $(MAKE) DESTDIR=$(CURDIR)/debian/nowplayingd install
+ mkdir -p $(CURDIR)/debian/nowplayingd/usr/bin
+ cp nowplayingd $(CURDIR)/debian/nowplayingd/usr/bin/
+
+ mkdir -p $(CURDIR)/debian/nowplayingd/etc/X11/Xsession.d
+ cp scripts/99nowplayingd $(CURDIR)/debian/nowplayingd/etc/X11/Xsession.d/
# Build architecture-independent files here.
--- /dev/null
+/** Code is released under GPLv2
+ *
+ * See debian/copyright for copyright info
+ */
+
+/** Compile binary only with:
+ * gcc -Wall `pkg-config --cflags --libs hildon-notify glib-2.0 mafw mafw-shared` nowplaying.c -o nowplayingd
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <libintl.h>
+#include <locale.h>
+#include <hildon/hildon-notification.h>
+#include <libmafw/mafw.h>
+#include <libmafw-shared/mafw-shared.h>
+
+#define WANTED_RENDERER "Mafw-Gst-Renderer"
+
+static GMainLoop *loop = NULL;
+static MafwRegistry *registry = NULL;
+
+static void sig_handler( int sig G_GNUC_UNUSED )
+{
+ if ( g_main_loop_is_running( loop ) ) {
+ g_main_loop_quit( loop );
+ }
+}
+
+static gboolean close_notification( gpointer n )
+{
+ notify_notification_close( NOTIFY_NOTIFICATION( n ), NULL );
+
+ return FALSE;
+}
+
+static void metadata_callback(
+ const MafwRenderer *self G_GNUC_UNUSED,
+ const gchar *object_id G_GNUC_UNUSED,
+ GHashTable *metadata,
+ gconstpointer user_data G_GNUC_UNUSED,
+ const GError *error G_GNUC_UNUSED )
+{
+ const gchar *artist = NULL;
+ const gchar *title = NULL;
+ HildonNotification *n = NULL;
+
+ artist = g_value_get_string( mafw_metadata_first( metadata, MAFW_METADATA_KEY_ARTIST ) );
+ title = g_value_get_string( mafw_metadata_first( metadata, MAFW_METADATA_KEY_TITLE ) );
+
+ if ( !artist || *artist == '\0' ) /* || !strcmp (artist, "")) */ {
+ artist = dgettext( "mediaplayer", "mp_li_unknown_artist" );
+ }
+
+ if ( !title || *title == '\0' ) /* || !strcmp (title, "")) */ {
+ title = dgettext( "mediaplayer", "mp_li_unknown_song" );
+ }
+
+ n = hildon_notification_new( artist, title, "tasklaunch_media_player", "media" );
+ hildon_notification_add_dbus_action( n, "default",
+ "tasklaunch_media_player",
+ "com.nokia.mediaplayer",
+ "/com/nokia/osso/mediaplayer",
+ "com.nokia.mediaplayer",
+ "open_mp_now_playing",
+ G_TYPE_NONE, NULL,
+ -1 );
+
+ notify_notification_show( NOTIFY_NOTIFICATION( n ), NULL );
+ g_timeout_add_seconds( 5, close_notification, n );
+}
+
+static void state_changed_cb(
+ MafwRenderer *renderer,
+ const MafwPlayState state,
+ gconstpointer user_data G_GNUC_UNUSED)
+{
+ switch (state) {
+ case Playing:
+ mafw_renderer_get_current_metadata( renderer,
+ (MafwRendererMetadataResultCB) metadata_callback,
+ NULL );
+ break;
+
+ case Stopped:
+ default:
+ break;
+ }
+}
+
+static void renderer_added_cb(
+ const MafwRegistry *registry2 G_GNUC_UNUSED,
+ GObject *renderer,
+ gconstpointer user_data G_GNUC_UNUSED)
+{
+ if ( MAFW_IS_RENDERER( renderer ) ) {
+ const gchar *name = mafw_extension_get_name( MAFW_EXTENSION( renderer ) );
+
+ if ( !strcmp( name, WANTED_RENDERER ) ) {
+ g_signal_connect( renderer, "state-changed", G_CALLBACK (state_changed_cb), NULL );
+ }
+ }
+}
+
+static void mafw_init( void )
+{
+ GList *renderers = NULL;
+
+ g_signal_connect( registry, "renderer-added", G_CALLBACK( renderer_added_cb ), NULL );
+ renderers = mafw_registry_get_renderers( registry );
+ while ( renderers ) {
+ renderer_added_cb( registry, G_OBJECT( renderers->data ), NULL );
+ renderers = g_list_next( renderers );
+ }
+}
+
+int main (void)
+{
+ setlocale( LC_ALL, "" );
+
+ g_type_init();
+ notify_init("nowplayingd");
+
+ loop = g_main_loop_new( NULL, FALSE );
+ g_assert( loop );
+
+ registry = MAFW_REGISTRY( mafw_registry_get_instance() );
+ g_assert( registry );
+
+ signal( SIGINT, sig_handler );
+ signal( SIGQUIT, sig_handler );
+ signal( SIGTERM, sig_handler );
+
+ mafw_shared_init( registry, NULL );
+
+ mafw_init();
+
+ g_main_loop_run( loop );
+
+ g_main_loop_unref( loop );
+
+ mafw_shared_deinit();
+
+ return EXIT_SUCCESS;
+}
+
--- /dev/null
+#! /bin/sh
+
+DAEMON=/usr/bin/nowplayingd
+DSMETOOL=/usr/sbin/dsmetool
+DSMETOOL_PARAMETERS="-t"
+
+$DSMETOOL $DSMETOOL_PARAMETERS $DAEMON
+++ /dev/null
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <libintl.h>
-#include <locale.h>
-#include <hildon/hildon-notification.h>
-#include <libmafw/mafw.h>
-#include <libmafw-shared/mafw-shared.h>
-
-#define WANTED_RENDERER "Mafw-Gst-Renderer"
-
-static GMainLoop *loop = NULL;
-static MafwRegistry *registry = NULL;
-
-static void sig_handler (int sig G_GNUC_UNUSED)
-{
- if (g_main_loop_is_running (loop))
- g_main_loop_quit (loop);
-}
-
-static void metadata_callback (const MafwRenderer *self G_GNUC_UNUSED, const gchar *object_id G_GNUC_UNUSED, GHashTable *metadata, gconstpointer user_data G_GNUC_UNUSED, const GError *error G_GNUC_UNUSED)
-{
- const gchar *artist;
- const gchar *title;
- HildonNotification * n;
-
- artist = g_value_get_string (mafw_metadata_first (metadata, MAFW_METADATA_KEY_ARTIST));
- title = g_value_get_string (mafw_metadata_first (metadata, MAFW_METADATA_KEY_TITLE));
-
- if (!artist || *artist == '\0') /* || !strcmp (artist, "")) */
- artist = dgettext ("mediaplayer", "mp_li_unknown_artist");
-
- if (!title || *title == '\0') /* || !strcmp (title, "")) */
- title = dgettext ("mediaplayer", "mp_li_unknown_song");
-
- n = hildon_notification_new (artist, title, "tasklaunch_media_player", "media");
- hildon_notification_add_dbus_action (n, "default", "tasklaunch_media_player", "com.nokia.mediaplayer", "/com/nokia/osso/mediaplayer", "com.nokia.mediaplayer", "open_mp_now_playing", G_TYPE_NONE, NULL, -1);
- notify_notification_show (NOTIFY_NOTIFICATION (n), NULL);
-}
-
-static void state_changed_cb (MafwRenderer *renderer, const MafwPlayState state, gconstpointer user_data G_GNUC_UNUSED)
-{
- switch (state)
- {
- case Playing:
- mafw_renderer_get_current_metadata (renderer, (MafwRendererMetadataResultCB) metadata_callback, NULL);
- break;
-
- case Stopped:
- default:
- break;
- }
-}
-
-static void renderer_added_cb (const MafwRegistry *registry2 G_GNUC_UNUSED, GObject *renderer, gconstpointer user_data G_GNUC_UNUSED)
-{
- if (MAFW_IS_RENDERER (renderer))
- {
- const gchar *name = mafw_extension_get_name (MAFW_EXTENSION (renderer));
-
- if (!strcmp (name, WANTED_RENDERER))
- {
- g_signal_connect (renderer, "state-changed", G_CALLBACK (state_changed_cb), NULL);
- }
- }
-}
-
-static void mafw_init (void)
-{
- GList *renderers;
-
- g_signal_connect (registry, "renderer-added", G_CALLBACK (renderer_added_cb), NULL);
- renderers = mafw_registry_get_renderers (registry);
- while (renderers)
- {
- renderer_added_cb (registry, G_OBJECT (renderers->data), NULL);
- renderers = g_list_next (renderers);
- }
-}
-
-int main (void)
-{
- setlocale (LC_ALL, "");
-
- g_type_init ();
- notify_init ("mediaplayershit");
-
- loop = g_main_loop_new (NULL, FALSE);
- g_assert (loop);
-
- registry = MAFW_REGISTRY (mafw_registry_get_instance ());
- g_assert (registry);
-
- signal (SIGINT, sig_handler);
- signal (SIGQUIT, sig_handler);
- signal (SIGTERM, sig_handler);
-
- mafw_shared_init (registry, NULL);
-
- mafw_init ();
-
- g_main_loop_run (loop);
-
- g_main_loop_unref (loop);
-
- mafw_shared_deinit ();
-
- return EXIT_SUCCESS;
-}
-