droidian / stated

Other
2 stars 2 forks source link

HACK: display: hack around file monitor not working on sysfs #1

Open calebccff opened 2 years ago

calebccff commented 2 years ago

inotify doesn't work on sysfs, neither does poll() (reliably), ideally phosh (or your UI of choice) should notify of device lock/unlock and display on/off state changes rather than it being handled here, this way they could also handle convergence for example.

Until then, this pokes sysfs after a power key press to determine the display state and handle the wakelocks as appropriate.

This is probably not appropriate to merge just yet, although I'm not very familiar with glib, I'm just opening it to start a conversation, I'd love to see proper opportunistic sleep on Linux mobile. That said I'd appreciate any feedback on it!

This doesn't handle cases where the display turns off for any reason other than a power button press.

g7 commented 2 years ago

Hello Caleb, thanks for opening this pull request :)

I agree on the points you made - checking display status this way is not ideal. On my local tree I have a bunch of improvements regarding display status detection (among others), where it's instead fed via DBus, with a small client that will keep track of the display status using the wlr-output-management protocol (and this includes multiple display support), and that can be replaced without touching stated on other DEs.

Unfortunately it has been on hold as I worked on other things - the good news is, once the ongoing migration to bookworm is finished, I'll return to it, polish the code and publish it here :)

I won't close this PR for now since the display status is still checked via sysfs as a fallback, so it would be worth lo keep this around :)

calebccff commented 2 years ago

thanks, that's good to hear! sounds like a much nicer solution :D