For KDE development, I work with a separate user. However, when you invoke su - kde-devel and run an X11 application, you'll get nasty errors like:
or
There are several solutions for this.
One solution is to use SSH with X Forwarding. Make sure that your SSH daemon is running with the option X11Forwarding yes and log in with:
From the spawned shell it is possible to run X applications on your display. I haven't done any research on this, but my guts tell me this causes slightly more overhead, which is unnecessary. Besides, perhaps it's undesired or impossible to fiddle with the SSH daemon and allow X11 forwarding.
Another solution is to relax the X access controls a bit, which is from my perspective a cleaner approach. There's the following you can do to run X11 applications:
su - kde-devel
This simply disables access control and allows everything. This is fine when you're in a completely trusted network. A more fine-grained approach would be to only allow connections from your own machine:
su - kde-devel
In fact, this is the solution we're looking for. But of course you wish to automate this, so you put the xhost command in your ~/.bashrc (that is: your normal user account, not the user you wish to give permissions). But, you only want to do this for interactive terminals, so the command should be surrounded with a terminal type check. And, because xhost produces annoying output, let's silence it right away. This results in the following lines for your ~/.bashrc:
case "$TERM" in
xterm*|rxvt*|screen*) xhost +local: >/dev/null 2>&1 ;;
*) ;;
esac
I've got this code block from the Ubuntu Forums, but with a slight addition: also allow the screen terminal type (useful if you use screen or tmux).
With these steps, I've shown how you can run X11 applications from any local user on your system.