aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/disable.cpu.turbo.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/scripts/disable.cpu.turbo.sh')
-rwxr-xr-xconfig/hypr/scripts/disable.cpu.turbo.sh63
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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage