9.2. APM

Some of the power saving functions are performed by the APM BIOS itself. On many laptops, standby and suspend states can be activated with key combinations or by closing the lid, without any special operating system function. However, to activate these modes with a command, certain actions must be triggered before the system is suspended. To view the battery charge level, you need a suitable kernel and the respective packages.

By default, APM support is integrated in the kernels shipped with SUSE LINUX. However, APM is only activated if no ACPI is implemented in the BIOS and an APM BIOS is detected. To activate APM support, ACPI must be disabled with acpi=off at the boot prompt. Enter cat /proc/apm to check if APM is active. An output consisting of various numbers indicates that everything is OK. You should now be able to shut down the computer with the command shutdown -h.

Strange things may happen if the BIOS implementation does not fully comply with the standard. Some problems can be circumvented with special boot parameters (formerly kernel configuration options). All parameters are entered at the boot prompt in the form apm=<parameter>:

on or off

Enable or disable APM support.

(no-)allow-ints

Allow interrupts during the execution of BIOS functions.

(no-)broken-psr

The “GetPowerStatus” function of the BIOS does not work properly.

(no-)realmode-power-off

Reset processor to real mode prior to shutdown.

(no-)debug

Log APM events in system log.

(no-)power-off

Power system off after shutdown.

bounce-interval=n

Time in hundredths of a second after a suspend event during which additional suspend events are ignored.

idle-threshold=n

System inactivity percentage from which the BIOS function idle is executed (0=always, 100=never).

idle-period=n

Time in hundredths of a second after which the system activity is measured.

9.2.1. The APM Daemon (apmd)

The apmd daemon (package apmd) monitors the battery and can trigger certain actions when a standby or a suspend event occurs. Although it is not mandatory for operation, it may be useful for some problems.

apmd is not started automatically when the system is booted. If you want it started automatically, edit the settings for the system services with the YaST runlevel editor. Alternatively, this can also be done with the chkconfig utility. The daemon can be started manually with the command rcapmd start.

A number of configuration variables are available in /etc/sysconfig/powermanagement. As the file is commented, only some information is provided here:

APMD_ADJUST_DISK_PERF

Adapts the disk performance to the power supply status. This can be done with a number of additional variables beginning with APMD_BATTERY (for battery operation) or APMD_AC (for AC operation).

APMD_BATTERY/AC_DISK_TIMEOUT

Disk inactivity period after which the disk is spun down. The values are described in Section 9.4. “Rest for the Hard Disk” or in the manual page for hdparm, option -S.

APMD_BATTERY/AC_KUPDATED_INTERVAL

Interval between two cycles of the kernel update daemon.

APMD_BATTERY/AC_DATA_TIMEOUT

Maximum age of buffered data.

APMD_BATTERY/AC_FILL_LEVEL

Maximum fill level of the hard disk buffer.

APMD_PCMCIA_EJECT_ON_SUSPEND

Although PCMCIA is implemented with APM support, difficulties may sometimes be encountered. Some card drivers do not resume correctly after a suspend (xirc2ps_cs). Therefore, apmd can deactivate the PCMCIA system prior to the suspend and reactivate it afterwards. To do this, set this variable to yes.

APMD_INTERFACES_TO_STOP

Set network interfaces to stop prior to a suspend and restart afterwards.

APMD_INTERFACES_TO_UNLOAD

Use this variable if you also need to unload the driver modules of these interfaces.

APMD_TURN_OFF_IDEDMA_BEFORE_SUSPEND

Sometimes, resuming after a suspend may not work if an IDE device (hard disk) is still in DMA mode.

Other options include the possibility to correct the key repeat rate or the clock after a suspend or to shut down the laptop automatically when the APM BIOS send a “battery critical” event. To execute special actions, adapt the script /usr/sbin/apmd_proxy (performs the tasks listed above) to your needs.

9.2.2. Further Commands

apmd contains a number of useful tools. apm can be used to query the current battery charge level and to set the system to standby (apm -S) or suspend (apm -s). Refer to the manual page of apm. The command apmsleep suspends the system for a specified time. To watch a log file without keeping the hard disk spinning, use tailf instead of tail -f.

There are also tools for the X Window System. apmd contains the graphical utility xapm for displaying the battery charge level. If you use the KDE desktop or at least kpanel, use kbatmon to view the battery charge level and suspend the system. xosview is another interesting alternative.