annotate collector/idle_osx.py @ 10:6b6b1ea0e00d
default tip
ok for no window to be focused (untested)
author |
drewp@bigasterisk.com |
date |
Mon, 13 Mar 2023 19:16:58 -0700 |
parents |
5ad799e534a5 |
children |
|
rev |
line source |
0
|
1 import subprocess
|
|
2
|
|
3
|
|
4 def get_idle_seconds():
|
|
5 for line in subprocess.check_output(['ioreg', '-c', 'IOHIDSystem'],
|
|
6 encoding='ascii').splitlines():
|
|
7 if 'HIDIdleTime' in line:
|
|
8 ns = float(line.split(' = ')[1])
|
|
9 return (ns / 1000000000)
|
|
10 raise ValueError("idle time not found") |