All pastes #804830 Raw Edit

Untitled

public text v1 · immutable
·published 2007-12-03 20:38 UTC
rendered paste body
#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@
LIDSTATE=$(/bin/sed -ne "/state:/{s/^state:[ ]*\([a-zA-Z]*\)$/\1/p;q}" \
	/proc/acpi/button/lid/LID/state)

case "$1" in
  button)
    case "$2" in
	power) 
		if [ "$LIDSTATE" == "open" ]; then
			/usr/sbin/presusp
		   	hibernate -F /etc/hibernate/ram.conf
		elif [ "$LIDSTATE" == "closed" ]; then
			hibernate -F /etc/hibernate/ususpend-ram.conf
		fi
         ;;
	lid)
		if [ "$LIDSTATE" == "closed" ]; then
			/usr/sbin/presusp
			hibernate -F /etc/hibernate/ram.conf
		elif [ "$LIDSTATE" == "open" ]; then
			hibernate -F /etc/hibernate/ususpend-ram.conf
		fi
		;;
	*) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac