I've been trying to run apps as a different user.
sudo -u otheruser open /Applications/TextEdit.app launches the app but it uses the current user, not otheruser.
login username and
su - otheruser successfully login as otheruser, the different user pops up in Activity Monitor, but something like
open /Applications/TextEdit.app returns the error
LSOpenURLsWithRole() failed with error -10810 for the file /Applications/TextEdit.app.
sudo su - otheruser -c /Applications/TextEdit.app/Contents/MacOS/TextEdit seems to launch the app (it appears under Activity Monitor as launched by otheruser) but this error appears while the dock icon bounces indefinitely:
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
So… how do I run an app as a different user?