Home | History | Annotate | Line # | Download | only in apm
script revision 1.3.2.1
      1      1.1  hubertf #!/bin/sh
      2      1.1  hubertf #
      3  1.3.2.1       he # $NetBSD: script,v 1.3.2.1 2001/05/06 14:30:24 he Exp $
      4      1.1  hubertf #
      5      1.1  hubertf 
      6      1.1  hubertf #
      7      1.1  hubertf # Link this script to /etc/apm/{suspend,standby,resume,line,battery}
      8      1.1  hubertf # to play some sounds on suspend/resume, and enable/shutdown the 
      9      1.3  hubertf # network card:
     10      1.3  hubertf #
     11      1.3  hubertf #   mkdir /etc/apm
     12      1.3  hubertf #   cp script /etc/apm/suspend
     13      1.3  hubertf #   cd /etc/apm
     14      1.3  hubertf #   for i in standby resume line battery ; do ln suspend $i ; done
     15      1.3  hubertf #
     16      1.3  hubertf # See apmd(8) for more information.
     17      1.1  hubertf #
     18      1.1  hubertf 
     19      1.1  hubertf 
     20      1.1  hubertf PATH=/usr/pkg/bin:/sbin:$PATH
     21      1.1  hubertf export PATH
     22      1.1  hubertf 
     23      1.1  hubertf # Where some sound files are stored:
     24      1.1  hubertf S=/usr/X11R6/share/kde/sounds
     25      1.1  hubertf 
     26      1.1  hubertf # What my network card's recognized as:
     27      1.1  hubertf if=ne0
     28      1.1  hubertf 
     29  1.3.2.1       he LOGGER='logger -t apm'
     30  1.3.2.1       he 
     31      1.1  hubertf 
     32      1.3  hubertf noise() {
     33  1.3.2.1       he 	if [ -f $1 ]; then
     34  1.3.2.1       he 		audioplay -q -f -s 22050 -c 1 $1
     35  1.3.2.1       he 	fi
     36      1.3  hubertf }
     37      1.3  hubertf 
     38      1.1  hubertf case $0 in
     39      1.1  hubertf *suspend)	
     40  1.3.2.1       he 	$LOGGER 'Suspending...'
     41      1.3  hubertf 	noise $S/KDE_Window_UnMaximize.wav
     42      1.1  hubertf 	# In case some NFS mounts still exist - we don't want them to hang:
     43      1.1  hubertf 	umount -a    -t nfs
     44      1.1  hubertf 	umount -a -f -t nfs
     45      1.1  hubertf 	ifconfig $if down
     46      1.3  hubertf 	sh /etc/rc.d/dhclient stop
     47  1.3.2.1       he 	$LOGGER 'Suspending done.'
     48      1.1  hubertf 	;;
     49      1.1  hubertf 
     50      1.1  hubertf *standby)
     51  1.3.2.1       he 	$LOGGER 'Going to standby mode ....'
     52      1.3  hubertf 	noise $S/KDE_Window_UnMaximize.wav
     53      1.1  hubertf 	# In case some NFS mounts still exist - we don't want them to hang:
     54      1.1  hubertf 	umount -a    -t nfs
     55      1.1  hubertf 	umount -a -f -t nfs
     56      1.1  hubertf 	ifconfig $if down
     57      1.3  hubertf 	sh /etc/rc.d/dhclient stop
     58  1.3.2.1       he 	$LOGGER 'Standby done.'
     59      1.1  hubertf 	;;
     60      1.1  hubertf 
     61      1.1  hubertf *resume)
     62  1.3.2.1       he 	$LOGGER 'Resuming...'
     63      1.3  hubertf 	noise $S/KDE_Startup.wav
     64      1.3  hubertf 	sh /etc/rc.d/dhclient start
     65      1.1  hubertf 	# mount /home
     66      1.1  hubertf 	# mount /data
     67  1.3.2.1       he 	$LOGGER 'Resuming done.'
     68      1.1  hubertf 	;;
     69      1.1  hubertf 
     70      1.1  hubertf *line)
     71      1.3  hubertf 	# noise $S/KDE_Window_DeIconify.wav
     72  1.3.2.1       he 	$LOGGER 'Running on power line.'
     73  1.3.2.1       he 	mount -u -o atime,devmtime -A -t ffs
     74      1.3  hubertf 	atactl wd0 setidle 0
     75      1.1  hubertf 	;;
     76      1.1  hubertf 
     77      1.1  hubertf *battery)
     78      1.3  hubertf 	# noise $S/KDE_Window_DeIconify.wav
     79  1.3.2.1       he 	$LOGGER 'Running on battery.'
     80  1.3.2.1       he 	mount -u -o noatime,nodevmtime -A -t ffs
     81      1.3  hubertf 	atactl wd0 setidle 5
     82      1.1  hubertf 	;;
     83      1.1  hubertf 
     84      1.1  hubertf esac
     85      1.1  hubertf 
     86      1.1  hubertf exit 0
     87