Skip to content

richelo/MBP_WiFi_Lid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

MacBook Lid Monitor

This script automatically manages WiFi and Bluetooth based on your MacBook's lid state, but only when running on battery power. When plugged into power, the script won't make any changes.

Features

  • Automatically disables WiFi and Bluetooth when closing the lid (on battery power)
  • Automatically enables WiFi and Bluetooth when opening the lid (on battery power)
  • Does nothing when the MacBook is plugged into power
  • Minimal battery impact (checks status every 2 seconds)

Requirements

  • MacOS
  • Homebrew (for installing blueutil)
  • blueutil (will be automatically installed if missing)

Installation

  1. Make the script executable:
chmod +x monitor_lid.sh
  1. Run the script:
./monitor_lid.sh

Running in the Background

To run the script in the background, you can use:

nohup ./monitor_lid.sh &

To stop the script, find its process ID and kill it:

ps aux | grep monitor_lid.sh
kill <PID>

Auto-start at Boot

To make the script start automatically when your Mac boots:

  1. Copy the LaunchAgent plist to your user's LaunchAgents directory:
cp com.user.lidmonitor.plist ~/Library/LaunchAgents/
  1. Load the LaunchAgent:
launchctl load ~/Library/LaunchAgents/com.user.lidmonitor.plist

The script will now automatically start when you log in. You can check the logs at:

  • lidmonitor.log for standard output
  • lidmonitor.error.log for any error messages

To stop the auto-start:

launchctl unload ~/Library/LaunchAgents/com.user.lidmonitor.plist

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages