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