Turn off USB power when closing MacBook lid

12

3

I have a USB-powered cooling pad under my MacBook Pro. When I close the lid to put my MacBook to sleep, I would like the cooling pad to turn off. In other words, I would like the MacBook to cut power to the USB port that the cooling pad is plugged into, or alternatively, both USB ports. Anyone know if this is possible?

I notice that the same question has been asked for Windows 7.

Patrick J Collins

Posted 2012-06-29T21:27:47.813

Reputation: 281

Also looks like a USB power switch may solve this issue for your cooling fan always on problem https://www.adafruit.com/product/1620?gclid=CjwKCAjw7vraBRBbEiwA4WBOn6hVzZM7s35DSGYQc_0Z75t31PJkJHFCGn-d79QxaudIA0l0N3DeNxoCmCoQAvD_BwE

– MrDaniel – 2018-07-30T14:50:59.160

Answers

12

According to Apple Computers and Displays: Powering peripherals through USB the only way to turn off power to the USB ports is to turn off the Mac, power will remain while the Mac is sleeping.

If your Apple computer or display is powered off, no power will be provided.

A work around for this is changing what your Mac Does when you close the lid. You can reconfigure your MacBook to go into a different safe sleep mode when you close the lid, as opposed to normal sleep. This is very similar to the hibernate feature available for Windows PC and would result in USB power being off.

The only con is that you would have to press the power button to start your mac when you open it. And it would take more time to get the Mac back to where you left off at, as it reloads the contents of RAM from disk.

You can change your Macs sleep-mode as indicated in Set newer portable Macs' sleep mode provided by MacWorld.

Check the current setup

$ pmset -g | grep hibernatemode

which mode is which:

0 - Old style sleep mode, with RAM powered on while sleeping, safe sleep disabled, and super-fast wake.

1 - Hibernation mode, with RAM contents written to disk, system totally shut down while “sleeping,” and slower wake up, due to reading the contents of RAM off the hard drive.

3 - The default mode on machines introduced since about fall 2005. RAM is powered on while sleeping, but RAM contents are also written to disk before sleeping. In the event of total power loss, the system enters hibernation mode automatically.

5 - This is the same as mode 1, but it’s for those using secure virtual memory (in System Preferences -> Security).

7 - This is the same as mode 3, but it’s for those using secure virtual memory.

It appears that sleep mode 1 would enable your USB ports to be powered off when closing the lid of the MacBook.

Change the sleep mode setting

sudo pmset -a hibernatemode 1

MrDaniel

Posted 2012-06-29T21:27:47.813

Reputation: 1 132

Thanks @MrDaniel for this answer. On my Mac version 10.13.6, the hibernatemode should be 25 (and not 1), here is the man page of pmset:

 hibernatemode = 25 is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory.
 The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.
 – Bhavesh Agarwal  – 2019-12-17T05:36:23.263

1Thank you for a wonderfully detailed answer. I am very attached to the instant start up when I open the lid, plus I have 16 Gb of RAM which would probably take a long time to read from disk. It's less of a pain just to unplug the USB cable. – Patrick J Collins – 2012-07-31T19:05:28.637

1

I know this is a really old post, just thought this would be useful to others;

On your Mac model / macOS version, type "man pmset" in Terminal to see what the values are for your Mac - seems not all models and/or macOS versions adhere to the same numbering scheme.

hibernatemode supports values of 0, 3, or 25.

Default: hibernatemode, standby and autopoweroff are all set to 0.

hibernatemode = 0 default on desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.

hibernatemode = 3 default on portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from hibernate image.

hibernatemode = 25 is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.

On my MacPro (2013 model) both values 3 and 25 will powerdown the backlight of my (non-Apple) mouse (Logitech) and keyboard (Havit). The default settings would keep the backlights on - which can be quite annoying.

Boot time (64Gb RAM) with "hibernatemode = 3" is very fast, "hibernatemode = 25" only a fraction slower.

Hanzaplastique

Posted 2012-06-29T21:27:47.813

Reputation: 123

The high performance PCI Express based SSDs really do help close the performance gap on the loading RAM contents back from disk storage problem. – MrDaniel – 2018-07-30T14:43:32.327

0

This has been an issue tugged and shunted back and forward and no standard has been set. There are as many pros as cons to this.

Many notebooks and some new motherbaords in PC's have a lightningbolt symbol above the USB symbol indicating which USB provides power during sleep. Some notebooks provide power on the left and the right goes off.

In PC's you can go into the bios and enable/disable this feature, sometimes even select the ports.

I think in you case with the macbook.. its always on. But it could also be a possibly it only stays on because it detects that something is plugged into it. It might shut down power to that port if before sleep nothing is connected to it.

One way would be put a switch somewhere and manually handle this.. I know it sucks but you know its life. Possibly even integrate a heat switch and turn on the fans when the temp goes above 50Degrees. Then it can always be on but regulated by it self.

Sorry I could not be more specific in how to fix your problem.. There is an issue that even the same model mac books are made different hardware and firmware. You could possibly dig deeper into the firmware bootloader and see if you get into some settings.. but that could be dangerous.

Piotr Kula

Posted 2012-06-29T21:27:47.813

Reputation: 3 538

Hi, maybe adding a switch is the best solution. I'll wait to see if anyone else has a better idea before I start stripping cables. – Patrick J Collins – 2012-07-31T19:13:18.927