I wondered why this solution does not already exist, when I took the dive at it, I see it wasn't feasible, at least as far as my research, skills and knowledge goes.
On linux, running with x11 (maybe not), I want to know the display uptime for a user session.
Let me elaborate, display uptime, I mean when the screen is flashing light minus screensaver or locked screen. The display time when the user can launch an application. Say am building a program that monitors how long an application is running, ideally I would need to kmow the total uptime the display was on to say "this application was used 20% today".
I know I said a lot, but I hope I buttressed the point very well. So far the solution I've;
-
polling xset q on x11 for the string "Monitor is On" and recording the intervals
-
Another parochial solution, Gnome has it desktop background has a window, Gjs, that I have noticed is always on the LIST_STACKING x11 API calls that corresponds to me closing my laptop lid a destroy event on that window and a map whenever it opens again. This could be monitored ideally for when the display was up, I think so, but the solution is too narrow. It could even be only to the Gnome version am using.
-
Journalctl, obvious but I could not navigate "how"
Thank you for any response to this. It would be appreciated.