1cabb78b6Shubertf#!/bin/sh 2cabb78b6Shubertf# 3*52b076efSabs# $NetBSD: script,v 1.7 2021/11/02 21:55:38 abs Exp $ 4cabb78b6Shubertf# 5cabb78b6Shubertf 6cabb78b6Shubertf# 7cabb78b6Shubertf# Link this script to /etc/apm/{suspend,standby,resume,line,battery} 8cabb78b6Shubertf# to play some sounds on suspend/resume, and enable/shutdown the 9112d4ac0Shubertf# network card: 10112d4ac0Shubertf# 11112d4ac0Shubertf# mkdir /etc/apm 12112d4ac0Shubertf# cp script /etc/apm/suspend 13112d4ac0Shubertf# cd /etc/apm 14112d4ac0Shubertf# for i in standby resume line battery ; do ln suspend $i ; done 15ada31564Sdavid# chmod a+x suspend standby resume line battery 16112d4ac0Shubertf# 17112d4ac0Shubertf# See apmd(8) for more information. 18cabb78b6Shubertf# 19cabb78b6Shubertf 20cabb78b6Shubertf 21cabb78b6ShubertfPATH=/usr/pkg/bin:/sbin:$PATH 22cabb78b6Shubertfexport PATH 23cabb78b6Shubertf 24cabb78b6Shubertf# Where some sound files are stored: 25*52b076efSabsS=/usr/pkg/share/kde/sounds 26cabb78b6Shubertf 27cabb78b6Shubertf# What my network card's recognized as: 28cabb78b6Shubertfif=ne0 29cabb78b6Shubertf 302e7cad82SlukemLOGGER='logger -t apm' 312e7cad82Slukem 32cabb78b6Shubertf 33112d4ac0Shubertfnoise() { 342e7cad82Slukem if [ -f $1 ]; then 35112d4ac0Shubertf audioplay -q -f -s 22050 -c 1 $1 362e7cad82Slukem fi 37112d4ac0Shubertf} 38112d4ac0Shubertf 39cabb78b6Shubertfcase $0 in 40cabb78b6Shubertf*suspend) 412e7cad82Slukem $LOGGER 'Suspending...' 42112d4ac0Shubertf noise $S/KDE_Window_UnMaximize.wav 43cabb78b6Shubertf # In case some NFS mounts still exist - we don't want them to hang: 44cabb78b6Shubertf umount -a -t nfs 45cabb78b6Shubertf umount -a -f -t nfs 46cabb78b6Shubertf ifconfig $if down 4779129951Smaya sh /etc/rc.d/dhcpcd stop 482e7cad82Slukem $LOGGER 'Suspending done.' 49cabb78b6Shubertf ;; 50cabb78b6Shubertf 51cabb78b6Shubertf*standby) 522e7cad82Slukem $LOGGER 'Going to standby mode ....' 53112d4ac0Shubertf noise $S/KDE_Window_UnMaximize.wav 54cabb78b6Shubertf # In case some NFS mounts still exist - we don't want them to hang: 55cabb78b6Shubertf umount -a -t nfs 56cabb78b6Shubertf umount -a -f -t nfs 57cabb78b6Shubertf ifconfig $if down 5879129951Smaya sh /etc/rc.d/dhcpcd stop 592e7cad82Slukem $LOGGER 'Standby done.' 60cabb78b6Shubertf ;; 61cabb78b6Shubertf 62cabb78b6Shubertf*resume) 632e7cad82Slukem $LOGGER 'Resuming...' 64112d4ac0Shubertf noise $S/KDE_Startup.wav 6579129951Smaya sh /etc/rc.d/dhcpcd start 66cabb78b6Shubertf # mount /home 67cabb78b6Shubertf # mount /data 682e7cad82Slukem $LOGGER 'Resuming done.' 69cabb78b6Shubertf ;; 70cabb78b6Shubertf 71cabb78b6Shubertf*line) 72112d4ac0Shubertf # noise $S/KDE_Window_DeIconify.wav 732e7cad82Slukem $LOGGER 'Running on power line.' 742e7cad82Slukem mount -u -o atime,devmtime -A -t ffs 75112d4ac0Shubertf atactl wd0 setidle 0 76cabb78b6Shubertf ;; 77cabb78b6Shubertf 78cabb78b6Shubertf*battery) 79112d4ac0Shubertf # noise $S/KDE_Window_DeIconify.wav 802e7cad82Slukem $LOGGER 'Running on battery.' 812e7cad82Slukem mount -u -o noatime,nodevmtime -A -t ffs 82112d4ac0Shubertf atactl wd0 setidle 5 83cabb78b6Shubertf ;; 84cabb78b6Shubertf 85cabb78b6Shubertfesac 86cabb78b6Shubertf 87cabb78b6Shubertfexit 0 88