-
-
Save rtrouton/f656cd260e9be8fabe66 to your computer and use it in GitHub Desktop.
For OS X 10.10.x and later - Launching Safari with the logged-in user's account name from a script run with root privileges
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Identify the username of the logged-in user | |
logged_in_user=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");'` | |
/bin/launchctl asuser "$logged_in_user" /usr/bin/open "/Applications/Safari.app" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment