summaryrefslogtreecommitdiffstats
path: root/helperscripts/wlan-ps-toggle
blob: 695bc4630c86b150fb9f2d18529e539226478c48 (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
#!/bin/sh
set -e

dev=wlan0
[ $# -ge 1 ] && dev="$1"

msg()
{
	local text="$*"
	echo "$text"
	zenity --info --timeout=1 --title="WLAN power saving" \
		--text="$text" || true
}

ps_is_on()
{
	[ "$(iw dev "$dev" get power_save | cut -d':' -f2 | tr -d ' ')" = on ]
}

ps_enable()
{
	iw dev "$dev" set power_save on
	msg "Turned $dev power saving ON"
}

ps_disable()
{
	iw dev "$dev" set power_save off
	msg "Turned $dev power saving OFF"
}

ps_is_on && ps_disable || ps_enable
bues.ch cgit interface