I want to start my python program when a user is getting logged-in into the mac and stop the program when he logged-out from mac.
I want to execute the program in the login-logout not only at the start of the system.
I want to start my python program when a user is getting logged-in into the mac and stop the program when he logged-out from mac.
I want to execute the program in the login-logout not only at the start of the system.
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")