ACPI/Configuration
From Gentoo Linux Wiki
| Terminals / Shells • Network • X Window System • Portage • System • Filesystems • Kernel • Other |
- Originally taken from linux.gentoo.user on Google Groups
ACPI (Advanced Configuration and Power Interface) is an interface for OS-directed configuration and power management. Devices such as AC adapters, Battery management, Thermal Controllers, Fans, and Lid Switches, as well as the usual Power On/Off and Sleep buttons are a few examples of such.
Contents |
[edit] Install
[edit] Compile your kernel with ACPI enabled
The default kernel comes with this already enabled. To check if you have ACPI compiled and enabled, see if the directory /proc/acpi/ exists. If not, in your kernal enable the following:
| Linux Kernel Configuration: Enabling ACPI |
Power management options (ACPI, APM) --->
[*] ACPI Support (Advanced Configuration and Power Interface) Support --->
[*] Deprecated /proc/acpi/event support
<*> AC Adapter
<*> Battery
<*> Button
<*> Fan
< > Dock
<*> Processor
<*> Thermal Zone
|
[edit] Install acpid
The tools for ACPI are found under sys-power/acpid.
emerge --ask --verbose sys-power/acpid
| Note: As of linux 2.6.23, you will need to manually enable the deprecated /proc/events/acpi option in the kernel. See previous section for kernel configuration. |
[edit] Running acpid
You can turn it on using:
/etc/init.d/acpid start
To have it start up when you start the machine, add it to the default runlevel:
rc-update add acpid default
If you add any config files while ACPI is running you have to restart it to reload the rules
/etc/init.d/acpid restart
[edit] Configuration
Following are some configuration file examples for setting up ACPI after it is emerged.
Remember to make the scripts executable!
chmod +x /etc/acpi/<script-filename>
[edit] Lid
This is only recommended to use on laptops. It will hibernate the computer if it is not connected to AC power supply. On most PCs the required file /proc/acpi/ac_adapter/AC/state does not exist. There might be also issues with the graphics card on some machines, even on laptops. If you've opened a SSH connection to your computer and called hibernate-ram in it. It will shutdown completely. If you press the power-button, you can proceed in your SSH connection but you don't get anything displayed on your monitor - everything else is working fome (according to lspci, etc.).
| File: /etc/acpi/events/lid |
event=button/lid.* action=/etc/acpi/lid.sh |
The following script requires the package "hibernate-script":
emerge -av hibernate-script rc-update add hibernate-cleanup boot
| File: /etc/acpi/lid.sh |
#!/bin/bash
if [ "`sed -e "s/.[^ ]* *//" /proc/acpi/ac_adapter/AC/state`" = "on-line" ]
then
logger "ACPI: AC adapter is on-line, not hibernating..."
else
logger "ACPI: AC adapter is off-line, hibernating..."
hibernate-ram
fi
|
[edit] Sleep
This will set your computer to the standby-mode. There aren't high power savings. On this machine, I've got a power saving of 20% compared to idle mode. Note: Your LAN connection will possibly break, so that you cannot use SSH during standby-mode. It's better to shutdown the computer to hibernate as it will save more power. You can wake up your computer from standby-mode through pressing the power-button. Again, this script should only be used if you really have a laptop as it relies on ACPI-events that report the battery status which do not exist on PCs.
| File: /etc/acpi/events/sleep |
event=button/sleep.* action=/etc/acpi/sleep.sh |
| File: /etc/acpi/events/battery |
event=battery.* action=echo -e "\a" |
| File: /etc/acpi/sleep.sh |
#!/bin/bash logger "ACPI: Time to sleep" touch /tmp/was_sleeping echo -n standby > /sys/power/state |
[edit] Power
This script will be executed when pressing the power-button of your computer. It should be also working on PCs with ACPI-support. This script implements three power-modes:
- Standby (S1)
- Suspend to disk
- Shutdown
The default is standby. Suspend to disk is not working on most of the computers, use standby or shutdown in this case instead. If you want to use shutdown, note that you will not be able to proceed with your session. It will shutdown your computer completely. If you want to proceed with your work, use standby or suspend to disk instead, if available.
| File: /etc/acpi/events/power |
event=button/power.* action=/etc/acpi/power.sh |
| File: /etc/acpi/power.sh |
#!/bin/bash
COMMAND="echo -n standby >| /sys/power/state" #standby
#COMMAND="echo -n disk >| /sys/power/state" #suspend to disk
#COMMAND="/etc/init.d/shutdown.sh" #shutdown
if [ ! -f /tmp/was_sleeping ]
then
touch /tmp/was_sleeping
logger "ACPI: Going to sleep..."
exec $COMMAND
else
rm -f /tmp/was_sleeping
logger "ACPI: Was on S1 state, not going to sleep mode"
fi
|
[edit] Applying changes
Having saved the scripts to disk, you need to reload the configuration. See the "Run" section how to do so.
[edit] Links
- The power management guide will help you reducing the power consumption of your laptop
- HOWTO Automatically turn off your monitor
- Fix common ACPI problems
- Troubleshooting ACPI
- The Scripts Category on the ThinkWiki has some good ACPI scripts.
- TuxOnIce
