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

๐Ÿค– Essential macOS Automation Scripts

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

๐ŸŽฏ 1. Auto-Optimize macOS Performance Daily

๐Ÿ”น Cleans junk files, flushes RAM, and empties logs every night

bash
#!/bin/bash
echo "Cleaning up system..."
sudo purge
sudo rm -rf ~/Library/Caches/*
sudo rm -rf /Library/Caches/*
sudo find /private/var/log -type f -delete
echo "Done!"

๐Ÿ“Œ How to Automate:

  • Save it as cleanup.sh
  • Make it executable: bashCopyEditchmod +x cleanup.sh
  • Schedule it using cron or LaunchAgents (for GUI-based automation).

๐Ÿ”‹ 2. Auto-Limit Battery Charge to 80% (Extends Lifespan)

๐Ÿ”น Prevents overcharging, useful for MacBooks

  • Install AlDente: cssCopyEditbrew install --cask aldente
  • Set charge limit: arduinoCopyEditdefaults write com.davidwernhart.AlDente MaxPercentage 80

๐ŸŒ 3. Auto-Connect to WiFi & Mount a Network Drive on Boot

๐Ÿ”น Useful for always-on access to a NAS or shared folder

bash
#!/bin/bash
networksetup -setairportpower en0 on
mount_afp afp://username:password@192.168.1.100/SharedFolder /Volumes/Shared

๐Ÿ“Œ How to Automate:

  1. Save as wifi_mount.sh
  2. Make executable: bashCopyEditchmod +x wifi_mount.sh
  3. Add to startup via LaunchAgents

๐Ÿ•ถ๏ธ 4. Auto-Enable Dark Mode at Sunset & Light Mode at Sunrise

๐Ÿ”น Matches macOS theme with real-world time

bash
#!/bin/bash
hour=$(date +"%H")
if [ $hour -ge 18 ] || [ $hour -lt 6 ]; then
osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true'
else
osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to false'
fi

๐Ÿ“Œ How to Automate:

  1. Save as darkmode.sh
  2. Run every hour using crontab -e: pgsqlCopyEdit0 * * * * /path/to/darkmode.sh

๐Ÿ’พ 5. Auto-Backup Important Folders to External Drive

๐Ÿ”น Syncs Documents & Desktop to an external drive every day

bash
#!/bin/bash
rsync -av --delete ~/Documents /Volumes/BackupDrive/
rsync -av --delete ~/Desktop /Volumes/BackupDrive/
echo "Backup complete!"

๐Ÿ“Œ How to Automate:

  • Add to LaunchAgents or run via cron.

๐Ÿ”ฅ 6. Auto-Close Unused Apps at Midnight

๐Ÿ”น Saves memory by closing apps like Photoshop, Chrome, etc.

bash
#!/bin/bash
apps=("Google Chrome" "Photoshop" "Slack" "Spotify")
for app in "${apps[@]}"; do
osascript -e "tell application \"$app\" to quit"
done

๐Ÿ“Œ How to Automate:

  1. Save as close_apps.sh
  2. Run every night at midnight: pgsqlCopyEdit0 0 * * * /path/to/close_apps.sh

๐Ÿš€ 7. Auto-Update Homebrew & macOS Software Weekly

๐Ÿ”น Keeps your Mac & installed apps always up-to-date

bashCopyEdit#!/bin/bash
echo "Updating Homebrew..."
brew update && brew upgrade && brew cleanup
echo "Updating macOS..."
sudo softwareupdate -ia

๐Ÿ“Œ How to Automate:

  • Run this every Sunday at 3 AM: pgsqlCopyEdit0 3 * * 7 /path/to/update.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 & PerformanceVirtualization & Hypervisors

Post navigation

Previous post
Next post

Related Posts

macOS GUI-based automation using Shortcuts, Automator, and Hammerspoon! ๐Ÿš€

March 30, 2025April 2, 2025

๐Ÿ”น 1. macOS Shortcuts for Quick Automation (Best for GUI-Based Tasks) ๐ŸŽฏ A. Auto-Enable Focus Mode When Opening Specific Apps ๐Ÿ”น Example: Turn on “Gaming Focus” when Steam is launched. 1๏ธโƒฃ Open Shortcuts โ†’ Click New Shortcut2๏ธโƒฃ Add “Open App” โ†’ Select Steam3๏ธโƒฃ Add “Set Focus Mode” โ†’ Choose Gaming…

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

Maximize gaming FPS, optimize external displays, and extend battery life on macOS! ๐Ÿš€

March 30, 2025April 2, 2025

๐ŸŽฎ Advanced Gaming Performance Tweaks 1. Unlock Max CPU & GPU Power for Gaming By default, macOS balances power efficiency over performance. These tweaks prioritize speed: A. Enable High Performance Mode (For M1/M2/M3 MacBooks) B. Disable CPU Power Throttling (Intel Macs Only) C. Set CPU Performance to Turbo Mode (Intel…

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 }