hal/tools hal-system-power-hibernate, 1.4, 1.5 hal-system-power-set-power-save, 1.2, 1.3 hal-system-power-suspend, 1.2, 1.3

Richard Hughes hughsient at freedesktop.org
Wed Sep 28 09:52:15 PDT 2005


Update of /cvs/hal/hal/tools
In directory gabe:/tmp/cvs-serv14634/tools

Modified Files:
	hal-system-power-hibernate hal-system-power-set-power-save 
	hal-system-power-suspend 
Log Message:
Use sensible fallbacks for the tools/hal-system-power-* tools.

Index: hal-system-power-hibernate
===================================================================
RCS file: /cvs/hal/hal/tools/hal-system-power-hibernate,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- hal-system-power-hibernate	13 Sep 2005 18:57:02 -0000	1.4
+++ hal-system-power-hibernate	28 Sep 2005 16:52:13 -0000	1.5
@@ -1,76 +1,51 @@
 #!/bin/sh
 
-unknown_distro() {
-    echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
-    echo Unsupported Operating System >&2
-    exit 1
-}
-
 unsupported() {
-    echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
-    echo No hibernate script found >&2
-    exit 1
+	echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
+	echo No hibernate script found >&2
+	exit 1
 }
 
-if [ -f /etc/altlinux-release ] ; then
-    if [ -x /usr/bin/powersave ] ; then
-        /usr/bin/powersave --suspend-to-disk
-        RET=$?
-    else
-        # TODO: add support
-        unsupported
-    fi
+#SuSE and ALTLinux only support powersave
+if [ -f /etc/altlinux-release ] || [ -f "/etc/SuSE-release" ] ; then
+	if [ -x /usr/bin/powersave ] ; then
+		/usr/bin/powersave --suspend-to-disk
+		RET=$?
+	else
+		unsupported
+	fi
+
+#RedHat/Fedora only support pm-utils
 elif [ -f /etc/redhat-release ] || [ -f /etc/fedora-release ] ; then
-    /usr/sbin/pm-hibernate
-    RET=$?
-elif [ -f /etc/SuSE-release ] ; then
-    /usr/bin/powersave --suspend-to-disk
-    RET=$?
-elif [ -f /etc/mandrake-release ] ; then
-    # Try to use hibernate2 (if user has installed tools)
-    if [ -x /usr/sbin/hibernate ] ; then
-        /usr/sbin/hibernate --force
-        RET=$?
-    else
-        # TODO: add distro specific support
-        unsupported
-    fi
-elif [ -f /etc/gentoo-release ] ; then
-    # Try to use hibernate2 (if user has installed tools)
-    if [ -x /usr/sbin/hibernate ] ; then
-        /usr/sbin/hibernate --force
-        RET=$?
-    else
-        # TODO: add distro specific support
-        unsupported
-    fi
-elif [ -f /etc/slackware-version ] ; then
-    # Try to use hibernate2 (if user has installed tools)
-    if [ -x /usr/sbin/hibernate ] ; then
-        /usr/sbin/hibernate --force
-        RET=$?
-    else
-        # TODO: add distro specific support
-	unsupported
-    fi
-elif [ -f /etc/debian_version ] ; then
-    # Try to use hibernate2 (if user has installed tools)
-    if [ -x /usr/sbin/hibernate ] ; then
-        /usr/sbin/hibernate --force
-        RET=$?
-    else
-        # TODO: add distro specific support
-        unsupported
-    fi
+	if [ -x /usr/sbin/pm-hibernate ] ; then
+		/usr/sbin/pm-hibernate
+		RET=$?
+	else
+		unsupported
+	fi
+
+#Other distros just need to have *any* tools installed
 else
-    # Try to use hibernate2 (if user has installed tools)
-    if [ -x /usr/sbin/hibernate ] ; then
-        /usr/sbin/hibernate --force
-        RET=$?
-    else
-        # TODO: add distro specific support
-        unknown_distro
-    fi
-fi 
+	if [ -x "/usr/bin/powersave" ] ; then
+		/usr/bin/powersave --suspend-to-disk
+		RET=$?
+	elif [ -x "/usr/sbin/pmi" ] ; then
+		/usr/sbin/pmi action hibernate force
+		RET=$?
+	elif [ -x "/usr/sbin/pm-hibernate" ] ; then
+		/usr/sbin/pm-hibernate
+		RET=$?
+	elif [ -x "/usr/sbin/hibernate" ] ; then
+		# Suspend2 tools installed
+		/usr/sbin/hibernate --force
+		RET=$?
+	elif [ -w "/sys/power/state" ] ; then
+		# Use the raw kernel sysfs interface
+		echo "disk" > /sys/power/state
+		RET=$?
+	else
+		unsupported
+		fi
+	fi
 
 exit $RET

Index: hal-system-power-set-power-save
===================================================================
RCS file: /cvs/hal/hal/tools/hal-system-power-set-power-save,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hal-system-power-set-power-save	19 Aug 2005 12:33:48 -0000	1.2
+++ hal-system-power-set-power-save	28 Sep 2005 16:52:13 -0000	1.3
@@ -1,56 +1,44 @@
 #!/bin/sh
 read value
 
