void-packages/srcpkgs/pbbuttonsd/patches/003-disable-powersave-under...

70 lines
2.3 KiB
Diff

Description: Do not powersave if gnome-power-manager is running
Ignore lid and power change events if gnome-power-manager is running,
since that already handles power management.
Author: Martin Pitt <martin.pitt@ubuntu.com>
=== modified file 'src/module_powersave.c'
Index: pbbuttonsd-0.8.1/src/module_powersave.c
===================================================================
--- pbbuttonsd-0.8.1.orig/src/module_powersave.c
+++ pbbuttonsd-0.8.1/src/module_powersave.c
@@ -28,6 +28,7 @@
#include <utmp.h>
#include <sys/time.h>
#include <sys/ioctl.h>
+#include <sys/wait.h>
#include <sys/kd.h>
#include "pbbinput.h"
@@ -283,6 +284,23 @@ power_handle_tags (int cfgure, struct ta
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:
@@ -555,7 +573,7 @@ power_handle_tags (int cfgure, struct ta
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
@@ -603,7 +621,7 @@ power_handle_tags (int cfgure, struct ta
/* 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 */
@@ -616,7 +634,7 @@ power_handle_tags (int cfgure, struct ta
}
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))