summaryrefslogtreecommitdiff
path: root/libre/linux-libre-tools/cpupower.pmutils
blob: fb93cd7c1274abf1cbbf89d5e3316b0f41960c31 (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
#!/bin/bash

[[ -x /usr/bin/cpupower ]] || exit $NA

CPUPOWER_GOVERNOR_AC=${CPUPOWER_GOVERNOR_AC:-ondemand}
CPUPOWER_GOVERNOR_BAT=${CPUPOWER_GOVERNOR_BAT:-conservative}

help() {
    cat <<EOF
--------
$0: Select cpupower frequency governor.

Parameters:
CPUPOWER_GOVERNOR_AC = Governor to use on AC.
Defaults to ondemand.

CPUPOWER_GOVERNOR_BAT = Governor to use on battery.
Defaults to conservative.

EOF
}

cpupow() {
  printf 'Setting cpupower frequency governor to %s...' "$1"
  cpupower -c all frequency-set -g "$1"
}

case $1 in
  true) cpupow "$CPUPOWER_GOVERNOR_BAT" ;;
  false) cpupow "$CPUPOWER_GOVERNOR_AC" ;;
  help) help;;
  *) exit $NA ;;
esac

exit 0

# vim:set ts=2 sw=2 ft=sh et: