summaryrefslogtreecommitdiff
path: root/pm/power.d/wireless
blob: eb0f02e6b3786f4a1282e9e4aa2bd68e471db52c (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
#!/bin/sh

[ -x /sbin/iwconfig ] || exit $NA

# This hook is very generic and only works on wireless hardware that 
# iwconfig can actually configure power settings on.  Sadly, this misses
# some more popular cards *cough* iwlwifi *cough*.

# Better heuristics and better control for specific cards
# would be welcome.

wireless_powersave() {
    case $1 in
	on) iwparams="txpower auto power on" ;;
	off) iwparams="txpower auto power off" ;;
	*) exit $NA ;;
    esac
    cd /sys/class/net
    for dev in *; do
	[ -w "${dev}/wireless" ] || continue
	/sbin/iwconfig $dev $iwparams
    done
}

case $1 in
    true) wireless_powersave on ;;
    false) wireless_powersave off ;;
    *) exit $NA ;;
esac

exit 0