1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/bin/sh
# pm-utils hook to handle suspend/resume properly for wicd
if [ -r "${PM_FUNCTIONS}" ]; then
. "${PM_FUNCTIONS}"
elif [ -r "${FUNCTIONS}" ]; then
. "${FUNCTIONS}"
else
# pm-utils version is too old, or something else is wrong
exit $NA
fi
RETVAL=0 # Set this to 0 initially
wicd_suspend()
{
# Put wifi interface down
%DAEMON%suspend.py 1>/dev/null 2>/dev/null
RETVAL=$?
}
wicd_resume()
{
# Bring wifi interface back up
%DAEMON%autoconnect.py 1>/dev/null 2>/dev/null
RETVAL=$?
}
case "$1" in
hibernate|suspend)
wicd_suspend
;;
thaw|resume)
wicd_resume
;;
*) exit $NA
;;
esac
# We can't return a nonzero exit code (aside from $NA, $DX, and $NX) to
# to pm-utils or the entire sleep operation will be inhibited, so...
# No matter what we do, the log prefix and message will conflict a bit.
case "$RETVAL" in
0)
exit $RETVAL
;;
1)
# Probably the daemon isn't running if this happens
echo "Unable to connect to wicd daemon - is it running?"
exit $DX
;;
2)
# This will occur if the daemon encounters an error
echo "Wicd daemon was unable to suspend the network."
exit $DX
;;
3)
# Will only be returned by autoconnect.py
# This should never happen, but just in case...
echo "Wicd daemon failed to autoconnect on resume."
exit $DX
;;
*)
echo "Unknown exit code."
exit $NA
;;
esac
|