My case: At work, I use my own laptop (Xiaomi Mi Pro). When I connect it to an external monitor, I want to be able to just close the lid and leave without the laptop and have the laptop suspend. When I return, I want to continue working.
But it's not that simple when an external monitor is attached. The default behaviour of Linux with multiple desktop environments is to change the primary monitor to the external.
For example: Ubuntu 18.04.1. Its dconf option
lid-close-suspend-with-external-monitor doesn't work. Nothing changes when I set that option to true. Sometimes Ubuntu couldn't recognize that external monitor at all. This problem suddenly appeared and disappeared, so I abandoned Ubuntu.
Now I'm using Mint 19 with Cinnamon. It has the necessary option in the power settings (actually the same dconf option
lid-close-suspend-with-external-monitor, but in the cinnamon section). And it works, but when I open the lid, the windows from the laptop screen move to the external monitor. Having to move them back to workplaces is time consuming and undesirable.
I think that before laptop suspends, xrandr has time to change the primary monitor to external. How can I prevent this behavior. Can I lock the primary laptop monitor? Or maybe it is possible to restore the position of the windows after opening the lid?