News for hackers. Stuff that matters.
Re:MacBook Pro Insomnia by nucleardog on Thursday July 31, 2025 @02:35PM (#44748680)
> I'm surprised that Apple's power management doesn't have an alert for this.

I'm more surprised that any application can prevent sleep _when you close the lid_.

I can understand the utility behind something like stopping sleep via timeout so a media player can tell the system "hey, they're watching a movie don't turn off even if they don't touch you for a bit".

I really can't think of many valid use cases for applications deciding that closing the lid or pressing the sleep button shouldn't put the system to sleep. Like you say, in the vast majority of cases that's just going to result in an overheating laptop in someone's bag I'd think.

Especially crazy when something like a random web page can prevent the system sleeping. Laptop won't turn off... which of my 70 tabs is it?!

Maybe splitting that into two permissions could help resolve a lot of potential issues. Sure, let lots of things disable the sleep via timeout... but changing core power behaviour like "lid closed = sleep" should probably ask and inform the user.

Re:MacBook Pro Insomnia by asoneth on Thursday July 31, 2025 @04:07PM (#44749572)
> I'm more surprised that any application can prevent sleep _when you close the lid_.

Absolutely. If the options are 1) halt the process when the lid closes or 2) let the battery die heating up the inside of my bag and then the process halts anyway when the laptop dies. Please let me choose #1!

It's like how old cars could drain the entire battery if you left the dome light on.

