Home | History | Annotate | Line # | Download | only in scripts
acadapter revision 1.1
      1  1.1  jmcneill #!/bin/sh -
      2  1.1  jmcneill #
      3  1.1  jmcneill #	$NetBSD: acadapter,v 1.1 2006/09/26 02:17:38 jmcneill Exp $
      4  1.1  jmcneill #
      5  1.1  jmcneill # Generic script for acadapter events.
      6  1.1  jmcneill #
      7  1.1  jmcneill # Arguments passed by powerd(8):
      8  1.1  jmcneill #
      9  1.1  jmcneill #	device event
     10  1.1  jmcneill 
     11  1.1  jmcneill case "${2}" in
     12  1.1  jmcneill pressed)
     13  1.1  jmcneill 	logger -p info "${0}: Full performance mode" >&1
     14  1.1  jmcneill 	# The following turns up brightness on a Sony Vaio laptop
     15  1.1  jmcneill 	/sbin/sysctl -w hw.sony0.brt=8 >/dev/null 2>&1
     16  1.1  jmcneill 	# Enable full performance mode for speedstep CPUs
     17  1.1  jmcneill 	/sbin/sysctl -w machdep.speedstep_state=1 2>&1
     18  1.1  jmcneill 	# Disable power saving mode on all network interfaces
     19  1.1  jmcneill 	for intf in /sbin/ifconfig -l; do
     20  1.1  jmcneill 		/sbin/ifconfig $intf -powersave >/dev/null 2>&1
     21  1.1  jmcneill 	done
     22  1.1  jmcneill 
     23  1.1  jmcneill 	#
     24  1.1  jmcneill 	# If you want to keep your hard disk idle while running on
     25  1.1  jmcneill 	# battery, the following commands will help.
     26  1.1  jmcneill 	#
     27  1.1  jmcneill 
     28  1.1  jmcneill 	# Disk idle timeouts
     29  1.1  jmcneill 	#/sbin/atactl wd0 setidle 300
     30  1.1  jmcneill 	#/sbin/atactl wd0 setstandby 600
     31  1.1  jmcneill 	# Make sure syslogd is running
     32  1.1  jmcneill 	#pkill syslogd
     33  1.1  jmcneill 	#/etc/rc.d/syslogd start
     34  1.1  jmcneill 	# Startup cron daemon when running on power
     35  1.1  jmcneill 	#/etc/rc.d/cron start
     36  1.1  jmcneill 
     37  1.1  jmcneill 	# All finished
     38  1.1  jmcneill 	exit 0
     39  1.1  jmcneill 	;;
     40  1.1  jmcneill 
     41  1.1  jmcneill released)
     42  1.1  jmcneill 	logger -p info "${0}: Power saving mode" >&1
     43  1.1  jmcneill 	# The following turns down brightness on a Sony Vaio laptop
     44  1.1  jmcneill 	/sbin/sysctl -w hw.sony0.brt=0 >/dev/null 2>&1
     45  1.1  jmcneill 	# Enable power saving mode for speedstep CPUs
     46  1.1  jmcneill 	/sbin/sysctl -w machdep.speedstep_state=0 >/dev/null 2>&1
     47  1.1  jmcneill 
     48  1.1  jmcneill 	# Disable power saving mode on all network interfaces
     49  1.1  jmcneill 	for intf in /sbin/ifconfig -l; do
     50  1.1  jmcneill 		/sbin/ifconfig $intf powersave >/dev/null 2>&1
     51  1.1  jmcneill 	done
     52  1.1  jmcneill 
     53  1.1  jmcneill 	#
     54  1.1  jmcneill 	# When running on battery, we want to keep the disk idle for as long
     55  1.1  jmcneill 	# as possible. Unfortunately, things like cron and syslog make this
     56  1.1  jmcneill 	# very difficult. If you can live without cron or persistent logging,
     57  1.1  jmcneill 	# you can use the commands below to disable cron and syslogd.
     58  1.1  jmcneill 	#
     59  1.1  jmcneill 	# If you still want to see syslog messages, you can create a custom
     60  1.1  jmcneill 	# /etc/syslog.conf.battery that writes messages to /dev/console or
     61  1.1  jmcneill 	# possibly a free wsdisplay screen.
     62  1.1  jmcneill 	#
     63  1.1  jmcneill 
     64  1.1  jmcneill 	# Disk idle timeouts
     65  1.1  jmcneill 	#/sbin/atactl wd0 setidle 30
     66  1.1  jmcneill 	#/sbin/atactl wd0 setstandby 120
     67  1.1  jmcneill 	
     68  1.1  jmcneill 	# Stop the cron daemon
     69  1.1  jmcneill 	#/etc/rc.d/cron stop
     70  1.1  jmcneill 
     71  1.1  jmcneill 	# Restart syslogd using a diskless configuration
     72  1.1  jmcneill 	#pkill syslogd
     73  1.1  jmcneill 	#/usr/sbin/syslogd -s -f /etc/syslog.conf.battery
     74  1.1  jmcneill 
     75  1.1  jmcneill 	# All finished
     76  1.1  jmcneill 	exit 0
     77  1.1  jmcneill 	;;
     78  1.1  jmcneill 
     79  1.1  jmcneill *)
     80  1.1  jmcneill 	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
     81  1.1  jmcneill 	exit 1
     82  1.1  jmcneill 	;;
     83  1.1  jmcneill esac
     84