Mercurial > code > home > repos > racc
comparison idle_osx.py @ 0:05bdded21d38
start: progs and idle time
author | drewp@bigasterisk.com |
---|---|
date | Fri, 03 Mar 2023 18:33:19 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:05bdded21d38 |
---|---|
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") |