Is there any way to set a MacBook Pro to not sleep when you close the lid?
Solution 1:
You can use InsomniaX. It sits in your menu bar, and upon activating it, your laptop won't sleep if you close it.
Solution 2:
There's also the macosx-nosleep-extension alternative to insomniaX.
Solution 3:
Without using any third-party software, Apple says you need to have an external keyboard, mouse, or trackpad (USB or bluetooth) to prevent the computer from going to sleep (Lion), or to awaken it from sleep (Snow Leopard and earlier), after the lid is closed.
It turns out that you can apparently connect any external USB device to wake it back up from sleep. I do this with a MacBook Pro that I use with Synergy so that I can use the keyboard and mouse on my Linux workstation to control my MacBook Pro with an external monitor and the lid closed. I just plug in my USB flash drive after I close the lid to wake the MacBook Pro and then I can start using it in clamshell mode with no external keyboard or mouse connected to the MacBook Pro.