Add support for pausing MPlayer 1.4
authorThomas Perl <thp@thpinfo.com>
Sat, 21 Nov 2009 16:37:44 +0000 (17:37 +0100)
committerThomas Perl <thp@thpinfo.com>
Sat, 21 Nov 2009 16:37:44 +0000 (17:37 +0100)
debian/changelog
debian/headphoned.zheadphoned.init
debian/postrm [new file with mode: 0644]
debian/rules
makefile
src/headphoned.c

index fd68590..a26fb30 100644 (file)
@@ -1,3 +1,9 @@
+headphoned (1.4) diablo; urgency=low
+
+  * Add support for pausing MPlayer
+
+ -- Thomas Perl <thp@thpinfo.com>  Sat, 21 Nov 2009 17:37:08 +0100
+
 headphoned (1.3) diablo; urgency=low
 
   * Add support for pausing Panucci
index 846ce61..08ff60b 100644 (file)
@@ -20,6 +20,18 @@ DESC="Headphone daemon"
 export DBUS_SESSION_BUS_ADDRESS='unix:path=/tmp/session_bus_socket'
 # XXX end
 
+# Add the headphoned FIFO to MPlayer's global configuration
+CONFIG_LINE="input:file=/etc/headphoned/mplayer-input"
+MPLAYER_CONF="/etc/mplayer/mplayer.conf"
+if [ -f "$MPLAYER_CONF" ]; then
+       if ! grep "$CONFIG_LINE" "$MPLAYER_CONF" >/dev/null; then
+               echo -n "Updating $MPLAYER_CONF... "
+               echo $CONFIG_LINE >>$MPLAYER_CONF
+               echo "done."
+       fi
+fi
+# End Add the headphoned FIFO to MPlayer's global configuration
+
 test -x $DAEMON || exit 0
 
 set -e
diff --git a/debian/postrm b/debian/postrm
new file mode 100644 (file)
index 0000000..1b92f0f
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#DEBHELPER#
+
+CONFIG_LINE="input:file=\/etc\/headphoned\/mplayer-input"
+MPLAYER_CONF="/etc/mplayer/mplayer.conf"
+
+# Remove the headphoned "input" config option for MPlayer (if it exists)
+if [ -f "$MPLAYER_CONF" ]; then
+       if grep "$CONFIG_LINE" "$MPLAYER_CONF" >/dev/null; then
+               echo -n "Updating $MPLAYER_CONF... "
+               sed -i -e "/$CONFIG_LINE/d" "$MPLAYER_CONF"
+               echo "done."
+       fi
+fi
+
index 0aa4a44..b495e60 100755 (executable)
@@ -63,7 +63,7 @@ binary-arch: build install
        dh_link
        dh_strip
        dh_compress
-       dh_fixperms
+       dh_fixperms --exclude=/etc/headphoned/mplayer-input
        dh_installdeb
        dh_shlibdeps
        dh_gencontrol
index 2905814..46e3f6b 100644 (file)
--- a/makefile
+++ b/makefile
@@ -12,6 +12,9 @@ $(PROG): $(OBJS)
 
 install: $(PROG)
        install $(PROG) $(DESTDIR)$(PREFIX)/sbin/$(PROG)
+       mkdir -p $(DESTDIR)/etc/$(PROG)
+       mkfifo $(DESTDIR)/etc/$(PROG)/mplayer-input
+       chown user:users $(DESTDIR)/etc/$(PROG)/mplayer-input
 
 clean:
        rm -f $(PROG) $(OBJS)
index 2daaf69..adfdf55 100644 (file)
@@ -18,6 +18,7 @@
 #include <gconf/gconf-client.h>
 #include <libosso.h>
 #include <dbus/dbus.h>
+#include <fcntl.h>
 
 #define STATE_FILE "/sys/devices/platform/gpio-switch/headphone/state"
 #define STATE_CONNECTED_STR "connected"
@@ -33,6 +34,8 @@
 #define PANUCCI_PATH "/panucciInterface"
 #define PANUCCI_INTF "org.panucci.panucciInterface"
 
+#define MPLAYER_FIFO "/etc/headphoned/mplayer-input"
+
 // Volume control is currently broken, as something is messing
 // with the controls from outside this process in GConf..
 //#define ENABLE_VOLUME_CONTROL
@@ -90,6 +93,7 @@ on_file_changed(GIOChannel* source, GIOCondition condition, gpointer data)
        gint volume = headphoned->volume[headphoned->state];
 #endif
        gchar* result;
+       int mplayer_fifo;
 
        g_io_channel_seek_position(source, 0, G_SEEK_SET, NULL);
        g_io_channel_read_line(source, &result, NULL, NULL, NULL);
@@ -122,6 +126,13 @@ on_file_changed(GIOChannel* source, GIOCondition condition, gpointer data)
                                                NULL,
                                                DBUS_TYPE_INVALID);
                        }
+
+                       /* MPlayer */
+                       if ((mplayer_fifo = open(MPLAYER_FIFO,
+                                               O_WRONLY | O_NONBLOCK)) != -1) {
+                               write(mplayer_fifo, "pause\n", 6);
+                               close(mplayer_fifo);
+                       }
                }
 #endif
        }