Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从mac登录注销时启动停止Python程序_Python_Macos - Fatal编程技术网

从mac登录注销时启动停止Python程序

从mac登录注销时启动停止Python程序,python,macos,Python,Macos,我想在用户登录mac时启动python程序,在用户从mac注销时停止该程序 我希望在登录注销时执行该程序,而不仅仅是在系统启动时。这仅适用于Mac用户 这仅适用于Mac用户 可能重复的我想在登录注销中执行程序,而不仅仅是在系统启动时。可能重复的我想在登录注销中执行程序,而不仅仅是在系统启动时。 import Quartz d = Quartz.CGSessionCopyCurrentDictionary() if d.get('CGSSessionScreenIsLocked') and d.

我想在用户登录mac时启动python程序,在用户从mac注销时停止该程序


我希望在登录注销时执行该程序,而不仅仅是在系统启动时。

这仅适用于Mac用户 这仅适用于Mac用户
可能重复的我想在登录注销中执行程序,而不仅仅是在系统启动时。可能重复的我想在登录注销中执行程序,而不仅仅是在系统启动时。
import Quartz

d = Quartz.CGSessionCopyCurrentDictionary()
if d.get('CGSSessionScreenIsLocked') and d.get('CGSSessionScreenIsLocked') == 1:
    print("Screen is locked")
elif not d.get('CGSSessionScreenIsLocked'): 
    print("Screen is unlocked")