Bug#655394: [PATCH] Let acpi-support not handle power stuff if gnome3 is handling it already
Hey folks, I also encountered this bug: both gnome3 and acpid were handling powerbutton presses. A bit of digging showed that the gnome-power-manager has been deprecated and the relevant parts of it have been integrated into gnome-settings-daemon since 3.1.4. This means the current check for gnome-power-manager is no longer sufficient. The attached patch makes acpi-support check if gnome-settings-daemon is running, but only if the installed version is 3.1.4 or newer. This check might be a bit of a hack right now, but I guess the entire is process X running, then don't handle the key is in a way. I guess the perfect solution would be to connect to gnome-settings-daemon and find out if the power and/or media-keys plugins are really enabled (like what seems to happen for dcop?). It seems something like this could happen through DBus, but gnome-settings-daemon is only active on the session bus and I doubt it's possible to implement this reliably (since you don't know where the dbus session for the user lives?). Having said that, I guess this patch is a sufficient solution? Gr. Matthijs --- policy-funcs.orig 2012-01-11 12:50:53.082612087 +0100 +++ policy-funcs 2012-01-11 12:56:18.278874769 +0100 @@ -16,6 +16,15 @@ getXconsole PMS=/usr/bin/gnome-power-manager /usr/bin/kpowersave /usr/bin/xfce4-power-manager PMS=$PMS /usr/bin/guidance-power-manager /usr/lib/dalston/dalston-power-applet + + # gnome-power-manager is integrated with gnome-settings-daemon (in the + # power and media-keys plugins) since 3.1.4, so if we have that version + # installed, also check for gnome-settings-daemon. + GSD_VERSION=`dpkg-query --showformat='${Version}' --show gnome-settings-daemon 2/dev/null` + if dpkg --compare-versions $GSD_VERSION ge 3.1.4; then + PMS=$PMS /usr/bin/gnome-settings-daemon + fi + pidof -x $PMS /dev/null || { test $XUSER != pidof dcopserver /dev/null signature.asc Description: Digital signature
Bug#655394: [Pkg-acpi-devel] Bug#655394: [PATCH] Let acpi-support not handle power stuff if gnome3 is handling it already
On Wed, Jan 11, 2012 at 01:05:06PM +0100, Matthijs Kooijman wrote: This check might be a bit of a hack right now, but I guess the entire is process X running, then don't handle the key is in a way. I guess the perfect solution would be to connect to gnome-settings-daemon and find out if the power and/or media-keys plugins are really enabled (like what seems to happen for dcop?). It seems something like this could happen through DBus, but gnome-settings-daemon is only active on the session bus and I doubt it's possible to implement this reliably (since you don't know where the dbus session for the user lives?). Did you look into PowerDevilRunning() in the same file? This function gets the module information from KDE. I guess the Gnome version could work similarly. Having said that, I guess this patch is a sufficient solution? Actually the dbus version would be preferable if doable. Michael -- Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org Jabber: michael.meskes at googlemail dot com VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#655394: [Pkg-acpi-devel] Bug#655394: [PATCH] Let acpi-support not handle power stuff if gnome3 is handling it already
Hi Michael, Did you look into PowerDevilRunning() in the same file? This function gets the module information from KDE. I guess the Gnome version could work similarly. Hmm, I was going to look at that function and then got distracted or something. Stupid I overlooked that. Having said that, I guess this patch is a sufficient solution? Actually the dbus version would be preferable if doable. Here's a new patch, that uses dbus. I've generalized the PowerDevil function to prevent duplicate code, but I haven't actually been able to test the code on KDE (but the changes are small enough to not expect any problems). I've also not tested this on an older gnome, but I did try running gnome-settings-daemon without the Power plugin loaded, which works as expected. Gr. Matthijs --- policy-funcs.orig 2012-01-11 16:12:36.139926253 +0100 +++ policy-funcs 2012-01-11 16:15:01.684570189 +0100 @@ -21,19 +21,46 @@ pidof dcopserver /dev/null test -x /usr/bin/dcop /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; } || -PowerDevilRunning +PowerDevilRunning || + GnomeSettingsDaemonPowerRunning } -PowerDevilRunning() { +# Find a DBUS session bus, by looking at the given process' environment and +# then send a message to that bus. If multiple processes match the given name, +# the message is sent to all of the buses (and output is simply concatenated. +DBusSend() { + # The process to get the DBUS session address from + local PROC_NAME=$1 + + # Parameters for dbus-send + local DEST=$2 + local DBUS_PATH=$3 + local METHOD=$4 + test -x /usr/bin/dbus-send || return 1 local DBUS_SESS - for p in $(pidof kded4); do + for p in $(pidof $PROC_NAME); do test -r /proc/$p/environ || continue DBUS_SESS=$(grep -a -z DBUS_SESSION_BUS_ADDRESS= /proc/$p/environ || :) test $DBUS_SESS != || continue - ! su $(ps -o user= $p) -s /bin/sh -c $DBUS_SESS dbus-send --print-reply --dest=org.kde.kded /kded org.kde.kded.loadedModules | grep -q powerdevil || return 0 + su $(ps -o user= $p) -s /bin/sh -c $DBUS_SESS dbus-send --print-reply --dest='$DEST' '$DBUS_PATH' '$METHOD' done - - return 1 +} + +# Ask kde if the powerdevil module is loaded +PowerDevilRunning() { + DBusSend kde4 org.kde.kded /kded org.kde.kded.loadedModules | grep -q powerdevil +} + +# gnome-power-manager was integrated into gnome-settings-daemon from version +# 3.1.4, in a new Power plugin (though the handling of buttons is done in the +# MediaKeys plugin. +# +# gnome-settings-daemon does not export a list of loaded plugins, but +# fortunately the Power plugin does have its own Dbus interface we can check +# for (We can't check the MediaKeys plugin, since that has been around for +# longer). +GnomeSettingsDaemonPowerRunning() { + DBusSend gnome-session org.gnome.SettingsDaemon /org/gnome/SettingsDaemon/Power org.freedesktop.DBus.Introspectable.Introspect | grep -q 'interface name=org.gnome.SettingsDaemon.Power' } signature.asc Description: Digital signature
Bug#655394: [Pkg-acpi-devel] Bug#655394: [PATCH] Let acpi-support not handle power stuff if gnome3 is handling it already
On Wed, Jan 11, 2012 at 01:05:06PM +0100, Matthijs Kooijman wrote: It seems something like this could happen through DBus, but gnome-settings-daemon is only active on the session bus and I doubt it's possible to implement this reliably (since you don't know where the dbus session for the user lives?). Could you please try patching /usr/share/acpi-support/policy-funcs with the attached patch and tell me if it fixes the problem for you? I haven't thoroughly tested that patch yet, though, but it seems to work for me. Michael -- Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org Jabber: michael.meskes at googlemail dot com VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL --- /usr/share/acpi-support/policy-funcs 2011-12-13 15:00:19.0 +0100 +++ policy-funcs 2012-01-11 16:49:10.74956 +0100 @@ -21,7 +21,8 @@ pidof dcopserver /dev/null test -x /usr/bin/dcop /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; } || -PowerDevilRunning +PowerDevilRunning || + GSDWithSuspend } PowerDevilRunning() { @@ -36,4 +37,18 @@ done return 1 +} + +GSDWithSuspend() { + test -x /usr/bin/dbus-send || return 1 + + local DBUS_SESS + for p in $(pidof gnome-settings-daemon); do + test -r /proc/$p/environ || continue + DBUS_SESS=$(grep -a -z DBUS_SESSION_BUS_ADDRESS= /proc/$p/environ || :) + test $DBUS_SESS != || continue + ! su $(ps -o user= $p) -s /bin/sh -c $DBUS_SESS dbus-send --system --print-reply --dest=org.freedesktop.UPower --type=method_call --reply-timeout=6000 /org/freedesktop/UPower org.freedesktop.DBus.Properties.Get string:org.freedesktop.UPower string:CanSuspend | grep -q true || return 0 + done + + return 1 }
Bug#655394: [Pkg-acpi-devel] Bug#655394: [PATCH] Let acpi-support not handle power stuff if gnome3 is handling it already
Hi Michael, seems our messages (and patches) crossed paths. From a quick look, my patch looks more sensible, since it check gnome-settings-daemon, not UPower (AFAICS the latter only executes the suspend, not triggers it?). Anyway, let me know what you think. Gr. Matthijs signature.asc Description: Digital signature
Bug#655394: [Pkg-acpi-devel] Bug#655394: [PATCH] Let acpi-support not handle power stuff if gnome3 is handling it already
Hi all, I've applied the patch from Michael, it works well. Regards, Igor. 2012/1/11 Matthijs Kooijman matth...@stdin.nl Hi Michael, seems our messages (and patches) crossed paths. From a quick look, my patch looks more sensible, since it check gnome-settings-daemon, not UPower (AFAICS the latter only executes the suspend, not triggers it?). Anyway, let me know what you think. Gr. Matthijs -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAk8NtksACgkQz0nQ5oovr7wJDQCfZ丝ᣔ⯬∪ꞑ拾餙� BYwAoI2dHdoCJnzf6s2kHODkK9/SIlTJ =ZLXp -END PGP SIGNATURE-
Bug#655394: [Pkg-acpi-devel] Bug#655394: [PATCH] Let acpi-support not handle power stuff if gnome3 is handling it already
On Wed, Jan 11, 2012 at 05:18:20PM +0100, Matthijs Kooijman wrote: seems our messages (and patches) crossed paths. From a quick look, my patch looks more sensible, since it check gnome-settings-daemon, not UPower (AFAICS the latter only executes the suspend, not triggers it?). Anyway, let me know what you think. Yes, I agree. My patch was just a quick hack to see if it works with dbus. It needed some refinement anyway. So I'm going to try and then use your patch. Thanks. Michael -- Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org Jabber: michael.meskes at googlemail dot com VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org