File: intel-audio-powersave

package info (click to toggle)
pm-utils 1.4.1-9
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,320 kB
  • sloc: sh: 3,032; xml: 1,035; makefile: 175; ansic: 152
file content (37 lines) | stat: -rw-r--r-- 870 bytes parent folder | download | duplicates (6)
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
#!/bin/sh

# Allow the driver to put the audio hardware to sleep
# once the driver has been inactive for a second.
# This hook should work with at least the ac97 and hda codecs.

INTEL_AUDIO_POWERSAVE=${INTEL_AUDIO_POWERSAVE:-true}

help() {
cat <<EOF
--------
$0: Intel Audio powersave parameters.

This hook has 1 tuneable parameter. 
INTEL_AUDIO_POWERSAVE = controls whether we will try to save power on battery.
Defaults to true.

EOF
}

audio_powersave() {
    [ "$INTEL_AUDIO_POWERSAVE" = "true" ] || exit $NA
    for dev in /sys/module/snd_*; do
	[ -w "$dev/parameters/power_save" ] || continue
	printf "Setting power savings for %s to %d..." "${dev##*/}" "$1"
	echo $1 > "$dev/parameters/power_save" && echo Done. || echo Failed.
    done
}

case $1 in
    true) audio_powersave 1 ;;
    false) audio_powersave 0 ;;
    help) help;;
    *) exit $NA
esac

exit 0