#!/bin/bash # SetFreq 0.01 -- 03.02.25 bt -- LostGeek.NET CPU_PATH="/sys/devices/system/cpu" NUM_CPUS=$(nproc) CPU_MODEL=$(grep -m 1 "model name" /proc/cpuinfo | cut -d: -f2 | sed 's/^[ \t]*//') function show_info() { echo "CPU Model: $CPU_MODEL" echo "Number of CPUs: $NUM_CPUS" echo echo "Current frequencies and governors:" for ((i=0; i [-g ] [-d] - Set frequency min/max for all CPUs" echo " setfreq -g - Set only the governor" echo " setfreq -d - Enable Dynamic Scaling. Sets the min speed, max will be bclk/turbo." echo " " echo "Governor abbreviations:" echo " performance (max), powersave (ps), schedutil (sched), ondemand (demand), userspace (user)" } function set_freq() { local FREQ=$(($1 * 1000)) # Convert MHz to KHz local MAX_FREQ=$(cat "$CPU_PATH/cpu0/cpufreq/cpuinfo_max_freq") for ((i=0; i /dev/null if [[ $DYNAMIC -eq 0 ]]; then echo "$FREQ" | sudo tee "$CPU_PATH/cpu$i/cpufreq/scaling_max_freq" > /dev/null else echo "$MAX_FREQ" | sudo tee "$CPU_PATH/cpu$i/cpufreq/scaling_max_freq" > /dev/null fi done echo "Frequency set to $1 MHz for all CPUs." } function set_governor() { local GOV=$1 case $GOV in max) GOV="performance" ;; ps) GOV="powersave" ;; sched) GOV="schedutil" ;; demand) GOV="ondemand" ;; user) GOV="userspace" ;; esac for ((i=0; i /dev/null done echo "Governor set to $GOV for all CPUs." } # Defaults DYNAMIC=0 FREQ="" GOV="" # Parse arguments while [[ $# -gt 0 ]]; do case $1 in -g) GOV=$2 shift 2 ;; -d) DYNAMIC=1 shift ;; [0-9]*) FREQ=$1 shift ;; *) show_info exit 1 ;; esac done # Execute based on provided options if [[ -z $FREQ && -z $GOV && $DYNAMIC -eq 0 ]]; then show_info elif [[ -n $FREQ ]]; then set_freq "$FREQ" fi if [[ -n $GOV ]]; then set_governor "$GOV" fi