Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 152177 - x11-drivers/ati-drivers-8.29.6 acpi ati-powermode.sh script $default_state variable unreachable
Summary: x11-drivers/ati-drivers-8.29.6 acpi ati-powermode.sh script $default_state va...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal
Assignee: X11 External Driver Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-20 16:38 UTC by Dan Dai
Modified: 2007-09-04 01:37 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Dai 2006-10-20 16:38:34 UTC
The current /etc/acpi/ati-powermode.sh is broken. Low-power-state can be entered without problem, however will not switch back to high-power-state afterwards and leaves error in acpi log. I believe this is because the defined variable $default_state can't the reached after "su". 

I have attached a new ati-powermode.sh for consideration. 

---------------------------------------------------
#!/bin/bash

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

getXuser() {
        user=`finger| grep -m1 ":$displaynum " | awk '{print $1}'`
        if [ x"$user" = x"" ]; then
                user=`finger| 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
}

aticonfig='/opt/ati/bin/aticonfig'

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



if [ ${lid_closed} -eq 1 -o ${on_dc} -eq 1 ]; then
    echo "Low power"
    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"
            su $user -c "$aticonfig --set-powerstate=1 --effective=now"
        fi
    done
else
    echo "high power"
    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"
       export default_state=`$aticonfig --lsp | grep 'default state' | cut -c 3`            su $user -c "$aticonfig --set-powerstate=$default_state --effective=now"
        fi
    done
fi
Comment 1 Nicolas MASSE 2006-11-05 02:41:21 UTC
I think this bug is invalid and should be closed. 

The problem is not the script "ati-powermode.sh" but the something related to ACPI (hardware and/or kernel, I do not know).

On some laptops (like mine), when you close it and reopen it, only one event is generated.

To test: "tail -n 0 -f /var/log/acpid |grep event", close and open your laptop.

For example, on my laptop I have only one event :
[Sun Nov  5 11:38:15 2006] received event "button/lid LID0 00000080 00000014"
[Sun Nov  5 11:38:15 2006] completed event "button/lid LID0 00000080 00000014"

Comment 2 Remy Blank 2006-11-17 00:45:40 UTC
I think this bug is valid but has a misleading title. There are two problems with this script:

 * As noticed by Dan, at the moment of the call to get default_state, no DISPLAY is defined, and therefore the call fails. Moving the line where Dan suggests takes care of that problem.

 * The script requires the finger binary, which is not installed on my system. So a dependency on net-misc/netkit-fingerd is required.
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2007-09-04 01:37:15 UTC
Bug about ati-drivers version that doesn't exist any more in the tree ->
WONTFIX.