1

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.

Programming-Lover
  • 1,177
  • 10
  • 14
  • Possible duplicate of [MAC OSX - execute a python script at startup](https://stackoverflow.com/questions/29338066/mac-osx-execute-a-python-script-at-startup) – Jack Moody Feb 27 '19 at 07:45
  • I want to execute the program in the login-logout not only at the start of the system. – Programming-Lover Feb 27 '19 at 11:45

1 Answers1

0

This is only for Mac users

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")
Programming-Lover
  • 1,177
  • 10
  • 14