Differences between revisions 8 and 9
Revision 8 as of 2005-10-25 13:37:17
Size: 4992
Editor: MartinWilck
Comment:
Revision 9 as of 2005-10-29 15:00:53
Size: 4782
Editor: MartinWilck
Comment:
Deletions are marked like this. Additions are marked like this.
Line 85: Line 85:
The default {{{acpid}}} setup in Etch has a script for the '''power button''' that
 1. If a user is logged in under KDE, logs him out;
 1. Otherwise, initiates a graceful shutdown.
Thus, the power button needs to be pressed twice if someone is logged on under KDE.
All of this works out of the box on the X50.
The default {{{acpid}}} setup in Etch has a script for the '''power button''' that works as expected.

Power Management and ACPI

Most of this works out-of-the-box. [http://faq.pathfinderteam.org/index.php/Samsung_X20 this page on the Samsung X20 (in German)] has many good hints.

The battery lifetime numbers Samsung publishes (6h) are marketing exaggerations. The normal battery in my notebook lasts about 2h when I'm working normally.

Emergency power off

React to "battery low" events by shutting down gracefully or suspending. Works with acpid. Action must be written by hand on Debian. Here is mine:

# /etc/acpid/actions/mw_battery.sh

# Don't forget to define an event in /etc/acpi/events that calls 
# /etc/acpi/actions/mw_battery.sh %e on battery events

export LC_ALL=C

# dont bother if shutdown is already running
[ -f /var/run/shutdown.pid ] && exit 0

minutes=$(/usr/local/bin/minutes_to_go $2)
[ -z "$minutes" ] && exit 0 # charging or full

if [ $minutes -le 3 ]; then
   /sbin/shutdown -h now "battery running low ($minutes minutes)"
fi

The minutes_to_go command is here:

# /usr/local/bin/minutes_to_go BATTERY

BAT=$1
[ -r /proc/acpi/battery/$BAT/state ] || exit 2

awk '
/^charging state:/ { if ($3 !~ /^discharging/) { r=0; exit (0); }}
/^present rate:/ {r=$3}
/^remaining capacity/ {c=$3}
END { if (r) print int(60*c/r); }
' /proc/acpi/battery/$BAT/state

Instead of poweroff, one could as well do a suspend-to-disk (see below).

Likewise, it should be possible to react to "critical temperature" events. Should be possible with acpid on the X50, too. Not tested (I didn't reach critical temperatures:-).

ACPI sleep states and software suspend

This requires a kernel recompilation. Make the following selections in the kernel configuration:

 -> Power management options (ACPI, APM)
   [*] Software Suspend [EXPERIMENTAL]     
   -> ACPI (Advanced Configuration and Power Interface) Support                                                                  
     -> ACPI Support 
     [*] ACPI Sleep States [EXPERIMENTAL]

Suspend-to-disk (echo disk >/sys/power/state) works fine on the X50 as long as the proprietary ATI graphics driver isn't used.

Suspend-to-RAM didn't work for me yet.

Power saving

CPU frequency adjustment works very well. There is a large number of tools available ([http://www.gentoo.de/doc/de/power-management-guide.xml see here for a comparison]). My personal favorite under Debian are the light-weight cpufrequtils. They rely mostly on the kernel cpufreq driver to do the adjustments. I am using the ondemand governor under normal conditions and the powersave governor when I really want to save battery. I put the following into /etc/modules to enable power control:

freq_table
speedstep_centrino
cpufreq_ondemand
cpufreq_powersave

cpufrequtils must be enabled by editing /etc/default/cpufrequtils. I call cpufreq-set upon acpid AC adapter events and etiquette mode keys (see ../InputDevices).

There are also power saving modes for other components besides the CPU. Onfortunately, the hdparm commands to put the disk to sleep don't work with SATA disks underr libata (yet), so the laptop-mode-tools package is currently mostly useless.

Power button and sleep button

The default acpid setup in Etch has a script for the power button that works as expected.

The sleep button is detected on the X50 but there is no default action. Here is mine:

# /etc/acpi/actions/mw_sleep.sh
# Create an acpi event that calls this script!

# The resume partition: /dev/sda10 on my laptop
RESUME=8:10

export LC_ALL=C

# Security: be sure that no console is directly accessible after wake-up
kill_console_sessions() {
        wall <<EOF
 *** SLEEP BUTTON PRESSED ***
EOF
        sleep 2
        [ -n "$(dcop --all-users --list-sessions)" ] && {
                dcop --all-users kdesktop KScreensaverIface lock
        }
        ps -eo tty,comm,pid | \
                awk '/tty[0-9]* *login /{print $3}' | \
                xargs -r kill -TERM
}

### CAREFUL! Does this also work with fglrx (ATI proprietary X driver)??
grep -q fglrx /proc/modules && exit 0

## set resume partition
grep -q $RESUME /sys/power/resume || echo $RESUME >/sys/power/resume

kill_console_sessions

chvt 1 # change to text terminal to avoid problems with X
[ -w /sys/power/state ] && {
        /sbin/hwclock --systohc
        echo disk >/sys/power/state
        /sbin/hwclock --hctosys
}
chvt 7 # change back to the console you want activated after wake-up (X Windows)