Package: pbbuttonsd
Version: 0.7.9-2
Tags: patch upstream

When using pbbuttonsd and Gnome, the two are fighting each other for
power management (gnome-power-manager) and volume control
(gnome-settings-daemon). This has the effect that the brightnes keys
react strangely and the mute key does not work because both pbbuttonsd
and g-settings-daemon trigger the muting once, thus nulling the
effect.

The attached patch makes pbbuttonsd ignore the events if it sees the
running Gnome daemons. I found that this dynamic approach works best,
since when disabling it completely by default this would cripple
pbbuttonsd too much for desktop environments which do not have
power/volume management.

Thanks for considering,

Martin
-- 
Martin Pitt              http://www.piware.de
Ubuntu Developer   http://www.ubuntulinux.org
Debian Developer        http://www.debian.org
--- pbbuttonsd-0.7.9.orig/src/module_alsamixer.c
+++ pbbuttonsd-0.7.9/src/module_alsamixer.c
@@ -22,6 +22,7 @@
 
 #include <math.h>
 #include <pbb.h>
+#include <sys/wait.h>
 
 #include "gettext_macros.h"
 #include "input_manager.h"
@@ -518,6 +519,24 @@
 			step = 0;
 		} else return;
 
+		/* check whether gnome-settings-daemon is running */
+		pid_t killall_pid = fork();
+		if (killall_pid == 0) {
+			execl ("/usr/bin/killall", "killall", "-q", "-s", "0", "gnome-settings-daemon", NULL);
+			perror("could not execute killall");
+			exit (1);
+		} else if (killall_pid > 0) {
+			int status;
+			if (wait (&status) > 0) {
+				if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+					print_msg (PBB_WARN, _("Ignoring volume control key since gnome-settings-daemon is running\n"));
+					return;
+				}
+			} else
+			    perror("wait on killall");
+		} else
+		    perror ("forking killall");
+
 		if ((step == 0) || (mod & MOD_SHIFT))
 			alsamixer_set_and_send(ALSAMIXER_REL, step); /* mute and fine tuning */
 		else
only in patch2:
unchanged:
--- pbbuttonsd-0.7.9.orig/src/module_powersave.c
+++ pbbuttonsd-0.7.9/src/module_powersave.c
@@ -24,6 +24,7 @@
 #include <utmp.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
+#include <sys/wait.h>
 #include <sys/kd.h>
 #include "pbbinput.h"
 
@@ -370,6 +371,23 @@
 	struct moddata_power *base = &modbase_power;
 	int err, val;
 
+	/* check whether gnome-power-manager is running */
+	int gpm_running = 0;
+	pid_t killall_pid = fork();
+	if (killall_pid == 0) {
+		execl ("/usr/bin/killall", "killall", "-q", "-s", "0", "gnome-power-manager", NULL);
+		perror("could not execute killall");
+		exit (1);
+	} else if (killall_pid > 0) {
+		int status;
+		if (wait (&status) > 0) {
+			if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+			       gpm_running = 1;
+		} else
+		    perror("wait on killall");
+	} else
+	    perror ("forking killall");
+
 	while (taglist->tag != TAG_END) {
 		switch (taglist->tag) {
 		case TAG_REINIT:
@@ -580,7 +598,7 @@
 			else		taglist->data = base->flags.heartbeat_enable;
 			break;
 		case TAG_POWERCHANGED:  /* private tag */
-			if (cfgure) {
+			if (cfgure && !gpm_running) {
 				if (taglist->data)
 					base->activeProfile = &base->onAC;
 				else
@@ -628,7 +646,7 @@
 			/* PMCS-script will be called in power_suspend() so that it's nothing left to do here */
 			break;
 		case TAG_WAKEUPFROMSLEEP:  /* private tag */
-			if (cfgure) {
+			if (cfgure && !gpm_running) {
 				power_awake ();
 				val = base->powersource;
 				power_sync ();  /* syncronise redundant data from module_pmac */
@@ -641,7 +659,7 @@
 			}
 			break;
 		case TAG_COVERSTATUS:  /* private tag */
-			if (cfgure) {
+			if (cfgure && !gpm_running) {
 				base->flags.coveropen = taglist->data & 1;
 				val = base->activeProfile->coveraction;
 				if (val == ACTION_BLANK || ((val == ACTION_TORAM) && !base->flags.sleep_supported))

Attachment: signature.asc
Description: Digital signature

Reply via email to