| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | set -eu |
| 3 | |
| 4 | usagescip-shell shell shell-project 0.0.0 usage().() { |
| 5 | generators="$1" |
| 6 | # example: USAGE: ./governor.sh <performance|powersave> |
| 7 | echoscip-shell system . . echo. "USAGE: $0 <$(echoscip-shell system . . echo. "$generators" | trscip-shell system . . tr. ' ' '|')>" |
| 8 | exit 111 |
| 9 | } |
| 10 | |
| 11 | |
| 12 | for cpu in "/sys/devices/system/cpu/cpu"[0-9]* ; do |
| 13 | if grepscip-shell system . . grep. -vq '^1$' "$cpu/online" 2>/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 14 | continue |
| 15 | fi |
| 16 | if [scip-shell system . . `[`. ! -e "$cpu/cpufreq/scaling_available_governors" ]; then |
| 17 | continue |
| 18 | fi |
| 19 | generators="$(catscip-shell system . . cat. "$cpu/cpufreq/scaling_available_governors")" |
| 20 | if [scip-shell system . . `[`. "$#" -eq 0 ] || [scip-shell system . . `[`. -z "$1" ]; then |
| 21 | usagescip-shell shell shell-project 0.0.0 usage(). "$generators" |
| 22 | elif (echoscip-shell system . . echo. -n "$generators" | trscip-shell system . . tr. ' ' '\n' | grepscip-shell system . . grep. -q "^$1\$" 2>/dev/nullscip-shell filesystem . . `/dev/null`.); then |
| 23 | if grepscip-shell system . . grep. -vq "^$1\$" "$cpu/cpufreq/scaling_governor" 2>/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 24 | echoscip-shell system . . echo. "$1" > "$cpu/cpufreq/scaling_governor" |
| 25 | fi |
| 26 | else |
| 27 | usagescip-shell shell shell-project 0.0.0 usage(). "$generators" |
| 28 | fi |
| 29 | done |