summaryrefslogtreecommitdiffstats
path: root/ubuntu/maverick/applications/tdepowersave/debian/acpi-support
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2014-02-08 18:30:44 +0100
committerSlávek Banko <slavek.banko@axis.cz>2014-02-08 18:30:44 +0100
commit06cd84e37ec7a430f109f5fcf2394d185ab7fa92 (patch)
treecf5b17224cfb8052b606e02973f290955113d35d /ubuntu/maverick/applications/tdepowersave/debian/acpi-support
parent2e9958e988761c077d2308b110abc946c4f6722d (diff)
downloadtde-packaging-06cd84e37ec7a430f109f5fcf2394d185ab7fa92.tar.gz
tde-packaging-06cd84e37ec7a430f109f5fcf2394d185ab7fa92.zip
Add divert for acpi-support-base policy-funcs in tdepowersave on Debian and Ubuntu
Diffstat (limited to 'ubuntu/maverick/applications/tdepowersave/debian/acpi-support')
-rw-r--r--ubuntu/maverick/applications/tdepowersave/debian/acpi-support/policy-funcs67
1 files changed, 67 insertions, 0 deletions
diff --git a/ubuntu/maverick/applications/tdepowersave/debian/acpi-support/policy-funcs b/ubuntu/maverick/applications/tdepowersave/debian/acpi-support/policy-funcs
new file mode 100644
index 000000000..8b9f13762
--- /dev/null
+++ b/ubuntu/maverick/applications/tdepowersave/debian/acpi-support/policy-funcs
@@ -0,0 +1,67 @@
+. /usr/share/acpi-support/power-funcs
+
+CheckUPowerPolicy() {
+ pidof upowerd > /dev/null
+}
+
+# The (not very aptly named) function CheckPolicy checks if the current X
+# console user is running a power management daemon that handles suspend/resume
+# requests. This is used in various places to determine if we need to handle
+# something ourselves or if we need to pass the info on to a power management
+# daemon (e.g. through a fake key press).
+
+CheckPolicy() {
+ local PMS
+
+ 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"
+ PMS="$PMS /opt/trinity/bin/tdepowersave"
+ pidof -x $PMS > /dev/null ||
+ { test "$XUSER" != "" &&
+ pidof dcopserver > /dev/null &&
+ test -x /opt/trinity/bin/dcop &&
+ /opt/trinity/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; } ||
+ PowerDevilRunning ||
+ GnomeSettingsDaemonPowerRunning
+}
+
+# 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 "$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='$DEST' '$DBUS_PATH' '$METHOD'"
+ done
+}
+
+# Ask kde if the powerdevil module is loaded
+PowerDevilRunning() {
+ DBusSend kded4 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-settings-daemon org.gnome.SettingsDaemon /org/gnome/SettingsDaemon/Power org.freedesktop.DBus.Introspectable.Introspect | grep -q 'interface name="org.gnome.SettingsDaemon.Power"'
+}