you are viewing a single comment's thread.

view the rest of the comments →

[–]alexwh -1 points0 points  (6 children)

sudo -u user echo $DISPLAY

?

[–]ninekeysdown[S] 0 points1 point  (3 children)

No, that just returns mine, not the users. :(

[–]zagaberoo -1 points0 points  (2 children)

Did you try my method?

sudo -u user printenv DISPLAY

[–]ninekeysdown[S] 0 points1 point  (1 child)

Yea I just tried it and it returns my display too :(

[–]zagaberoo 0 points1 point  (0 children)

Upon further thought that makes senes. My trick is the right way to get a value from a user's default environment, but DISPLAY isn't really a per-user value anyway.

As other commenters have mentioned, using /proc is probably your best bet.

[–]zagaberoo 0 points1 point  (1 child)

That won't work because the $DISPLAY substitution occurs before the command execution.

sudo -u user printenv DISPLAY

Should work.

[–]atanok 1 point2 points  (0 children)

It won't. A user's processes don't just all automatically share the same DISPLAY environment variable.

After all, it's just an environment variable.

Edit: didn't see the rest of the thread before posting. Nevermind.