7

I want to turn off my MacBook's Wi-Fi automatically when closing its lid. Is there any software can do this?

I have a battery drain problem. When Wi-Fi is enabled and I close the lid, my MacBook will periodically wake overnight, draining battery.

I have done ton of research and tried many methods. Turning off the Wi-Fi before closing the lid is the only way to guarantee that my MacBook will not wake. But, well, it is annoying to disable Wi-Fi every time. So I need a script or other software to do this job.

  • 3
    See this post for important guidelines that should be followed when asking for a hardware/software recommendation. It will help everyone by preventing unnecessary answers for items that don't fit your request. – fsb Apr 13 '17 at 15:27
7

You could combine DFGKApps's script for turning off Wifi and DssW's Power Manager to run the script on sleep.

The Terminal.app command to disable WiFi appears to be:

 networksetup -setairportpower en1 off

To re-enable WiFi use:

networksetup -setairportpower en1 on

Be sure to test these commands using Terminal.app, as I suspect they may require tweaking depending on your network set up.

Be aware that running a script on sleep does come with limitations. The time available for the script is short and can not be extended.

I am a software engineer involved with Power Manager, so feel free to ask technical questions about how to use it.

  • 1
    That's exactly what I'm looking for! Thank! I can't upvote your answer as I don't have enough privilege, sorry. – Jack JackGuRae Apr 13 '17 at 17:16
  • I have done further research. Controlplane is a cheaper way to run script on Apple Event. – Jack JackGuRae Apr 14 '17 at 4:34
2

Have you tried your Energy Saver preferences?

  1. Go to System Preferences
  2. Click on "Energy Saver"
  3. On the "Battery" tab, make sure "Enable Power Nap while on battery power" is unchecked. That should stop it from checking emails while in sleep mode.
  4. While you're at it, if you don't want it to connect to WiFi at all while sleeping, go to "Power Adapter" and uncheck "Wake for Wi-Fi network access" and "Enable Power Nap" there too.
  5. To further save power, you could also (on the Battery tab) check "Put hard disks to sleep when possible". That should help with battery drain - but it's unrelated to WiF-i.

You may have found and discounted that solution already, but if you let us know what other solutions you've tried, it might help to pin it down.

  • 1
    I have tried all you've suggested, really. Sometime it works, sometime it doesn't. – Jack JackGuRae Apr 13 '17 at 17:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .