Mercurial > code > home > repos > racc
diff collector/power_osx.py @ 4:5ad799e534a5
move to subdir
author | drewp@bigasterisk.com |
---|---|
date | Mon, 13 Mar 2023 18:50:23 -0700 |
parents | power_osx.py@3d7fc94a404a |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/collector/power_osx.py Mon Mar 13 18:50:23 2023 -0700 @@ -0,0 +1,30 @@ +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() \ No newline at end of file