answered
2015-10-29 11:04:45 +0200
Currently display state statistics are not collected (anymore - back in Nokia N9 times display on time had to be tracked to compensate for amoled display aging).
But if you wish to know how long the device has been suspended (= can be used as upper bound for display off time estimate), you can use "mcetool --get-suspend-stats" (will be available in mce >= 1.65.0 / sfos >= 2.0.1).
Note that the above is just an abstraction for the benefit of automated testing. You can get the same data already now by using clock_gettime() and calculating difference between CLOCK_BOOTTIME (which accounts also time spend in suspend) and CLOCK_MONOTONIC (which does not advance when device suspends).
Maybe sysmon? (https://openrepos.net/content/basil/system-monitor)
objectifnul ( 2015-10-25 09:44:59 +0200 )editHaven't looked at the source, but perhaps this could help?
pichlo ( 2015-10-25 10:20:29 +0200 )editOhhh, sorry... my mistake. I meant how to check with terminal command. I will update question.
Schturman ( 2015-10-25 11:04:43 +0200 )editI did not know you meant 'from the terminal' but I did read your question as 'how to check it programmatically'. The screen usage monitor source may help but I would need to get back home and spend some time checking the source to see if any of that is usable directly from the command line, without any extra tools.
You say you can tell if the screen is on or off. So as a last resort, you can keep a log of changes and calculate the time yourself. It may not be very accurate, depending on how quickly you detect the change.
pichlo ( 2015-10-25 12:45:39 +0200 )editthanks, I'm already trying to find this from source in your link. For now without result...
Schturman ( 2015-10-25 13:42:49 +0200 )editAnd yes, calculating by myself is not accurate because my checking script work every 20-30min.