Mercurial > code > home > repos > racc
view 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 |
line wrap: on
line source
import subprocess def get_idle_seconds(): for line in subprocess.check_output(['ioreg', '-c', 'IOHIDSystem'], encoding='ascii').splitlines(): if 'HIDIdleTime' in line: ns = float(line.split(' = ')[1]) return (ns / 1000000000) raise ValueError("idle time not found")