#!/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