From 3eb500b11a3faf768cf96fd6034141eff6ffa83c Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Fri, 15 Sep 2017 16:27:58 -0400 Subject: Update etc scripts to include governor It needs to be in performance, not powersave, to work well on my machine. While we're at it, also have the scripts print usage if you pass no arguments, rather than giving an error message about $1 being unset. --- etc/governor.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 etc/governor.sh (limited to 'etc/governor.sh') diff --git a/etc/governor.sh b/etc/governor.sh new file mode 100755 index 000000000..caabb9da8 --- /dev/null +++ b/etc/governor.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -eu + +usage() { + generators="$1" + echo "USAGE: $0 <$(echo "$generators" | tr ' ' '|')>" + exit 111 +} + + +for cpu in "/sys/devices/system/cpu/cpu"[0-9]* ; do + if grep -vq '^1$' "$cpu/online" 2>/dev/null; then + continue + fi + generators="$(cat "$cpu/cpufreq/scaling_available_governors")" + if [ "$#" -eq 0 ] || [ -z "$1" ]; then + usage "$generators" + elif (echo -n "$generators" | tr ' ' '\n' | grep -q "^$1\$" 2>/dev/null); then + if grep -vq "^$1\$" "$cpu/cpufreq/scaling_governor" 2>/dev/null; then + echo "$1" > "$cpu/cpufreq/scaling_governor" + fi + else + usage "$generators" + fi +done -- cgit v1.2.3