Skip to content

Instantly share code, notes, and snippets.

@trvswgnr
Last active August 5, 2020 17:41
Show Gist options
  • Save trvswgnr/e9f317c2dc4ab923b0fc7202cb989b93 to your computer and use it in GitHub Desktop.
Save trvswgnr/e9f317c2dc4ab923b0fc7202cb989b93 to your computer and use it in GitHub Desktop.
Set MacOS low storage notification limit.
#!/usr/bin/env bash
if [[ -z $1 ]]; then
echo 'Please set a disk space limit to trigger the low disk space warning'
exit 1;
else
LIMIT=$1
fi
defaults write com.apple.diskspaced minFreeSpace $LIMIT
echo "Low disk space warning limit set to $LIMIT"
if [[ $(csrutil status) == "System Integrity Protection status: enabled." ]]; then
killall diskspaced
echo 'System Integrity Protection is enabled. Killed diskspaced daemon to suppress warning, restart for new limit to take effect.'
else
launchctl unload -w /System/Library/LaunchAgents/com.apple.diskspaced.plist
launchctl load -w /System/Library/LaunchAgents/com.apple.diskspaced.plist
echo 'Restarted diskspaced daemon, new limit should take effect immediately.'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment