#!/bin/sh

# name        : laptop-mode
# author      : Matthias Grimm <matthiasgrimm@users.sourceforge.net>
# description : toggle laptop mode in kernel and adjust
#               memory management buffer flush timeouts
# requirements: laptop-mode support in kernel
#               laptopmode.sh somewhere on your system
# limitations : none
#
# --- end of public part -- don't change below this line ---

set -e
LMODE=/lib/udev/lmt-udev

[ -x $LMODE ] || exit 0

if [ -w /proc/sys/vm/laptop_mode ]; then
	case "$1" in
		powersave)
			$LMODE "start"
			echo "3 " $LMODE "start"
			;;
		custom)
			$LMODE "auto"
			;;
		performance)
			$LMODE "stop"
			;;
	esac
elif [ -x logger ]; then
	logger -p daemon.error -t laptop-mode "Laptop-mode support missing in kernel."
fi


