Well, the script may be run as root in the background from my ARD server machine while a local user logged in as themself may be sitting in front of the machine. I want the script to get their username even though it’s running as root.
This code will return the correct username if an actual person logged in, but will return root if a script running as root was used to type in the name and password and then hit return on the login screen.