]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/apmd/apmd-3.2.2/apmd_proxy
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / apmd / apmd-3.2.2 / apmd_proxy
1 #!/bin/sh
2
3 # apmd_proxy - program dispatcher for APM daemon
4 #
5 # Written by Craig Markwardt (craigm@lheamail.gsfc.nasa.gov) 21 May 1999
6 # Modified for Debian by Avery Pennarun
7 #
8 # This shell script is called by the APM daemon (apmd) when a power
9 # management event occurs.  Its first and second arguments describe the
10 # event.  For example, apmd will call "apmd_proxy suspend system" just
11 # before the system is suspended.
12 #
13 # Here are the possible arguments:
14 #
15 # start              - APM daemon has started
16 # stop               - APM daemon is shutting down
17 # suspend critical   - APM system indicates critical suspend (++)
18 # suspend system     - APM system has requested suspend mode
19 # suspend user       - User has requested suspend mode
20 # standby system     - APM system has requested standby mode 
21 # standby user       - User has requested standby mode
22 # resume suspend     - System has resumed from suspend mode
23 # resume standby     - System has resumed from standby mode
24 # resume critical    - System has resumed from critical suspend
25 # change battery     - APM system reported low battery
26 # change power       - APM system reported AC/battery change
27 # change time        - APM system reported time change (*)
28 # change capability  - APM system reported config. change (+)
29 #
30 # (*) - APM daemon may be configured to not call these sequences
31 # (+) - Available if APM kernel supports it.
32 # (++) - "suspend critical" is never passed to apmd from the kernel,
33 #   so we will never see it here.  Scripts that process "resume
34 #   critical" events need to take this into account.
35 #
36 # It is the proxy script's responsibility to examine the APM status
37 # (via /proc/apm) or other status and to take appropriate actions.
38 # For example, the script might unmount network drives before the
39 # machine is suspended.
40 #
41 # In Debian, the usual way of adding functionality to the proxy is to
42 # add a script to /etc/apm/event.d.  This script will be called by
43 # apmd_proxy (via run-parts) with the same arguments.
44 #
45 # If it is important that a certain set of script be run in a certain
46 # order on suspend and in a different order on resume, then put all
47 # the scripts in /etc/apm/scripts.d instead of /etc/apm/event.d and
48 # symlink to these from /etc/apm/suspend.d, /etc/apm/resume.d and
49 # /etc/apm/other.d using names whose lexicographical order is the same
50 # as the desired order of execution.
51 #
52 # If the kernel's APM driver supports it, apmd_proxy can return a non-zero
53 # exit status on suspend and standby events, indicating that the suspend
54 # or standby event should be rejected.
55 #
56 # *******************************************************************
57
58 set -e
59
60 # The following doesn't yet work, because current kernels (up to at least
61 # 2.4.20) do not support rejection of APM events.  Supporting this would
62 # require substantial modifications to the APM driver.  We will re-enable
63 # this feature if the driver is ever modified.       -- cph@debian.org
64 #
65 #SUSPEND_ON_AC=false
66 #[ -r /etc/apm/apmd_proxy.conf ] && . /etc/apm/apmd_proxy.conf
67 #
68 #if [ "${SUSPEND_ON_AC}" = "false" -a "${2}" = "system" ] \
69 #       && on_ac_power >/dev/null; then
70 #    # Reject system suspends and standbys if we are on AC power
71 #    exit 1  # Reject (NOTE kernel support must be enabled)
72 #fi
73
74 if [ "${1}" = "suspend" -o "${1}" = "standby" ]; then
75     run-parts -a "${1}" -a "${2}" /etc/apm/event.d
76     if [ -d /etc/apm/suspend.d ]; then
77         run-parts -a "${1}" -a "${2}" /etc/apm/suspend.d
78     fi
79 elif [ "${1}" = "resume" ]; then
80     if [ -d /etc/apm/resume.d ]; then
81         run-parts -a "${1}" -a "${2}" /etc/apm/resume.d
82     fi
83     run-parts -a "${1}" -a "${2}" /etc/apm/event.d
84 else
85     run-parts -a "${1}" -a "${2}" /etc/apm/event.d
86     if [ -d /etc/apm/other.d ]; then
87         run-parts -a "${1}" -a "${2}" /etc/apm/other.d
88     fi
89 fi
90
91 exit 0