#!/bin/sh # /etc/acpi/default.sh # Default acpi script that takes an entry for all actions # Use the program acpi_listen to see what kind of events are # generated. #set $* group=${1%%/*} action=${1#*/} device=$2 id=$3 value=$4 log_unhandled() { logger "ACPI event unhandled: $*" } restoreclock() { # set system clock from hw clock logger "$0 wakup, restore clock" hwclock --hctosys --utc } #echo "group $group, action $action, device $device, id $id, value $value">> /tmp/dbg # This is what happens on a Lenovo x301: # Fn F4: # group ibm, action hotkey, device HKEY, id 00000080, value 00001004 # # Close lid: # group button, action lid, device LID, id 00000080, value 00000001 # The value will count up for every close or open of the lid # group video, action video, device VID, id 00000080, value 00000000 # # Open lid: # group button, action lid, device LID, id 00000080, value 00000002 # The value will count up for every close or open of the lid case "$group" in ibm) case "$action" in hotkey) if [ "$id" == "00000080" -a "$value" == "00001004" ]; then logger "$0 suspend to ram, Fn F4" #echo 5 > /proc/acpi/ibm/beep echo mem > /sys/power/state restoreclock /usr/local/laptop/bin/laptop_wlan_reassoc_acpi & fi #*) log_unhandled $* ;; esac ;; button) case "$action" in lid) # we see here only close lid because we are # already sleeping when it opens if [ "$id" == "00000080" ]; then logger "$0 suspend to ram, close lid" #echo 5 > /proc/acpi/ibm/beep echo mem > /sys/power/state restoreclock /usr/local/laptop/bin/laptop_wlan_reassoc_acpi & fi # x301 turns the led backlight automatically off # when closing. No special handling needed. #*) log_unhandled $* ;; esac ;; ac_adapter) case "$value" in # Add code here to handle when the system is unplugged # (maybe change cpu scaling to powersave mode). For # multicore systems, make sure you set powersave mode # for each core! #*0) # cpufreq-set -g powersave # ;; # Add code here to handle when the system is plugged in # (maybe change cpu scaling to performance mode). For # multicore systems, make sure you set performance mode # for each core! #*1) # cpufreq-set -g performance # ;; *) log_unhandled $* ;; esac ;; #*) log_unhandled $* ;; esac