I have a friend who wants his connections (WiFi, Bluetooth, ext...) to turn off when his lid is closed. He doesn't want to change a lot of settings (sleep mode, turning it off manually ...).

Is there a simple way to do this through macOS System Preferences? Or a way with some program?

  • Firstly, welcome to Ask Different! :) I hope you come to find this site has a lot to offer! In case you haven't already, it's worth taking the time to read the tour. All the best with your question!
    – Monomeeth
    Aug 7, 2019 at 22:51

4 Answers 4


You could install blueutil and SleepWatcher via homebrew and set a .sleep code to call blueutil in order to disable bluetooth and call "networksetup -setairportpower en0 off" to disable wifi when going to sleep mode or closing the lid.

Blueutil comands are "/usr/local/bin/blueutil -p 0" to disable bluetooth and blueutil -p 1 to enable it.

To use SleepWatcher, make a shell script in your home directory named .sleep and give it permission with the chmod command.

You also can do a .wake code to enable back connections when waking up the mac.

You can find out how to use sleepwatcher here

  • 1
    You can do all of this with Keyboard Maestro too, if you prefer a GUI tool. You can have Keyboard Maestro call blueutil and networksetup to control your Bluetooth and AirPort. However, the first thing to do is make sure that “Enable Power Nap” is OFF in System Preferences under Energy Saver.
    – TJ Luoma
    Aug 21, 2019 at 21:22


I wrote this script after reading the comments here. Hope it helps someone!

  • I would like to appreciate the script built by Patrick Kantorski, it is amazing! There seems to be one issue with the automatic installer, towards the end it actually disables wi-fi before finishing the process and then gives two lines of errors as it cannot reach the server of Homebrew. But I managed to install it manually. Maybe a quick update of the installer will make it work automatically.
    – nevrozel
    Jan 5, 2021 at 7:35

Would logging out after 5(minimum) minutes of activity work? This can be done in Security and Privacy-> Advanced.

Since both are single toggle methods, disable power nap in energy saver preferences.

  • This does not answer the question. Loging out will close and end all applications and opened documents. The question is specific about not turning off [which is almost the same of logging out from the point of terminating the user applications] and the questinon is specific about WHEN he closes the Lid, so it is not automatic independent from the user control, it is the oposite: is JUST when the user make the ACT of closing the lid.
    – Prado
    Aug 9, 2019 at 22:33
  • Thanks for the feedback @parado! I am awaiting OP's response over the same too. That's why I ask it as a question. Also, second para achieves what question needs right? Or I am at fault there too? For the "just" of the lid, better if something like AppleScript can be used or third part app for the same. Again, to be specified by OP.
    – anki
    Aug 10, 2019 at 5:41
  • Hi, my comment is a positive comment, I don't know for sure you are in fault, but you post it as a answer and I think it should be posted as a comment, your suggestion is good, it just don't fit exactly the OP question as an answer. Also I am new here, and for my understanding we should only post answer if it really fits the question, but as I said, I am not sure. Your comment is going to make me read the rules again, which is good for me to enforce my understanding of the rules for answers and comments. Keep the answer, lets wait for the OP response.
    – Prado
    Aug 10, 2019 at 10:10
  • I dont listed see what Mac you have. But I have a HP laptop that has a button for airplane mode. When I want to disconnect before I close the lid, I just hit that. Done, no connections. When I come back I open the lid and hit the button again to reconnect and thats it. Maybe the Mac has a simple airplane mode button?
    – Stumped
    Aug 21, 2019 at 18:46
  • @Stumped I am not aware of that button. Would love to have/know about it.
    – anki
    Aug 21, 2019 at 18:47

See what I was saying above in comments. I don't have a Mac and do not know if they have it, but I have an HP laptop with airplane mode button on it. When I want to disconnect before I close the lid, I just hit that. Done, no connections. When I come back I open the lid and hit the button again to reconnect and thats it. Maybe the Mac has a simple airplane mode button? You could check and look for it. On the laptop, it is an arrow icon on F12 key.

  • The OP specifically states that they have a Mac. I don't think a speculative answer from someone who doesn't own a Mac is helpful.
    – quanticle
    Dec 17, 2021 at 21:21

You must log in to answer this question.

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