Mercurial > code > home > repos > racc
annotate collector/idle_osx.py @ 8:af6e0049e701
deploy for vite
author | drewp@bigasterisk.com |
---|---|
date | Mon, 13 Mar 2023 18:54:47 -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") |