Mercurial > code > home > repos > racc
view power_osx.py @ 3:3d7fc94a404a
a few more inputs; daemonize
author | drewp@bigasterisk.com |
---|---|
date | Wed, 08 Mar 2023 10:57:11 -0800 |
parents | 0ecb388a0b90 |
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()