On Mon, 2006-05-01 at 20:19 +0100, Richard Hughes wrote:
> On Mon, 2006-05-01 at 14:15 -0400, Peter Jones wrote:
> > On Mon, 2006-05-01 at 19:08 +0100, Richard Hughes wrote:
> > > It's surely a 5 minute job to add?
> > 
> > Indeed.  Go for it ;)
> 
> I guess /etc/pm/lowpower.d/ is the right name for the lowpower scripts.

What about the attached as a rough and ready start?

Richard.

Index: Makefile
===================================================================
RCS file: /cvs/pm-utils/pm-utils/Makefile,v
retrieving revision 1.32
diff -u -r1.32 Makefile
--- Makefile	1 May 2006 15:20:59 -0000	1.32
+++ Makefile	1 May 2006 20:01:05 -0000
@@ -44,6 +44,7 @@
 	install -m 755 -d $(sysconfdir)/pm
 	install -m 755 -d $(sysconfdir)/pm/hooks
 	install -m 755 -d $(sysconfdir)/pm/config.d
+	install -m 755 -d $(sysconfdir)/pm/lowpower.d
 
 	install -m 644 pm.sysconfig $(sysconfdir)/pm/config
 	for file in pm/functions* ; do \
@@ -52,6 +53,9 @@
 	for file in pm/hooks/* ; do \
 		install -m 755 $$file $(sysconfdir)/pm/hooks ; \
 	done
+	for file in pm/lowpower.d/* ; do \
+		install -m 755 $$file $(sysconfdir)/pm/lowpower.d ; \
+	done
 
 tag-archive:
 	@cvs -Q tag -F $(CVSTAG)
--- /dev/null	2006-05-01 07:42:38.603969750 +0100
+++ pm-powersave	2006-05-01 20:18:31.000000000 +0100
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Simple powersave script
+#
+# Copyright 2006 Red Hat, Inc.
+#
+# Based on work from:
+#    Bill Nottingham <[EMAIL PROTECTED]>
+#    Peter Jones <[EMAIL PROTECTED]>
+#    David Zeuthen <[EMAIL PROTECTED]>
+#    Richard Hughes <[EMAIL PROTECTED]>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+runlowpowerhooks()
+{
+	files="/etc/pm/lowpower.d/*"
+	for file in $files ; do
+		[ -x $file ] && $file $1
+	done
+}
+
+if [ "$1" == "true" ] ; then
+    echo "SetLowPower ON"
+    runlowpowerhooks true
+elif [ "$1" == "false" ] ; then
+    echo "SetLowPower OFF"
+    runlowpowerhooks false
+else
+    echo "Argument needs to be true or false"
+    exit 1
+fi
--- /dev/null	2006-05-01 07:42:38.603969750 +0100
+++ pm/lowpower.d/laptop-tools	2006-05-01 20:15:17.000000000 +0100
@@ -0,0 +1,58 @@
+#!/bin/bash
+# Values are taken from the laptop-tools package
+#	Bart Samwel <[EMAIL PROTECTED]>
+
+. /etc/pm/functions
+
+setlowpowermode()
+{
+	# Seconds laptop mode has to to wait after the disk
+	# goes idle before doing a sync.
+	echo $DISK_IDLE_SECS > /proc/sys/vm/laptop_mode
+
+	# Set dirty page values
+	echo $DIRTY_WRITEBACK > /proc/sys/vm/dirty_writeback_centisecs
+	echo $DIRTY_EXPIRE > /proc/sys/vm/dirty_expire_centisecs
+
+	# Dirty synchronous ratio.  At this percentage of dirty
+	# pages the process which calls write() does its own writeback.
+	echo $DIRTY_RATIO > /proc/sys/vm/dirty_ratio
+
+	# Allowed dirty background ratio, in percent.
+	# Once DIRTY_RATIO has been exceeded, the kernel will wake pdflush
+	# which will then reduce the amount of dirty memory to 
+	# dirty_background_ratio.  Set this nice and low, so once some
+	# writeout has commenced, we do a lot of it.
+	echo $DIRTY_BACKGROUND_RATIO > /proc/sys/vm/dirty_background_ratio
+}
+
+if [ ! -w "/proc/sys/vm/" ] ; then
+	# Use the raw kernel sysfs interface
+	echo "You do not have write access to /proc/sys/vm/"
+	exit 1
+fi
+
+case "$1" in
+	true)
+		echo "**SetLowPower ON"
+		DISK_IDLE_SECS=2
+		DIRTY_WRITEBACK=30
+		DIRTY_EXPIRE=30
+		DIRTY_RATIO=60
+		DIRTY_BACKGROUND_RATIO=1
+		setlowpowermode
+		;;
+	false)
+		echo "**SetLowPower OFF"
+		DISK_IDLE_SECS=0
+		DIRTY_WRITEBACK=500
+		DIRTY_EXPIRE=3000
+		DIRTY_RATIO=40
+		DIRTY_BACKGROUND_RATIO=10
+		setlowpowermode
+		;;
+	*)
+		;;
+esac
+
+exit $?
_______________________________________________
Pm-utils mailing list
[EMAIL PROTECTED]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to