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