Ow Mun Heng, who happens to be smarter than you, thinks:
> On Sat, 2005-04-02 at 00:51 +0000, Ryan Viljoen wrote:
> > Hi
> > 
> > I am setting up my ACPI on my notebook and have come across a small
> > problem. I am setting the events in the /etc/acpi/events/default
> > config file. Now I have got the ac_adapter event working nicely with
> > speedfreq. Now I want to setup my power button and sleep button.

Hope it helps.

The /tmp/was_sleeping file is because the kernel catch when you press the power 
button when its on S1 state, so if
you want to use S1 and dont put that lines, you are going to enter in a 
infinite loop of start-suspend.


/etc/acpi/default.sh
----------
#!/bin/bash

set $*

group=${1/\/*/}
action=${1/*\//}

case "$group" in
        button)
                case "$action" in
                        power)  logger "ACPI: $group/$action action 
(/etc/acpi/$action.sh was executed)"
                                ;;
                        lid)    logger "ACPI: $group/$action action 
(/etc/acpi/$action.sh was executed)"
                                ;;
                        sleep)  logger "ACPI: $group/$action action 
(/etc/acpi/$action.sh was executed)"
                                ;;
                        *)      logger "ACPI: action $action is not defined"
                                ;;
                esac
                ;;

        *)
                logger "ACPI: group $group / action $action is not defined"
                ;;
esac
----------

/etc/acpi/lid.sh
----------
#!/bin/bash

if [ "`cut -d " " -f 20 /proc/acpi/ac_adapter/AC/state`" = "on-line" ]

        then
                logger "ACPI: Battery are online. I'm not going to sleep mode"
        else
                echo -n standby > /sys/power/state
fi
----------

/etc/acpi/power.sh
----------
#!/bin/bash

if [ ! -f /tmp/was_sleeping ]

        then
                touch /tmp/was_sleeping
                echo -n standby >| /sys/power/state # S1
#               echo -n disk >| /sys/power/state    # Suspend 2 Disk
#               /etc/init.d/shutdown.sh
        else
                rm -f /tmp/was_sleeping
                logger "ACPI: Was on S1 State. I'm not going to sleep mode"
fi
----------

/etc/acpi/sleep.sh
----------
#!/bin/bash

logger "ACPI: Time to sleep"
touch /tmp/was_sleeping
echo -n standby > /sys/power/state
----------

/etc/acpi/events/default
----------
event=.*
action=/etc/acpi/default.sh %e
----------

/etc/acpi/events/lid
----------
event=button/lid.*
action=/etc/acpi/lid.sh
----------

/etc/acpi/events/power
----------
event=button/power.*
action=/etc/acpi/power.sh
----------

/etc/acpi/events/sleep
----------
event=button/sleep.*
action=/etc/acpi/sleep.sh
----------

/etc/acpi/events/battery
----------
event=battery.*
action=echo -e "\a"
----------


-- 
A joint is just tea for two.
--
gentoo-user@gentoo.org mailing list

Reply via email to