28

At home, I run my MacBook in clamshell mode (closed lid, external display).

This works fine when you're connected to the power adapter, but it doesn't work when running on battery. That's how it's supposed to be and Apple has some kb entry on the issue. But it's also lame.

You can prevent the machine from sleeping when closed by running InsomniaX, but then it'll assume the builtin display is still active, so you end up with a two-display setup when you really only want the external. This is obviously less than ideal.

So, is there any work around, hack, utility, black magic that I can use to make it run in clamshell mode while strictly on battery power?

Also, bonus points for a solution that makes the AC status not affect the machine state at all. (Like, you know, it does normally, when not in clamshell.)

1
  • 5
    +1 just for "But it's also lame." Commented Jul 31, 2009 at 2:49

3 Answers 3

6

This page suggests a workaround:

  1. Set the display mode to mirroring (use the F7 button).
  2. If you haven't done so already, attach the external screen, keyboard and mouse.
  3. Press a key on the keyboard (like Shift) and click the mouse once.
  4. Close the lid and wait for the Macbook to go to sleep.
  5. While sleeping, click the external mouse once, the Macbook will wake up.

If all goes well, the external screen will display the Dock and menu-bar after a few seconds. As soon as you see this, the Apple logo on the Macbook shouldn't light up, open the lid of the Macbook. The Macbook won't go to sleep, won't power up its built-in screen and you can now use clamshell mode in lid-open mode.

EDIT: See comments on this post for kch's experiences with this method.

6
  • I'll test this. I suppose if you later activate InsomniaX, you'd be able to close the lid.
    – kch
    Commented Jul 31, 2009 at 4:26
  • 2
    Well, this is totally convoluted, random, tricky, unintuitive, un-mac-like, but it worked.
    – kch
    Commented Jul 31, 2009 at 4:51
  • Also, using InsomniaX worked. I did the steps as described, after that loaded and enabled InsomniaX and closed the lid. And here I am typing this comment, with external screen in lovely full resolution.
    – kch
    Commented Jul 31, 2009 at 4:52
  • Well, this does seem to be the only way. I'm accepting this answer, would appreciate if you could update it with my InsomniaX comment.
    – kch
    Commented Aug 10, 2009 at 17:12
  • maybe things have changed in the four years since this was posted, or maybe I'm doing something wrong, but this isn't working for me...
    – Kip
    Commented Sep 7, 2013 at 18:56
12

Lucas Fais's answer about Amphetamine is great, but if you don't trust third party apps, or don't want to support something called "Amphetamine"... Below you will find a fully-native way to do this on a Mac without any third party apps.

It takes like 5 minutes to set up (all steps below), and let's you enable an intelligent No Sleep Mode with just a single click. No other menus, no fiddling around, no third party security threats. It just does exactly what it needs, nothing more, nothing less.

Steps:

  1. Open Terminal.app and run these 5 commands to create the script files and set their permissions:
mkdir ~/Desktop/PauseSleep
echo "" > ~/Desktop/PauseSleep/DontSleep.myscript
chmod 755 ~/Desktop/PauseSleep/DontSleep.myscript
echo "" > ~/Desktop/PauseSleep/Sleep.myscript
chmod 755 ~/Desktop/PauseSleep/Sleep.myscript
  1. Go to Desktop > PauseSleep and double click on DontSleep.myscript. This will ask you what application to open the file with: Choose Utilities > Terminal.app. (This step is important because it will later let you click-to-run your script.)

  2. Now, right click DontSleep.myscript and choose Open With > Other > TextEdit.app so we can edit the file. Simply copy-and-paste all the following code into the file. That's it. No fiddling required.

# Starting main script
echo "Starting script...";
echo ""
echo "Enter password to update sleep settings: "
sudo echo "Disabling sleep..."

# Creating helper process
echo "# This is a helper script. Do not run manually." > ~/Desktop/PauseSleep/DontSleepHelper.sh
echo "sudo pmset -a disablesleep 1"                    >> ~/Desktop/PauseSleep/DontSleepHelper.sh
echo "rm -f ~/Desktop/PauseSleep/DontSleepHelper.sh"   >> ~/Desktop/PauseSleep/DontSleepHelper.sh
echo "sleep 60"                                        >> ~/Desktop/PauseSleep/DontSleepHelper.sh
echo "sudo pmset -a disablesleep 0"                    >> ~/Desktop/PauseSleep/DontSleepHelper.sh
echo "exit 0;"                                         >> ~/Desktop/PauseSleep/DontSleepHelper.sh
chmod 755 ~/Desktop/PauseSleep/DontSleepHelper.sh

# Launching the helper as a standalone process
nohup ~/Desktop/PauseSleep/DontSleepHelper.sh &

# Waiting for a second then printing info for the user
sleep 1
echo ""
echo "/------------------------------------------------------------------\\"
echo "| You may now close this window and shut the macbook lid.            |"
echo "| If lid is not closed within 1 minutes, clamshell mode will be      |"
echo "| reverted to default to prevent you from from forgetting about it.  |"
echo "\\------------------------------------------------------------------/"
echo ""
echo ""
echo "Script is done."
  1. Now, right click Sleep.myscript and choose Open With > Other > TextEdit.app. Copy all the following code into the file. Again, no fiddling required. You can just copy as is.
## Note: This file is optional but good to have in case you somehow get stuck in No Sleep mode.

# Starting main script
echo "Starting script...";
echo ""
echo "Enter password to update sleep settings: "
sudo echo "Reverting any still-un-revered settings and going to sleep..."
sudo pmset -a disablesleep 0
sudo pmset sleepnow
echo ""
echo "Script is done."
  1. Now you can drag the whole PauseSleep folder onto your Dock. This let's you enter the Unpowered Clamshell Mode by simply clicking the DontSleep.myscript icon in your Dock before closing the lid.

The benefit of this approach (besides being safe from having to trust third parties...) is that it reverts all of the changes the script made after 1 minute, but your computer will remain Awake until the next time you open and close the lid or until your normal sleep time is reached.

This way, you don't have to worry about setting third-party-app-timers, or remembering to turn off No Sleep mode when you're done working, or accidentally putting your computer in the backpack thinking it went to sleep but actually it's still in No Sleep since the last time you used it. This script prevents all that hassle.

It works when you need it, and turns off when you don't. Simple as that.

9

In 2020, I believe Amphetamine app is the best way to achieve that.

I was able to create a trigger based on whether external monitor is plugged or not and battery level. Awesome!

https://apps.apple.com/app/amphetamine/id937984704?mt=12

My trigger setup

5
  • Thanks for sharing, it works well Commented Jun 7, 2021 at 1:45
  • Does this still work on big sur? I just added your Amphetamine trigger and removed my power cord of my macbook air (m1). But the display won't show and it's just black. Commented Jun 21, 2021 at 7:16
  • Worked for me - Pro M1, Big Sur, etc.
    – abyshukla
    Commented Jun 21, 2021 at 15:50
  • @FelixNiedermann, On battery power, with these settings, the screen goes black for couple of seconds before coming back on. Machine-> mid 2015 pro
    – abyshukla
    Commented May 27, 2022 at 8:15
  • Not working on MBP M2 with the same trigger setup. The trigger gets activated, but the display still doesn't receive a signal.
    – binford
    Commented Apr 25, 2023 at 8:16

You must log in to answer this question.

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