LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   hooks in xfce4-power-manager (http://www.linuxquestions.org/questions/linux-desktop-74/hooks-in-xfce4-power-manager-756720/)

TwinReverb 09-21-2009 06:04 AM

hooks in xfce4-power-manager
 
All,

Are there any hooks I can install into either xfce4-power-manager or the underlying system to launch an hdparm and/or sysctl command from the same script(s) it calls to make the CPU go into max power savings (when on battery) and into max performance (when on AC power)? I'm asking because I'm not sure if I want to do this as a feature request or not. Thanks!

TwinReverb 09-21-2009 06:44 AM

Found the answer:

edit /usr/lib/hal/scripts/linux/hal-system-power-set-power-save-linux and add some lines....

Code:

#!/bin/sh

value=$1

unsupported() {
        echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
        echo No powersave method found >&2
        exit 1
}

# We only support pm-utils
if [ -x "/usr/sbin/pm-powersave" ] ; then
        if [ $value = "true" ]; then
                /usr/sbin/pm-powersave true
                # Added: put hard drive in high power saving
                hdparm -B 1 /dev/sda
                # Added: we're going into laptop mode
                echo 5 > /proc/sys/vm/laptop_mode
                RET=$?
        elif [ $value = "false" ]; then
                /usr/sbin/pm-powersave false
                # Added: put hard drive in high performance
                hdparm -B 254 /dev/sda
                # Added: come out of laptop mode
                echo 0 > /proc/sys/vm/laptop_mode
                RET=$?
        fi

else
        # cannot set proc stuff here, so error out
        unsupported
        fi

exit $RET



All times are GMT -5. The time now is 11:57 AM.