Can I tell Windows 10 - 'If I close the lid on my laptop, go to sleep IF I don't have an external monitor attached'?

I am aware of the following SuperUser questions:

  • Prevent laptop from going to sleep when I close the lid, but only if I'm connected to an external display
  • automate so that if and only if external monitor is attached, closing laptop lid does nothing

Neither of these have useful answers, and are also both quite old.

In the current version of Windows 10, is there a way to tell Windows to sleep only if the lid is closed and there are no external monitors attached?

In work, I like to close the lid and attach a couple of monitors, at home I just use the laptop as-is.

Sometimes I close the lid before I leave for home, forgetting it's actually still running, and take my laptop out of the bag when I get home to discover it is radioactive hot!

The laptop is a Dell XPS 9550, if that helps.

Thanks


That functionality is not built into Windows.

However, it would be fairly easy to write a script to do so. In Poweshell you would use Get-WmiObject win32_desktopmonitor to see if a monitor is attached, then you can change the power plan accordingly.


There seems to be a way, although it is not as convenient as it could/should be:

  1. Select your external monitor as your main monitor.
  2. Set your computer to sleep when the lid is closed.
  3. Now you can close the lid, your computer will go to sleep.
  4. But when you click a mouse button it will come back from sleep while the lid is closed.

(Source: reply from "none_ofyour_business")