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