summaryrefslogtreecommitdiffstats
path: root/contrib/pm-utils.handler
blob: b8cb568d7f16c1277609eeb9e74ba0d670442350 (plain)
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
70
#!/bin/bash

. /usr/lib/pm-utils/functions

[[ -f /usr/lib/network/network ]] || exit $NA
. /usr/lib/network/network

auto_resume()
{
    if checkyesno ${RESTOREPROFILES:-no}; then
        all_resume
        sleep 2
    fi
    restartservice net-auto-wireless
    restartservice net-auto-wired
    restartservice net-profiles
}

daemon_suspend_all()
{
    stopservice net-auto-wireless
    stopservice net-auto-wired
    stopservice net-profiles
}

case "$1" in
    hibernate|suspend_hybrid|suspend)
        report_notify "suspending all interfaces..."
        daemon_suspend_all
        if checkyesno "${RESTOREPROFILES:-no}"; then        
            interface_suspend all
        fi
        ;;
    thaw|resume)
        if [ -f "$STATE_DIR/interface/wlan0" ]; then
            report_notify "resuming all interfaces..."
            auto_resume wlan0
        else
            report_notify "resuming all interfaces except wireless..."
            all_resume wlan0
        fi
        ;;
    radio_off)
        report_notify "suspending wireless interface..."
        interface_suspend wlan0 no
        set_iface disabled wlan0
        bring_interface forcedown wlan0
        ;;
    radio_on)
        report_notify "resuming wireless interface..."
        auto_resume wlan0
        if [ -x /etc/pm/power.d/??wifi ]; then
            /usr/bin/on_ac_power    # this is in pm-utils
            case $? in
                0)  # on ac
                    /etc/pm/power.d/??wifi false
                    ;;
                1)  # on battery
                    /etc/pm/power.d/??wifi true
                    ;;
            esac
        fi
        ;;
    *)
        ;;
esac

exit $?

# vim: ft=sh ts=4 et sw=4: