script revision 1.4
11.1Shubertf#!/bin/sh
21.1Shubertf#
31.4Slukem# $NetBSD: script,v 1.4 2000/11/05 03:30:51 lukem Exp $
41.1Shubertf#
51.1Shubertf
61.1Shubertf#
71.1Shubertf# Link this script to /etc/apm/{suspend,standby,resume,line,battery}
81.1Shubertf# to play some sounds on suspend/resume, and enable/shutdown the 
91.3Shubertf# network card:
101.3Shubertf#
111.3Shubertf#   mkdir /etc/apm
121.3Shubertf#   cp script /etc/apm/suspend
131.3Shubertf#   cd /etc/apm
141.3Shubertf#   for i in standby resume line battery ; do ln suspend $i ; done
151.3Shubertf#
161.3Shubertf# See apmd(8) for more information.
171.1Shubertf#
181.1Shubertf
191.1Shubertf
201.1ShubertfPATH=/usr/pkg/bin:/sbin:$PATH
211.1Shubertfexport PATH
221.1Shubertf
231.1Shubertf# Where some sound files are stored:
241.1ShubertfS=/usr/X11R6/share/kde/sounds
251.1Shubertf
261.1Shubertf# What my network card's recognized as:
271.1Shubertfif=ne0
281.1Shubertf
291.4SlukemLOGGER='logger -t apm'
301.4Slukem
311.1Shubertf
321.3Shubertfnoise() {
331.4Slukem	if [ -f $1 ]; then
341.4Slukem		audioplay -q -f -s 22050 -c 1 $1
351.4Slukem	fi
361.3Shubertf}
371.3Shubertf
381.1Shubertfcase $0 in
391.1Shubertf*suspend)	
401.4Slukem	$LOGGER 'Suspending...'
411.3Shubertf	noise $S/KDE_Window_UnMaximize.wav
421.1Shubertf	# In case some NFS mounts still exist - we don't want them to hang:
431.1Shubertf	umount -a    -t nfs
441.1Shubertf	umount -a -f -t nfs
451.1Shubertf	ifconfig $if down
461.3Shubertf	sh /etc/rc.d/dhclient stop
471.4Slukem	$LOGGER 'Suspending done.'
481.1Shubertf	;;
491.1Shubertf
501.1Shubertf*standby)
511.4Slukem	$LOGGER 'Going to standby mode ....'
521.3Shubertf	noise $S/KDE_Window_UnMaximize.wav
531.1Shubertf	# In case some NFS mounts still exist - we don't want them to hang:
541.1Shubertf	umount -a    -t nfs
551.1Shubertf	umount -a -f -t nfs
561.1Shubertf	ifconfig $if down
571.3Shubertf	sh /etc/rc.d/dhclient stop
581.4Slukem	$LOGGER 'Standby done.'
591.1Shubertf	;;
601.1Shubertf
611.1Shubertf*resume)
621.4Slukem	$LOGGER 'Resuming...'
631.3Shubertf	noise $S/KDE_Startup.wav
641.3Shubertf	sh /etc/rc.d/dhclient start
651.1Shubertf	# mount /home
661.1Shubertf	# mount /data
671.4Slukem	$LOGGER 'Resuming done.'
681.1Shubertf	;;
691.1Shubertf
701.1Shubertf*line)
711.3Shubertf	# noise $S/KDE_Window_DeIconify.wav
721.4Slukem	$LOGGER 'Running on power line.'
731.4Slukem	mount -u -o atime,devmtime -A -t ffs
741.3Shubertf	atactl wd0 setidle 0
751.1Shubertf	;;
761.1Shubertf
771.1Shubertf*battery)
781.3Shubertf	# noise $S/KDE_Window_DeIconify.wav
791.4Slukem	$LOGGER 'Running on battery.'
801.4Slukem	mount -u -o noatime,nodevmtime -A -t ffs
811.3Shubertf	atactl wd0 setidle 5
821.1Shubertf	;;
831.1Shubertf
841.1Shubertfesac
851.1Shubertf
861.1Shubertfexit 0
87