I can't completely try this since all my machines have root disabled.
To find which display a user is on, you can use the who
command. The last column of output is usually the DISPLAY that the user is logged in on. Something like this could be used to grab just the display (there is likely a far more efficient way to do this, feel free to offer edits):
who | grep -m1 ^username.*\( | awk '{print $5}' | sed 's/[(|)]//g'
Then to launch a graphical X command on that display:
DISPLAY=:0 firefox &
where :0 would be replaced with whatever display you found in the first command and firefox would be replaced with whatever command you want to run. You could put this in a shell script and just use a variable.
The next part is the part I haven't tested, but I don't see why it shouldn't be possible to do:
su username -c "DISPLAY=:0 firefox"
to launch the X command as that user.
naga_plugged.pl
script finishes (or forks into background), becauseudev
will be waiting for it to exit.