Running a script as root and presenting a GUI to logging in users
Sockets - Involved but Tried and Tested

Your solution of two scripts talking through a socket is the tried and tested approach. We did this for Power Manager and it has worked reliably from OS X 10.3 – 10.11.

You can use a tcp or unix domain socket for this purpose.

In our situation, the daemon pmd runs as a computer wide process and the user session daemon pmuser runs once per user. They talk to share information that a computer wide daemon can not safely obtain and to perform actions within specific user sessions.

The computer wide daemon can detect when a user logs in. This is done through the SystemConfiguration API SCDynamicStoreKeyCreateConsoleUser.

The graphical script must be launched within the graphical user session; a launchd job in /Library/LaunchDaemons with the key value pair LimitLoadToSessionType: Aqua set will ensure this.

Depending on the information you need to gather from the user, I expect what you want to achieve is possible with Power Manager; feel free to get in touch.

launchctl's bsexec

Recent versions of OS X include a launchctl that promises what you need: the ability to launch a process within a user session. See How to launch a GUI application in another user's graphical session? for the details and likely problems you will encounter.

If you are deploying on OS X 10.10 and later, investigate launchd's new domain capabilities. A complete rewrite in OS X 10.10 opened up many as yet not completely documented options. The launchd mailing list is a treasure trove of information.