-unknown_distro() {
-    echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
-    echo Unsupported Operating System >&2
-    todo
-}
-
-todo() {
-    if [ $value = "true" ]; then
-        echo TODO: enable power savings
-    elif [ $value = "false" ]; then
-        echo TODO: disable power savings
-    fi
-    exit 1
+unsupported() {
+	echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
+	echo No powersave script 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
+		if [ $value = "true" ]; then
+			/usr/bin/powersave -e Powersave
+			RET=$?
+		elif [ $value = "false" ]; then
+			/usr/bin/powersave -e Performance
+			RET=$?
+		fi
+	else
+		unsupported
+	fi
 
-if [ -f /etc/altlinux-release ] ; then
-    if [ -x /usr/bin/powersave ] ; then
-        if [ $value = "true" ]; then
-            /usr/bin/powersave -e Powersave
-            RET=$?
-        elif [ $value = "false" ]; then
-            /usr/bin/powersave -e Performance
-            RET=$?
-        fi
-    else
-        todo
-    fi
+#RedHat/Fedora only support pm-utils
 elif [ -f /etc/redhat-release ] || [ -f /etc/fedora-release ] ; then
-    todo
-elif [ -f /etc/SuSE-release ] ; then
-    if [ $value = "true" ]; then
-        /usr/bin/powersave -e Powersave
-        RET=$?
-    elif [ $value = "false" ]; then
-        /usr/bin/powersave -e Performance
-        RET=$?
-    fi
-elif [ -f /etc/mandrake-release ] ; then
-    todo
-elif [ -f /etc/gentoo-release ] ; then
-    todo
-elif [ -f /etc/slackware-version ] ; then
-    todo
-elif [ -f /etc/debian_version ] ; then
-    todo
+	if [ -x "/usr/sbin/pm-powersave" ] ; then
+		if [ $value = "true" ]; then
+			/usr/sbin/pm-powersave on
+			RET=$?
+		elif [ $value = "false" ]; then
+			/usr/sbin/pm-powersave off
+			RET=$?
+		fi
+	else
+		unsupported
+	fi
+
 else
-    # TODO: support other distros
-    unknown_distro
-fi 
+	# cannot set proc stuff here, so error out
+	unsupported
+	fi 
 
 exit $RET
 

Index: hal-system-power-suspend
===================================================================
RCS file: /cvs/hal/hal/tools/hal-system-power-suspend,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hal-system-power-suspend	19 Aug 2005 12:33:48 -0000	1.2
+++ hal-system-power-suspend	28 Sep 2005 16:52:13 -0000	1.3
@@ -1,60 +1,61 @@
 #!/bin/sh
 
 alarm_not_supported() {
-    echo org.freedesktop.Hal.Device.SystemPowerManagement.AlarmNotSupported >&2
-    echo Waking the system up is not supported >&2
-    exit 1
+	echo org.freedesktop.Hal.Device.SystemPowerManagement.AlarmNotSupported >&2
+	echo Waking the system up is not supported >&2
+	exit 1
 }
 
 unsupported() {
-    echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
-    echo No suspend script found >&2
-    exit 1
-}
-
-unknown_distro() {
-    echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
-    echo Unsupported Operating System >&2
-    exit 1
+	echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
+	echo No suspend script found >&2
+	exit 1
 }
 
 read seconds_to_sleep
 
-if [ -f /etc/altlinux-release ] ; then
-    if [ -x /usr/bin/powersave ] ; then
-        /usr/bin/powersave --suspend-to-ram
-        RET=$?
-    else
-        # TODO: add support
-        unsupported
-    fi
-elif [ -f /etc/redhat-release ] || [ -f /etc/fedora-release ] ; then
-    # TODO: fix pm-suspend to take a --wakeup-alarm argument
-    if [ $seconds_to_sleep != "0" ] ; then
-        alarm_not_supported
-    fi
-    /usr/sbin/pm-suspend
-    RET=$?
-    # TODO: fixup pm-suspend to define erroc code (see alarm above) and throw
-    #       the appropriate exception
-elif [ -f /etc/SuSE-release ] ; then
-    /usr/bin/powersave --suspend-to-ram
-    RET=$?
-elif [ -f /etc/mandrake-release ] ; then
-    # TODO: add support
-    unsupported
-elif [ -f /etc/gentoo-release ] ; then
-    # TODO: add support
-    unsupported
-elif [ -f /etc/slackware-version ] ; then
-    # TODO: add support
-    unsupported
-elif [ -f /etc/debian_version ] ; then
-    # TODO: add support
-    unsupported
+#SuSE and ALTLinux only support powersave
+if [ -f "/etc/altlinux-release" ] || [ -f "/etc/SuSE-release" ] ; then
+	if [ -x /usr/bin/powersave ] ; then
+		/usr/bin/powersave --suspend-to-ram
+		RET=$?
+	else
+		# TODO: add support
+		unsupported
+	fi
+
+#RedHat/Fedora only support pm-utils
+elif [ -f "/etc/redhat-release" ] || [ -f "/etc/fedora-release" ] ; then
+	# TODO: fix pm-suspend to take a --wakeup-alarm argument
+	if [ $seconds_to_sleep != "0" ] ; then
+		alarm_not_supported
+	fi
+	# TODO: fixup pm-suspend to define erroc code (see alarm above) and throw
+	#	   the appropriate exception
+	if [ -x "/usr/sbin/pm-suspend" ] ; then
+		/usr/sbin/pm-suspend
+		RET=$?
+	else
+		# TODO: add support
+		unsupported
+	fi
+
+#Other distros just need to have *any* tools installed
 else
-    # TODO: support other distros
-    unknown_distro
-fi 
+	if [ -x "/usr/bin/powersave" ] ; then
+	    /usr/bin/powersave --suspend-to-ram
+	    RET=$?
+	elif [ -x "/usr/sbin/pmi" ] ; then
+	    /usr/sbin/pmi action suspend force
+	    RET=$?
+	elif [ -w "/sys/power/state" ] ; then
+	    # Use the raw kernel sysfs interface
+	    echo "mem" > /sys/power/state
+	    RET=$?
+	else
+	    # TODO: add other scripts support
+	    unsupported
+	    fi
+	fi
 
 exit $RET




More information about the hal-commit mailing list