Mercurial > code > home > repos > racc
view collector/power_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 |
line wrap: on
line source
import subprocess import ast def is_screen_on(): screen_is_locked = ast.literal_eval( subprocess.check_output( [ '/usr/bin/python', # system one with Quartz available '-sc', 'import Quartz; ' + 'print Quartz.CGSessionCopyCurrentDictionary().get("CGSSessionScreenIsLocked", False)' ], encoding='ascii')) return not screen_is_locked def go_lock_screen(): pass def go_wake_screen(): pass def go_sleep_mode(): subprocess.run(['pmset', 'sleepnow']) is_screen_on()