11.1Shubertf#!/bin/sh 21.1Shubertf# 31.7Sabs# $NetBSD: script,v 1.7 2021/11/02 21:55:38 abs 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.5Sdavid# chmod a+x suspend standby resume line battery 161.3Shubertf# 171.3Shubertf# See apmd(8) for more information. 181.1Shubertf# 191.1Shubertf 201.1Shubertf 211.1ShubertfPATH=/usr/pkg/bin:/sbin:$PATH 221.1Shubertfexport PATH 231.1Shubertf 241.1Shubertf# Where some sound files are stored: 251.7SabsS=/usr/pkg/share/kde/sounds 261.1Shubertf 271.1Shubertf# What my network card's recognized as: 281.1Shubertfif=ne0 291.1Shubertf 301.4SlukemLOGGER='logger -t apm' 311.4Slukem 321.1Shubertf 331.3Shubertfnoise() { 341.4Slukem if [ -f $1 ]; then 351.4Slukem audioplay -q -f -s 22050 -c 1 $1 361.4Slukem fi 371.3Shubertf} 381.3Shubertf 391.1Shubertfcase $0 in 401.1Shubertf*suspend) 411.4Slukem $LOGGER 'Suspending...' 421.3Shubertf noise $S/KDE_Window_UnMaximize.wav 431.1Shubertf # In case some NFS mounts still exist - we don't want them to hang: 441.1Shubertf umount -a -t nfs 451.1Shubertf umount -a -f -t nfs 461.1Shubertf ifconfig $if down 471.6Smaya sh /etc/rc.d/dhcpcd stop 481.4Slukem $LOGGER 'Suspending done.' 491.1Shubertf ;; 501.1Shubertf 511.1Shubertf*standby) 521.4Slukem $LOGGER 'Going to standby mode ....' 531.3Shubertf noise $S/KDE_Window_UnMaximize.wav 541.1Shubertf # In case some NFS mounts still exist - we don't want them to hang: 551.1Shubertf umount -a -t nfs 561.1Shubertf umount -a -f -t nfs 571.1Shubertf ifconfig $if down 581.6Smaya sh /etc/rc.d/dhcpcd stop 591.4Slukem $LOGGER 'Standby done.' 601.1Shubertf ;; 611.1Shubertf 621.1Shubertf*resume) 631.4Slukem $LOGGER 'Resuming...' 641.3Shubertf noise $S/KDE_Startup.wav 651.6Smaya sh /etc/rc.d/dhcpcd start 661.1Shubertf # mount /home 671.1Shubertf # mount /data 681.4Slukem $LOGGER 'Resuming done.' 691.1Shubertf ;; 701.1Shubertf 711.1Shubertf*line) 721.3Shubertf # noise $S/KDE_Window_DeIconify.wav 731.4Slukem $LOGGER 'Running on power line.' 741.4Slukem mount -u -o atime,devmtime -A -t ffs 751.3Shubertf atactl wd0 setidle 0 761.1Shubertf ;; 771.1Shubertf 781.1Shubertf*battery) 791.3Shubertf # noise $S/KDE_Window_DeIconify.wav 801.4Slukem $LOGGER 'Running on battery.' 811.4Slukem mount -u -o noatime,nodevmtime -A -t ffs 821.3Shubertf atactl wd0 setidle 5 831.1Shubertf ;; 841.1Shubertf 851.1Shubertfesac 861.1Shubertf 871.1Shubertfexit 0 88