winft / disman

Qt/C++ display management library
GNU Lesser General Public License v2.1
3 stars 1 forks source link

Support for laptop-specific actions #13

Closed romangg closed 8 months ago

romangg commented 4 years ago

Motivation

The display configuration of a laptop connected to an external display could be changed automatically depending on if the laptop lid is closed and if the laptop is in a docking station.

This was supported previously with the design to have all control file handling in KDisplay albeit it never worked without any issues.

Discussion

Laptop lid

It makes sense to have this in Disman. The internal display can be disabled when the lid is closed and enabled again when the lid is opened. We might want to only enable it again if the user has not manually changed the config in the meantime.

One question is what other service Disman should use to query the state of the lid. KDisplay used for that UPower what is probably also a good choice for Disman.

Docking station

When being docked but the lid open the configuration might only be changed in a way such that the panel is moved from the laptop display to the external display. This clashes though with other configurations depending on which output is connected. Also on Wayland this is not in the same way possible as on X11 since no primary output concept exists per se.

Besides, it is not clear how the KDisplay daemon queried the state of being docked or not. The code seems to do nothing.

Decision

For now it makes sense to only work on support for adapting the configuration on laptop lid open/close.

romangg commented 4 years ago

For the laptop lid action we need to also listen for suspension of the device. We can do this with logind, i.e. by listening to the PrepareForSleep signal of the org.freedesktop.login1 service on the system bus.

romangg commented 4 years ago

In KDisplay the flow is like this:

Closing lid

Opening lid

Caution

There are two special cases (which also might not have been properly handled in KDisplay):

romangg commented 4 years ago

mentioned in commit 51b556597777c1315cc687017bd08a16a1c3f55a