🎛 1. Auto-Switch Between Internal & eGPU (Intel Macs)
🔹 Forces macOS to switch to eGPU when plugged in, and back to internal when unplugged.
bash#!/bin/bash
EXTERNAL_GPU=$(system_profiler SPDisplaysDataType | grep "eGPU" | wc -l)
if [ "$EXTERNAL_GPU" -gt 0 ]; then
echo "eGPU detected! Switching to high-performance mode..."
sudo pmset -a gpuswitch 0 # Use dedicated GPU
else
echo "No eGPU detected. Switching to power-saving mode..."
sudo pmset -a gpuswitch 2 # Use integrated GPU
fi
📌 How to Automate:
- Save as
egpu_switch.sh
, then make it executable: bashCopyEditchmod +x egpu_switch.sh
- Schedule it to run every 10 minutes using
crontab -e
: rubyCopyEdit*/10 * * * * /path/to/egpu_switch.sh
❄️ 2. Auto-Control Mac Fans Based on Temperature (Intel Macs)
🔹 Prevents overheating while gaming or using eGPU
1️⃣ Install smcFanControl
CLI:
nginxbrew install smcfancontrol
2️⃣ Create a script to adjust fan speed:
bash#!/bin/bash
CPU_TEMP=$(istats cpu temp | grep -Eo '[0-9]+')
if [ "$CPU_TEMP" -ge 75 ]; then
echo "High CPU temp detected ($CPU_TEMP°C)! Increasing fan speed..."
smcFanControl -s 5000
elif [ "$CPU_TEMP" -le 50 ]; then
echo "Low CPU temp detected. Reducing fan speed..."
smcFanControl -s 2000
else
echo "Temperature normal ($CPU_TEMP°C). Keeping default fan speed."
fi
📌 How to Automate:
- Save as
fan_control.sh
and schedule it every 5 minutes: rubyCopyEdit*/5 * * * * /path/to/fan_control.sh
🤖 3. Auto-Enable AI Workflows (ChatGPT, Stable Diffusion, Whisper AI)
🔹 Detects if AI tasks (like ChatGPT or Stable Diffusion) are running, and optimizes CPU/GPU usage.
1️⃣ Install Dependencies (Python required for AI tasks):
nginxbrew install python
pip install torch torchvision torchaudio
2️⃣ Create an AI workload monitor script:
bash#!/bin/bash
AI_PROCESSES=("python" "stable-diffusion" "whisper")
for process in "${AI_PROCESSES[@]}"; do
if pgrep -x "$process" > /dev/null; then
echo "AI workload detected ($process running). Boosting performance..."
sudo pmset -a gpuswitch 0 # Force high-performance GPU
sudo renice -20 -p $(pgrep -x "$process") # Give AI tasks highest priority
break
else
echo "No AI workload detected. Running in normal mode."
sudo pmset -a gpuswitch 2 # Use integrated GPU
fi
done
📌 How to Automate:
- Save as
ai_boost.sh
and schedule it to check every 5 minutes: rubyCopyEdit*/5 * * * * /path/to/ai_boost.sh
🖥 4. Auto-Switch Display Resolution for Gaming vs. Work
🔹 Switches to 1080p for gaming and back to 4K for work.
bash#!/bin/bash
if pgrep -x "Steam" > /dev/null || pgrep -x "Lutris" > /dev/null; then
echo "Gaming detected! Switching to 1080p for performance..."
cscreen -x 1920 -y 1080
else
echo "No gaming detected. Switching back to 4K."
cscreen -x 3840 -y 2160
fi
📌 How to Automate:
- Install
cscreen
: nginxCopyEditbrew install cscreen
- Run every 5 minutes: rubyCopyEdit
*/5 * * * * /path/to/display_switch.sh
🔋 5. Auto-Optimize Battery Life for MacBook Gaming & Performance
🔹 Switches to battery-saving mode when unplugged, performance mode when charging.
bash#!/bin/bash
BATTERY_STATUS=$(pmset -g batt | grep -o "AC Power")
if [ "$BATTERY_STATUS" == "AC Power" ]; then
echo "MacBook is plugged in. Boosting performance..."
sudo pmset -b gpuswitch 0 # Use high-performance GPU when charging
sudo pmset -b dps 0 # Disable CPU throttling
else
echo "MacBook is on battery. Switching to power-saving mode..."
sudo pmset -b gpuswitch 2 # Use integrated GPU when on battery
sudo pmset -b dps 1 # Enable CPU throttling to save power
fi
📌 How to Automate:
- Run every 5 minutes: rubyCopyEdit
*/5 * * * * /path/to/battery_mode.sh