[Lunar-commits] <moonbase> laptop-mode-tools: A power saving package for Linux systems.

Florin Braescu florin at lunar-linux.org
Wed Aug 6 16:21:20 CEST 2008


commit 3e2fb287d120913f7c55e0e3ce62edc937088543
Author: Florin Braescu <florin at lunar-linux.org>
Date:   Wed Aug 6 17:21:20 2008 +0300

    laptop-mode-tools: A power saving package for Linux systems.
---
 utils/laptop-mode-tools/BUILD              |   14 +++++
 utils/laptop-mode-tools/DETAILS            |   19 +++++++
 utils/laptop-mode-tools/init.d/laptop-mode |   81 ++++++++++++++++++++++++++++
 3 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/utils/laptop-mode-tools/BUILD b/utils/laptop-mode-tools/BUILD
new file mode 100644
index 0000000..5157e67
--- /dev/null
+++ b/utils/laptop-mode-tools/BUILD
@@ -0,0 +1,14 @@
+(
+
+  prepare_install  &&
+  
+  cp -f $SCRIPT_DIRECTORY/init.d/laptop-mode  $SOURCE_DIRECTORY/etc/init.d/  &&
+  INIT_D="none"         &&
+  MAN_D=/usr/share/man  &&
+  ACPI=auto             &&
+  PMU=auto              &&
+  APM=auto              &&
+  
+  ./install.sh
+ 
+) > $C_FIFO 2>&1
diff --git a/utils/laptop-mode-tools/DETAILS b/utils/laptop-mode-tools/DETAILS
new file mode 100644
index 0000000..33d7bfe
--- /dev/null
+++ b/utils/laptop-mode-tools/DETAILS
@@ -0,0 +1,19 @@
+          MODULE=laptop-mode-tools
+         VERSION=1.45
+          SOURCE=${MODULE}_${VERSION}.tar.gz
+SOURCE_DIRECTORY=$BUILD_DIRECTORY/${MODULE}_${VERSION}
+      SOURCE_URL=http://samwel.tk/laptop_mode/tools/downloads
+      SOURCE_VFY=sha1:776537b8052086163961c2c831eddf9f3cc682ad
+        WEB_SITE=http://www.samwel.tk/laptop_mode
+	 ENTERED=20080806
+         UPDATED=20080806
+           SHORT="A laptop power saving package for Linux systems"
+
+cat << EOF
+Laptop Mode Tools is a laptop power saving package for Linux systems. 
+It allows you to extend the battery life of your laptop, in several 
+ways. It is the primary way to enable the Laptop Mode feature of the 
+Linux kernel, which lets your hard drive spin down. In addition, it 
+allows you to tweak a number of other power-related settings using a 
+simple configuration file.
+EOF
diff --git a/utils/laptop-mode-tools/init.d/laptop-mode b/utils/laptop-mode-tools/init.d/laptop-mode
new file mode 100644
index 0000000..19a540e
--- /dev/null
+++ b/utils/laptop-mode-tools/init.d/laptop-mode
@@ -0,0 +1,81 @@
+#! /bin/sh
+#
+# chkconfig: - 90 90
+# description: Starts and stops "laptop-mode" - tweaks system behavior
+#              to extend battery life.
+#
+# processname: /usr/sbin/laptop_mode
+# config:  /etc/laptop-mode/laptop-mode.conf
+
+test -f /usr/sbin/laptop_mode || exit 0
+
+if [ -f /lib/lsb/init-functions ] ; then
+  . /lib/lsb/init-functions
+else
+  log_success_msg()
+  {
+    logger -t LAPTOP-MODE -p daemon.info -- $*
+    echo "$*"
+  }
+  log_failure_msg()
+  {
+    logger -t LAPTOP-MODE -p daemon.notice -- $*
+    echo "$*"
+  }
+fi
+
+# Enable laptop mode when the system is booted when running on battery.
+
+case $1 in
+  start)
+    mkdir -p /var/run/laptop-mode-tools
+    touch /var/run/laptop-mode-tools/enabled
+    if RESULT=`/usr/sbin/laptop_mode auto` ; then
+      log_success_msg "$RESULT"
+    else
+      log_failure_msg "$RESULT"
+    fi
+    ;;
+
+  restart|reload|force-reload)
+    # Full restart: first stop laptop mode completely (to restore default mount options etc.)
+    mkdir -p /var/run/laptop-mode-tools
+    rm -f /var/run/laptop-mode-tools/enabled    
+    if RESULT=`/usr/sbin/laptop_mode stop` ; then
+      log_success_msg "$RESULT"
+    else
+      log_failure_msg "$RESULT"
+    fi
+
+    # Now remove files containing stored status, re-enable, and start it up again.
+    rm -f /var/run/laptop-mode-tools/*
+    touch /var/run/laptop-mode-tools/enabled
+    if RESULT=`/usr/sbin/laptop_mode auto force` ; then
+      log_success_msg "$RESULT"
+    else
+      log_failure_msg "$RESULT"
+    fi
+    ;;
+
+  stop)
+    rm -f /var/run/laptop-mode-tools/enabled
+    if RESULT=`/usr/sbin/laptop_mode stop` ; then
+      log_success_msg "$RESULT"
+    else
+      log_failure_msg "$RESULT"
+    fi
+    ;;
+
+  status)
+    echo "Laptop mode status:"
+    echo
+    /usr/sbin/laptop_mode status
+    ;;
+    
+  *)
+    echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
+    exit 2
+    ;;
+esac
+
+exit 0


More information about the Lunar-commits mailing list