Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:joshkress:PackageKit
hal
hal-add-standby-support.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hal-add-standby-support.diff of Package hal
Index: doc/spec/hal-spec-properties.xml ================================================================================ --- doc/spec/hal-spec-properties.xml +++ doc/spec/hal-spec-properties.xml @@ -5650,7 +5650,7 @@ <entry></entry> <entry>Yes</entry> <entry> - If suspend support is compiled into the kernel. + If suspend (S3) support is compiled into the kernel. NB. This may not mean the machine is able to suspend successfully. </entry> @@ -5662,13 +5662,25 @@ <entry></entry> <entry>Yes</entry> <entry> - If hibernation support is compiled into the kernel. + If hibernation (S4) support is compiled into the kernel. NB. This may not mean the machine is able to hibernate successfully. </entry> </row> <row> <entry> + <literal>power_management.can_standby</literal> (bool) + </entry> + <entry></entry> + <entry>No</entry> + <entry> + If standby (S1) support is compiled into the kernel. + NB. This may not mean the machine is able to standby + successfully. + </entry> + </row> + <row> + <entry> <literal>power_management.is_powersave_set</literal> (bool) </entry> <entry/> --- fdi/policy/10osvendor/10-power-mgmt-policy.fdi +++ fdi/policy/10osvendor/10-power-mgmt-policy.fdi @@ -36,6 +36,11 @@ <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_argnames" type="strlist"></append> <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-hibernate</append> + <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_names" type="strlist">Standby</append> + <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_signatures" type="strlist"></append> + <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_argnames" type="strlist"></append> + <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-standby</append> + <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_names" type="strlist">Shutdown</append> <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_signatures" type="strlist"></append> <append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_argnames" type="strlist"></append> --- hald/linux/osspec.c +++ hald/linux/osspec.c @@ -434,10 +434,12 @@ } static void -set_suspend_hibernate_keys (HalDevice *d) +set_power_state_keys (HalDevice *d) { - int can_suspend; - int can_hibernate; + gboolean can_suspend; + gboolean can_hibernate; + gboolean can_standby; + ssize_t read; size_t len; char *poweroptions; @@ -445,6 +447,7 @@ can_suspend = FALSE; can_hibernate = FALSE; + can_standby = FALSE; /* try to find 'mem' and 'disk' in /sys/power/state */ fp = fopen ("/sys/power/state", "r"); @@ -464,6 +467,8 @@ can_suspend = TRUE; if (strstr (poweroptions, "disk")) can_hibernate = TRUE; + if (strstr (poweroptions, "standby")) + can_standby = TRUE; free (poweroptions); /* check for the presence of suspend2 */ @@ -476,6 +481,7 @@ out: hal_device_property_set_bool (d, "power_management.can_suspend", can_suspend); hal_device_property_set_bool (d, "power_management.can_hibernate", can_hibernate); + hal_device_property_set_bool (d, "power_management.can_standby", can_standby); /* WARNING: These keys are depreciated and power_management.can_suspend * and power_management.can_hibernate should be used instead. @@ -533,7 +539,7 @@ * or hibernate successfully, only that the machine has * support compiled into the kernel. */ - set_suspend_hibernate_keys (root); + set_power_state_keys (root); /* TODO: add prober for PowerMac's */ if (should_decode_dmi) { --- tools/Makefile.am +++ tools/Makefile.am @@ -88,6 +88,7 @@ hal-system-power-suspend \ hal-system-power-hibernate \ hal-system-power-shutdown \ + hal-system-power-standby \ hal-system-power-reboot \ hal-system-lcd-get-brightness \ hal-system-lcd-set-brightness \ --- tools/hal-system-power-standby +++ tools/hal-system-power-standby @@ -0,0 +1,22 @@ +#!/bin/sh + +PRIVILEGE=hal-power-standby +if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then + RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \ + --user $HAL_METHOD_INVOKED_BY_UID \ + --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1) + IS_PRIVILEGED=$? + if [ "$IS_PRIVILEGED" != "0" ] ; then + echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2 + echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2 + exit 1 + fi +fi + +if [ -n "$HALD_UNAME_S" -a -x ./$HALD_UNAME_S/hal-system-power-standby-$HALD_UNAME_S ]; then + exec ./$HALD_UNAME_S/hal-system-power-standby-$HALD_UNAME_S $@ +else + echo "org.freedesktop.Hal.Device.UnknownError" >&2 + echo "No back-end for your operating system" >&2 + exit 1 +fi --- tools/linux/Makefile.am +++ tools/linux/Makefile.am @@ -12,6 +12,7 @@ hal-system-power-suspend-linux \ hal-system-power-hibernate-linux \ hal-system-power-shutdown-linux \ + hal-system-power-standby-linux \ hal-system-power-reboot-linux \ hal-system-lcd-get-brightness-linux \ hal-system-lcd-set-brightness-linux \ --- tools/linux/hal-system-power-standby-linux +++ tools/linux/hal-system-power-standby-linux @@ -0,0 +1,58 @@ +#!/bin/sh + +POWERSAVED_STANDBY="dbus-send --system --dest=com.novell.powersave \ + --print-reply /com/novell/powersave \ + com.novell.powersave.action.Standby" + +unsupported() { + echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2 + echo No Standby method found >&2 + exit 1 +} + +#SuSE and ALTLinux only support powersave +if [ -f "/etc/altlinux-release" ] || [ -f "/etc/SuSE-release" ] ; then + if [ -x /usr/bin/powersave ] ; then + $POWERSAVED_STANDBY + RET=$? + else + # TODO: add support + unsupported + fi + +#FreeBSD uses zzz to suspend for both ACPI and APM +elif [ "x`uname -s`" = "xFreeBSD" ] ; then + if [ -x /usr/sbin/acpiconf ] ; then + /usr/sbin/acpiconf -s 1 + RET=$? + else + unsupported + fi + +#Other distros just need to have *any* tools installed +else + if [ -x "/usr/bin/powersave" ] ; then + $POWERSAVED_STANDBY + RET=$? + elif [ -w "/sys/power/state" ] ; then + # Use the raw kernel sysfs interface + echo "standby" > /sys/power/state + RET=$? + else + # TODO: add other scripts support + unsupported + fi + fi + +#Refresh devices as a resume can do funny things +for type in button battery ac_adapter +do + devices=`hal-find-by-capability --capability $type` + for device in $devices + do + dbus-send --system --print-reply --dest=org.freedesktop.Hal \ + $device org.freedesktop.Hal.Device.Rescan + done +done + +exit $RET --- policy/hal-power.policy_org 2007-10-17 15:44:00.000000000 +0200 +++ policy/hal-power.policy 2007-10-17 15:44:40.000000000 +0200 @@ -79,6 +79,15 @@ </defaults> </action> + <action id="org.freedesktop.hal.power-management.standby"> + <description>Standby the system</description> + <message>System policy prevents standby the system</message> + <defaults> + <allow_inactive>no</allow_inactive> + <allow_active>yes</allow_active> + </defaults> + </action> + <action id="org.freedesktop.hal.power-management.cpufreq"> <description>Configure CPU frequency scaling</description> <message>System policy prevents CPU frequency scaling to be configured</message>
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor