Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ati-powermode.sh: Gentoo Power Management Guide compatible?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
urcindalo
l33t
l33t


Joined: 08 Feb 2005
Posts: 623
Location: Almeria, Spain

PostPosted: Mon Aug 31, 2009 11:51 am    Post subject: ati-powermode.sh: Gentoo Power Management Guide compatible? Reply with quote

Hi!

I just bought a new laptop with an ATI HD4570 card. I've emerged the ~amd64 x11-drivers/ati-drivers-9.8. It seems to work OK.

I'm trying to follow the Gentoo's Power Management Guide. However, I see ati-drivers-9.8 has installed some scripts in /etc/acpi:
Code:
$ ls -l
total 8
-rwxr-xr-x  1 root root 1684 Aug 29 01:01 ati-powermode.sh
-rwxr-xr-x  1 root root 1214 Aug 28 23:49 default.sh
drwxr-xr-x  2 root root  136 Aug 29 01:01 events
$ ls -l events
total 12
-rwxr-xr-x 1 root root 124 Aug 29 01:01 a-ac-aticonfig
-rwxr-xr-x 1 root root 132 Aug 29 01:01 a-lid-aticonfig
-rw-r--r-- 1 root root 663 Aug 28 23:49 default

Do they interfere with the Power Management Guide? Does anybody have some experience on the matter?
Thanks in advance.

The conetents of the main scripts are:
Code:
$ cat ati-powermode.sh                     
#!/bin/bash                                               

#
# Control script for ACPI lid state and AC adapter state
#                                                       

aticonfig='/opt/bin/aticonfig'

getXuser() {
        user=`who| grep -m1 ":$displaynum " | awk '{print $1}'`
        if [ x"$user" = x"" ]; then                           
                user=`who| grep -m1 ":$displaynum" | awk '{print $1}'`
        fi                                                           
        if [ x"$user" != x"" ]; then                                 
                userhome=`getent passwd $user | cut -d: -f6`         
                export XAUTHORITY=$userhome/.Xauthority               
        else                                                         
                export XAUTHORITY=""                                 
        fi                                                           
}                                                                     


grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then                         
 lid_closed=1                               
 echo "Lid Closed"                         
else                                       
 lid_closed=0                               
 echo "Lid Open"                           
fi                                         

grep -q off-line /proc/acpi/ac_adapter/*/state

if [ $? = 0 ]; then
   echo "On DC"   
   on_dc=1         
else               
   echo "On AC"   
   on_dc=0         
fi                 

#Find the right XServer to be configured.
for x in /tmp/.X11-unix/*; do
   displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
   getXuser;
   if [ x"$XAUTHORITY" != x"" ]; then
       export DISPLAY=":$displaynum"
   fi
done

#If PPLIB is enabled
su $user -c '$aticonfig --pplib-cmd="get version"' | grep PPLIB
if [ $? = 0 ]; then
   echo "Has PPLIB"
   has_pplib=1
else
   echo "No PPLIB"
   has_pplib=0
fi



if [ ${lid_closed} -eq 1 -o ${on_dc} -eq 1 ]; then
    echo "Low power"
    if [ ${has_pplib} -eq 1 ]; then
        su $user -c '$aticonfig --pplib-cmd="notify psrc dc"'
    else
        su $user -c "$aticonfig --set-powerstate=1"
    fi
else
    echo "high power"
    if [ ${has_pplib} -eq 1 ]; then
        su $user -c '$aticonfig --pplib-cmd="notify psrc ac"'
    else
        su $user -c "$aticonfig --set-powerstate=$($aticonfig --lsp | grep 'default state' | cut -c 3)"
    fi
fi

Code:
$  cat default.sh                                                                       
#!/bin/sh                                                                                             
# /etc/acpi/default.sh                                                                                 
# Default acpi script that takes an entry for all actions                                             

set $*

group=${1%%/*}
action=${1#*/}
device=$2     
id=$3         
value=$4     

log_unhandled() {
        logger "ACPI event unhandled: $*"
}                                       

case "$group" in
        button)
                case "$action" in
                        power)   
                                /sbin/init 0
                                ;;         

                        # if your laptop doesnt turn on/off the display via hardware
                        # switch and instead just generates an acpi event, you can force
                        # X to turn off the display via dpms.  note you will have to run
                        # 'xhost +local:0' so root can access the X DISPLAY.
                        #lid)
                        #       xset dpms force off
                        #       ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        ac_adapter)
                case "$value" in
                        # Add code here to handle when the system is unplugged
                        # (maybe change cpu scaling to powersave mode).  For
                        # multicore systems, make sure you set powersave mode
                        # for each core!
                        #*0)
                        #       cpufreq-set -g powersave
                        #       ;;

                        # Add code here to handle when the system is plugged in
                        # (maybe change cpu scaling to performance mode).  For
                        # multicore systems, make sure you set performance mode
                        # for each core!
                        #*1)
                        #       cpufreq-set -g performance
                        #       ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        *)      log_unhandled $* ;;
esac
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum