Skip to content

Instantly share code, notes, and snippets.

@felipealfonsog
Created January 15, 2025 07:05
Show Gist options
  • Save felipealfonsog/b6156ad349bf330d7aec71d12dcf3007 to your computer and use it in GitHub Desktop.
Save felipealfonsog/b6156ad349bf330d7aec71d12dcf3007 to your computer and use it in GitHub Desktop.
A comprehensive optimization script for Intel processors (i1 to i9) designed to enhance thermal management, power efficiency, and performance on laptops and Macs.
#!/bin/bash
# Program: IntelOptimizer
# Description: Optimizes thermal management, power efficiency, and performance for Intel processors (i1 to i9).
# Author: Felipe Alfonso Gonzalez - github.com/felipealfonsog
# Check if the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (sudo)." >&2
exit 1
fi
# Detect if the processor is Intel
if ! grep -q "GenuineIntel" /proc/cpuinfo; then
echo "This script is designed for Intel processors only." >&2
exit 1
fi
# Detect if the system is a laptop or Mac
is_laptop=false
is_mac=false
if [[ -d "/sys/class/power_supply/BAT0" ]]; then
is_laptop=true
elif [[ "$(uname)" == "Darwin" ]]; then
is_mac=true
fi
# Confirm system type
if $is_mac; then
echo "Mac detected. Configuring for macOS..."
elif $is_laptop; then
echo "Intel laptop detected. Configuring for laptop optimization..."
else
echo "Desktop with Intel processor detected. Configuring for desktop optimization..."
fi
echo "Updating the system..."
pacman -Syu --noconfirm
echo "Installing Intel microcode..."
pacman -S --noconfirm intel-ucode
# Install common tools for all Intel systems
echo "Installing common tools for Intel optimization..."
pacman -S --noconfirm \
lm_sensors \
fancontrol \
cpupower \
thermald \
powertop \
stress-ng \
sysstat \
intel-gpu-tools \
i7z \
htop \
bpytop \
glances \
inxi \
dmidecode \
lshw \
gnome-system-monitor
# Laptop-specific configurations
if $is_laptop; then
echo "Installing additional tools for laptops..."
pacman -S --noconfirm \
tlp tlp-rdw \
undervolt
echo "Setting up TLP for power management..."
systemctl enable tlp
systemctl start tlp
echo "Configuring undervolt for power savings..."
cat <<EOF > /etc/undervolt.conf
[undervolt]
core: -100
cache: -100
gpu: -50
uncore: -50
analogio: 0
EOF
systemctl enable undervolt
systemctl start undervolt
echo "Configuring cpupower for laptops..."
cpupower frequency-set -g powersave
fi
# macOS-specific message
if $is_mac; then
echo "NOTE: For macOS, this script provides limited functionality. Use tools like Intel Power Gadget for monitoring."
exit 0
fi
# Sensors setup
echo "Configuring hardware sensors..."
yes | sensors-detect --auto
systemctl enable lm_sensors
systemctl start lm_sensors
# Fancontrol setup
echo "Setting up fancontrol for temperature-based fan speed adjustment..."
cat <<EOF > /etc/fancontrol
# Fancontrol configuration
INTERVAL=10
DEVPATH=hwmon1/device
DEVNAME=hwmon1
FCTEMPS=hwmon1/pwm1=hwmon1/temp1_input
FCFANS=hwmon1/pwm1=hwmon1/fan1_input
MINTEMP=30
MAXTEMP=70
MINSTART=150
MINSTOP=100
EOF
systemctl enable fancontrol
systemctl start fancontrol
# Enable thermald
echo "Enabling Thermald for thermal management..."
systemctl enable thermald
systemctl start thermald
# Powertop optimizations
echo "Applying power optimizations with PowerTOP..."
powertop --auto-tune
# Final message
echo "Optimization complete!"
echo "Installed tools:"
echo " - lm_sensors: Hardware monitoring"
echo " - fancontrol: Fan speed management"
echo " - powertop: Power optimization"
echo " - cpupower: CPU frequency scaling"
echo " - thermald: Thermal management"
if $is_laptop; then
echo " - tlp: Laptop power management"
echo " - undervolt: Voltage tuning"
fi
if $is_mac; then
echo "NOTE: For macOS, only limited features are supported."
fi
echo "Please reboot your system to apply all configurations."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment