diff options
| author | Pinapelz <yukais@pinapelz.com> | 2026-03-30 21:58:55 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-03-30 21:58:55 -0700 |
| commit | 4acf85db722ebe7e019e7427436083b3b9f4959e (patch) | |
| tree | 6d5b416ad605730a6d573d1b4178c7676dc8a015 /config/hypr/scripts/disable.cpu.turbo.sh | |
| parent | 89e10cd0c0331fc727889d41e34309db1fb5735f (diff) | |
| parent | e4b9059d346e6a6dbd6216cd1fb5e41085bb6e7b (diff) | |
Merge remote-tracking branch 'upstream/main'
Diffstat (limited to 'config/hypr/scripts/disable.cpu.turbo.sh')
| -rwxr-xr-x | config/hypr/scripts/disable.cpu.turbo.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/config/hypr/scripts/disable.cpu.turbo.sh b/config/hypr/scripts/disable.cpu.turbo.sh new file mode 100755 index 00000000..dafee76b --- /dev/null +++ b/config/hypr/scripts/disable.cpu.turbo.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -euo pipefail + +require_root() { + if [[ ${EUID} -ne 0 ]]; then + exec sudo -- "$0" "$@" + fi +} + +write_sysfs() { + local path="$1" + local value="$2" + if [[ -w "$path" ]]; then + printf '%s' "$value" >"$path" + return 0 + fi + return 1 +} + +require_root "$@" + +changed=0 + +# Intel P-State turbo control +if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then + if write_sysfs /sys/devices/system/cpu/intel_pstate/no_turbo 1; then + changed=1 + fi +fi + +# Generic cpufreq boost control (AMD/Intel) +if [[ -e /sys/devices/system/cpu/cpufreq/boost ]]; then + if write_sysfs /sys/devices/system/cpu/cpufreq/boost 0; then + changed=1 + fi +fi + +# Prefer a quieter governor if available +for gov in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do + if [[ -w "$gov" ]]; then + current=$(cat "$gov") + if [[ "$current" != "powersave" ]] && grep -q powersave "${gov%/*}/scaling_available_governors"; then + printf '%s' powersave >"$gov" + changed=1 + fi + fi +done + +# Lower energy/performance preference if supported +for epp in /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference; do + if [[ -w "$epp" ]]; then + printf '%s' power >"$epp" 2>/dev/null || true + changed=1 + fi +done + +if [[ $changed -eq 1 ]]; then + echo "CPU turbo/boost disabled and power-saving preferences applied." + exit 0 +fi + +echo "No writable turbo/boost controls found. Check kernel driver support." +exit 1 |
