At work, I’ve been running my MacBook in clamshell mode. It’s great because new windows won’t show up on the built-in display, but unfortunately, it also means I have to keep my laptop plugged in. Lithium batteries don’t like staying fully charged or discharged — it causes them to degrade faster.
Solution: Charge your Mac to 50 percent. Cut a thin piece of tape and put it over the middle pin on the MagSafe charger. For safety, make sure the other pins stay completely uncovered.
The computer uses the middle pin to retrieve the charger’s serial number and wattage over the 1-Wire protocol — without this information, your Mac will power itself from the charger, but it won’t charge the battery. (I think this is the same technique that the now-discontinued MagSafe Airline Adapter used to avoid tripping planes’ circuit breakers.)