From 703f2e1d0ce87ffe434c41ed7c0d92a50d41e6ca Mon Sep 17 00:00:00 2001 From: lapatatedouce Date: Thu, 13 Mar 2025 13:31:54 +0100 Subject: [PATCH] add file --- miscellaneous/set_cpu_mode.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 miscellaneous/set_cpu_mode.sh diff --git a/miscellaneous/set_cpu_mode.sh b/miscellaneous/set_cpu_mode.sh new file mode 100644 index 0000000..eb7a99d --- /dev/null +++ b/miscellaneous/set_cpu_mode.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Description: +# This script allows the user to select a CPU frequency scaling governor mode. +# The governor controls the trade-off between performance and power consumption. +# Available modes typically include "performance", "powersave", "ondemand", "conservative", and "schedutil". + +# Usage: +# 1. Save this script to a file, e.g., set_cpu_mode.sh. +# 2. Make the script executable with the command: chmod +x set_cpu_mode.sh. +# 3. Run the script with: sudo ./set_cpu_mode.sh. +# 4. Follow the on-screen prompts to select the desired CPU governor mode. + +# Ask the user to choose a mode +echo "Please choose a CPU frequency scaling governor mode:" +echo "1. performance" +echo "2. powersave" +echo "3. ondemand" +echo "4. conservative" +echo "5. schedutil" +read -p "Enter the number corresponding to your choice: " choice + +# Array of available modes +modes=("performance" "powersave" "ondemand" "conservative" "schedutil") + +# Check if the choice is valid +if [[ $choice -ge 1 && $choice -le ${#modes[@]} ]]; then + selected_mode=${modes[$choice-1]} + echo "$selected_mode" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor + echo "The $selected_mode mode has been applied." +else + echo "Invalid choice. No mode was applied." +fi \ No newline at end of file