Bug#426439: pbbuttonsd: Coexist with Gnome's power and volume daemons

2007-07-09 Thread Martin Pitt
Hello Matthias,

Matthias Grimm [2007-07-07 19:01 +0200]:
 The phenomenon you reported is not a bug of pbbuttonsd. It is a
 design error of gnome power manager.

Well, not exactly. It's just two commonly installed programs which do
the same task.

 Please file a bug there to change gnome-power-manager to a clean
 client-server architecture.

It is already. g-p-m is only the frontend that controls policy, the
actual actions are done through hal.

 In this case gpm could use pbbuttonsd's functionality as a 
 power manager front-end instead of competing with it. I would
 accept patches in that direction.

Hm, that would be a bit weird, since hal works on all platforms,
whereas pbbuttonsd only works on powerpc. Hal is becoming (or already
is) the de-facto standard for hardware abstraction and control, so I
guess pbbuttonsd should rather use hal's backends in the future.

 Your patch disables some of pbbuttons core functions.

How so? It only avoids doing duplicate actions, but if g-p-m is not
running, its behaviour does not change.

Thanks for the discussion, and have a nice Sunday!

Martin

-- 
Martin Pitt http://www.piware.de
Ubuntu Developer   http://www.ubuntu.com
Debian Developer   http://www.debian.org


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#426439: pbbuttonsd: Coexist with Gnome's power and volume daemons

2007-07-07 Thread Matthias Grimm

Hi Martin,

I'm sorry but I had to reject your patch.

The phenomenon you reported is not a bug of pbbuttonsd. It is a
design error of gnome power manager. Please file a bug there to
change gnome-power-manager to a clean client-server architecture.
In this case gpm could use pbbuttonsd's functionality as a 
power manager front-end instead of competing with it. I would
accept patches in that direction.

Your patch disables some of pbbuttons core functions. Due to your
changes most of the other power management functions may fail too
because essential information from the system is blocked. I can't
recommend using your patch but pbbuttons is GPL, so please feel
free to patch pbbuttonsd on your own risk.

 Best Regards
   Matthias


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#426439: pbbuttonsd: Coexist with Gnome's power and volume daemons

2007-05-28 Thread Martin Pitt
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 Developerhttp://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))


signature.asc
Description: Digital signature