Is there a way, via the command line, to check if the current user has the desktop? That is, if I run a shell script in a window, I want to be able to tell (in the script) if the user has switched to another account via Fast User Switching. The shell script is still running in that command window, but since the user has switched to another account, the Desktop doesn't show that command window.
I share my Mac with my wife, and we each have our own accounts. When she sits down at the computer, she switches to her account. I want to write a Python program that runs 24/7 on my account. I want that program to know when my wife is at the computer and has switched to her account.
I hope I'm explaining this clearly. I searched on Google for 20 minutes before giving up, as none of the search results were even close to what I was trying to find. I don't even know how to phrase the question properly.