Skip to content
Tech Master Tech Master

OneStopTechnical Forum

  • Books
  • AI
  • Networking
  • Windows
  • Linux
  • Cloud
  • Mac
  • Active Directory
  • Azure
  • Cloud
  • Exchange
  • M365
  • Server 2025
  • Storage
  • Vsphere
  • Website
  • Database
  • Security
  • Knowledge Base
  • VPN
Tech Master
Tech Master

OneStopTechnical Forum

🤖 Advanced macOS Automation Scripts

blog.payperitem.com, March 30, 2025April 2, 2025

🎛 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:

nginx
brew 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):

nginx
brew 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

Mac #Azure#BSOD#CentOS#CloudComputing#CloudHosting#Colocation#CyberSecurity#CyberSecurity #WindowsSecurity #PrivacyMatters #Firewall #EndpointSecurity#DataCenter#DDoSProtection#DebianServer#DedicatedServer#DirectX#ESXi#FibreChannel#Firewall#GameOptimization#HyperV#IntrusionDetection#iSCSI#ITInfrastructure#ITPro#KVM#LinuxServer#ManagedHosting#NASStorage#Networking#NVMe#PCGaming#PCIssues#PowerShell#Proxmox#RAID#RedHat#SANStorage#Server#ServerRoom#ServerSecurity#SIEM#SSDServers#SysAdmin#SysAdminLife#TaskScheduler#TechSupport#UbuntuServer#VMware#VPSHosting#vSAN#vSphere#WindowsAutomation#WindowsDebugging#WindowsFix#WindowsGaming#WindowsServerEnterprise & HostingSecurity & MonitoringStorage & Performance

Post navigation

Previous post
Next post

Related Posts

eGPU setups, deep Terminal hacks, macOS customization, and automation scripts.

March 30, 2025April 2, 2025

🔥 eGPU Setup on macOS (For Intel & Apple Silicon Macs) 1. Check If Your Mac Supports eGPU 2. Best eGPU Enclosures for macOS 3. Install & Enable eGPU on macOS A. For macOS Catalina & Big Sur (Intel Macs) B. For macOS Monterey & Ventura (Intel Macs) C. eGPU…

Read More

Battery optimization, external display tweaks, and gaming performance boosts to make your Mac experience even better!

March 30, 2025April 2, 2025

🔋 Battery Optimization Tweaks 🖥 External Display Tweaks 🎮 Gaming Performance Boosts Want specific tweaks for gaming FPS boost, external display calibration, or more battery hacks? Let me know! 🚀 4o You said: tweaks for gaming FPS boost, external display calibration, or more battery hacks ChatGPT said: Here are some…

Read More

🔥 Hidden macOS Tweaks & Hacks

March 30, 2025April 2, 2025

🎛 System Performance Boosters 1. Reduce WindowServer Lag (Smoother Animations & Faster UI) The WindowServer process handles macOS graphics, and too many UI effects slow it down.Fix it by disabling unnecessary effects: 2. Unlock Pro-Level CPU & GPU Performance A. Disable macOS CPU Throttling for Maximum Speed csssudo pmset -a…

Read More

Recent Posts

  • List of AD Schema Versions
  • OldNewExplorer Free Download For Windows 11, 10, 8 and 7 [Latest Version]
  • How to Get the Classic (old) Context Menu on Windows 11
  • BitLocker Recovery Keys
  • Active Directory and Server hardening

Recent Comments

No comments to show.
June 2025
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« May    
Log in
©2025 Tech Master | WordPress Theme by SuperbThemes
  • Login
  • Sign Up
Forgot Password?
Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.
body::-webkit-scrollbar { width: 7px; } body::-webkit-scrollbar-track { border-radius: 10px; background: #f0f0f0; } body::-webkit-scrollbar-thumb { border-radius: 50px; background: #dfdbdb }