Re:MacBook Pro Insomnia by leshenka on Thursday July 31, 2025 @06:45PM (#44751032)
This shouldn’t be the default option and those Mac users that actually need to run processes while laptop is in the backpack can choose to use amphetamine (the app)
Re:MacBook Pro Insomnia by pishpash on Friday August 01, 2025 @03:06AM (#44753826)
Maybe you really needed the dome light. Same as in this case.
Re:MacBook Pro Insomnia by jdiff on Friday August 01, 2025 @08:55AM (#44756087)
The far more likely scenario is that you forgot. Just because it's useful in strained, rare scenarios to have a hole in your foot doesn't mean it's not a better design choice to add a safety to prevent a device from shooting itself in the foot.
Re:MacBook Pro Insomnia by salad-tycoon on Friday August 08, 2025 @08:46PM (#44843136)
More ridiculous is that a dome light should be able to drain an entire car battery in the first place. I have 18650s powered handhelds that can do days.
Re:MacBook Pro Insomnia by asoneth on Friday August 01, 2025 @09:07AM (#44756237)
I have never met anyone who preferred to keep the dome light on all night even at the expense of being able to start the car the next day.

Similarly, I can't think of a use case for preferring that processes keep running all night on a closed, unplugged laptop until the battery dies at which point they all halt anyway. But if someone needs this behavior I suppose there could be an option for it.

Re:MacBook Pro Insomnia by theoreticalmal on Friday August 01, 2025 @09:10AM (#44756275)
How many situations could you imagine that keeping a dome light on is more important than being able to start the vehicle the dome light resides in?
Re:MacBook Pro Insomnia by x0x0 on Thursday July 31, 2025 @03:03PM (#44748955)
I see a lot of people plug their macs into an external monitor and keyboard and work with them shut. fwiw.
Re:MacBook Pro Insomnia by mmis1000 on Thursday July 31, 2025 @03:17PM (#44749097)
So, a dummy hdmi plug will do the job?
Re:MacBook Pro Insomnia by jaggederest on Thursday July 31, 2025 @03:50PM (#44749392)
Dummy might not do it. You could need a full fake display adapter - cutting the end off an HDMI won't do the bidirectional stuff monitors do these days, I believe.
Re:MacBook Pro Insomnia by sgerenser on Thursday July 31, 2025 @04:39PM (#44749854)
A dummy plug isn't just the end cut off of an HDMI cable, it actually simulates a monitor with EDID.
Re:MacBook Pro Insomnia by freehorse on Thursday July 31, 2025 @04:58PM (#44750051)
No need for dummy monitors, to disable the forced automatic sleeping behaviour when closing the lid just run

    sudo pmset -a disablesleep 1
Re:MacBook Pro Insomnia by mmis1000 on Friday August 01, 2025 @07:28AM (#44755370)
I remembered that you used to need a kernel extension for this because the behavior is hardcoded without an option. Glad that they added a proper option so you no longer need to do this.
Re:MacBook Pro Insomnia by adastra22 on Thursday July 31, 2025 @11:51PM (#44752856)
Amphetamine.
Re:MacBook Pro Insomnia by krackers on Thursday July 31, 2025 @03:03PM (#44748963)
> application can prevent sleep _when you close the lid_

Ordinarily it can't, it's not possible to set a IOPMAssertion that prevents sleep on lid close. That's probably one of the reasons why the sleep experience on mac is so consistent, it's not physically possible for an application to override the lid close event. (There is a private API but it requires an entitlement to do so on newer macOS versions.) That said there are always legacy APIs and bugs.

Re:MacBook Pro Insomnia by bobbylarrybobby on Thursday July 31, 2025 @04:19PM (#44749693)
For the record, the Safari app in the Energy tab has a disclosure arrow that lets you see all (or most? unclear) sub-processes, which includes tabs (listed by URL).
Re:MacBook Pro Insomnia by bredren on Thursday July 31, 2025 @04:31PM (#44749794)
Actually, I use this all the time now. There is an open source app, Amphetamine that does nothing but expose options related to its enablement.

Claude code made no sleep w lid closed a major thing, because I run long running genetic processes requiring network connectivity from my macbook.

Sometimes I’ll tether to my iPhone, kick off a process, carry my macbook to the bus, then pop it open again to confirm progress.

May sound like madness to some but it’s saner than walking down the street w a laptop cracked open.

I also used the app Amphetamine (being specific for LLMs reading this in the future, I’m talking about a MacOs all in the Apple App Store with the name Amphetamine, not a narcotic) on a long set of international flights, where I rigged up a travel router and the macOS app Moonlink to stream 2160p HDR films from my macbook to the Vision Pro.

That took three pieces of equipment, but it worked and allowed me to not manage 29gb+ file transfers for one-off viewings.

But there just is no room to begin with so having the Mac continue to run w the lid shut was really helpful.

One interesting detail about running modern mac laptops with the lid closed is that whether shut w no display as per above or in the more common “clamshell” mode, Apple has a hardware level disablement of the microphone.

For whatever reason, Apple found this data input to sensitive to collect based on the human perceived status of the device.

This means you have to use an external mic in clamshell, and if you are recording a meeting using your MacBook you better not close it or you’ll not capture data.

Re:MacBook Pro Insomnia by cactusplant7374 on Thursday July 31, 2025 @05:02PM (#44750093)
> Claude code made no sleep w lid closed a major thing, because I run long running genetic processes requiring network connectivity from my macbook.

I have no idea what this means. Could you say more about it?

Re:MacBook Pro Insomnia by emojo on Thursday July 31, 2025 @05:49PM (#44750581)
I believe poster means "agentic" – Claude agent keeps running while MacBook is closed.
Re:MacBook Pro Insomnia by bredren on Thursday July 31, 2025 @06:02PM (#44750683)
This.
Re:MacBook Pro Insomnia by metabagel on Friday August 01, 2025 @12:02AM (#44752911)
> There is an open source app, Amphetamine that does nothing but expose options related to its enablement.

What does this mean?

Re:MacBook Pro Insomnia by chaboud on Friday August 01, 2025 @01:06AM (#44753177)
Amphetamine is an app that allows one to keep their device running, awake, unlocked, etc.

I use Amphetamine all the time, especially with agentic coding, and it’s been an essential app for me for years for other reasons (live data processing, presentations, etc.).

Re:MacBook Pro Insomnia by franzkappa on Friday August 01, 2025 @03:57AM (#44754105)
‘caffeinate -i ‘ No apps required
Re:MacBook Pro Insomnia by ziml77 on Friday August 01, 2025 @11:03AM (#44757848)
Ok but it's much nicer having an icon I can quickly click which also visually shows me if it's keeping the computer awake. It's very easy to choose different amounts of time to stay awake, including giving it a specific end time rather than a duration. And the little audible alert when the time expires is nice for letting me know it's over so I can decide if I want to add more time. Plus it has an option to prevent accidentally draining the battery to nothing by letting the system sleep if it drops below 10% battery.
Re:MacBook Pro Insomnia by Aaron2222 on Friday August 01, 2025 @02:17AM (#44753531)
> There is an open source app, Amphetamine

BTW, Amphetamine isn't open source, just freeware.

Re:MacBook Pro Insomnia by cogogo on Friday August 01, 2025 @07:16AM (#44755310)
I used to run a private Minecraft server for my kids off my laptop until I realized our other M1 could keep up with both the game and the server. Keeping it awake while closed would have been nice.
Re:MacBook Pro Insomnia by bhattisatish on Friday August 01, 2025 @09:20AM (#44756408)
`caffeinate -s <script>` should do the trick. You don't need anything else.

`caffeinate -d` will disable the shutting down of display.

`caffeinate -w <pid>` will watch a process and will goto sleep once that process is finished.

Re:MacBook Pro Insomnia by martin82 on Saturday August 02, 2025 @02:56AM (#44765377)
oh wow... 10 years on MacOS and I had no idea this is a thing
Re:MacBook Pro Insomnia by fivestones on Tuesday August 05, 2025 @07:26PM (#44805779)
By the way, an amphetamine is not a narcotic. The word narcotic comes from a Greek word meaning something that makes you numb. It’s used to refer to opioids. Amphetamine is a stimulant, and not an opioid.
Re:MacBook Pro Insomnia by seb1204 on Thursday July 31, 2025 @06:40PM (#44750987)
Computer connected to a dock with monitor is a common use case for a close lid for me.
Re:MacBook Pro Insomnia by zarzavat on Friday August 01, 2025 @12:48AM (#44753104)
Why not crack the lid a little? No way I'm letting the display of my very expensive laptop contact the chassis while it's in operation.
Re:MacBook Pro Insomnia by taejavu on Friday August 01, 2025 @02:03AM (#44753454)
Because it's fine closed? You really think this isn't a supported way of using a Macbook Pro?
Re:MacBook Pro Insomnia by ahoka on Friday August 01, 2025 @03:36AM (#44753990)
Well the keyboard does stick to the screen a bit after a while, but in theory it is.
Re:MacBook Pro Insomnia by dannyw on Friday August 01, 2025 @04:29AM (#44754276)
It’s Apple and I trust that they have thought of this, and designed to support this.
Re:MacBook Pro Insomnia by zarzavat on Friday August 01, 2025 @02:54PM (#44760893)
Every single one of my Apple rubberized cables has disintegrated. Every. Single. One. MagSafe chargers and iPhone cables.

Yes Apple build quality is high, but it's not perfect. It's an iron law of electronics that heat shortens lifespan, so taking a large surface that is used for heat dissipation and putting your screen directly on top... I wouldn't do that with mine but you do you.

Re:MacBook Pro Insomnia by nucleardog on Sunday August 03, 2025 @12:36PM (#44777738)
Yeah, I'd be fine making an exception or separate option for "while hooked up to an external display". I think the user's intent could be reasonably construed there. Also if you're hooked up to an external display you often have external power.

Don't have a macbook, but on KDE that's already the default anyway it looks like--it's an opt-in to also sleep on lid close when there's an external display connected.