Can I run my MacBook in clamshell mode without being connected to power?

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.


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


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.