Skip to content

Draft: Introduce KScreenLid

Jakob Petsovits requested to merge jpetso/libkscreen:work/jpetso/liblid into master

WIP patch attempting to address powerdevil#22. Will remove draft status once it's fully working. Goes together with the kscreen-liblid branch on jpetso/powerdevil.


This is a new library that only has one class to access the system's display lid status.

The API of the class was extracted from PowerDevil which was already abstracting this functionality. Here we are doing in a generic way so it can be used elsewhere.

The implementation requires separate backends, replacing the previously used UPower D-Bus API for lid monitoring which has been deprecated for a long time and may disappear anytime now.

For open/closed status, this WIP commit accesses systemd's login1 D-Bus API which has been recommended as replacement for UPower lid monitoring. However, the specification for the login1 interface does not guarantee a PropertiesChanged signal for the "LidClosed" property and indeed, this implementation does not appear to receive any such events. So we'll probably have to use something else. [Edit: As of systemd 256, the PropertiesChanged signal for "LidClosed" is supported! So this code should work for v256 and beyond.]

Compared to UPower, the login1 interface does not expose whether a lid is present on the system. So we need something else for at least this part anyway, if we want to keep showing or hiding lid-related properties such as the lid action field in PowerDevil's "Energy Saving" KCM.

For determining lid presence, this WIP commit uses KWin's InputDevice D-Bus API. This is only implemented for Wayland, so we'll need to factor it out into a separate class similar to KScreen::Dpms before merging.

Edited by Jakob Petsovits

Merge request reports