X11: run a gnome app as another user
Asked Answered
H

7

21

I have ubuntu + x11 + gnome.

I want to run a graphical application as another user.

However, when I start it from the command line using sudo -u otheruser app I get the error "No protocol specified".

How can I work arround this?

Hemicellulose answered 14/7, 2009 at 8:31 Comment(1)
will be moved to superuser.comHhd
B
3

Use

xdg-su -u user -c command
Basswood answered 14/7, 2009 at 9:1 Comment(2)
I believe you still need to use xhost to allow local connections from any user.Lifeless
man xdg-su: xdg-su is for use inside a desktop session only.Basswood
R
13

xhost '+si:localuser:USERNAME'

Ringtail answered 14/11, 2013 at 15:41 Comment(0)
L
8

Execute this command first:

$ sudo xhost +

Then run the command you want as the other user:

$ sudo -i -u username
$ command you want to run

When you are done:

$ sudo xhost -
Lifeless answered 14/7, 2009 at 8:44 Comment(4)
Nice find. Now Chrome and Flash runs fine as different user, but to get audio you need to pkill the pulseaudio-daemon of the current user first.Pigg
sudo xhost +local: if you don't want connections from the internetSurveillance
xhost + is highly unsafe: It will allow any user to connect to your X session and open windows to you.Yarber
xhost +username to add username to list of users with access to the X server. Then xhost -username to remove that user afterwardsDeeprooted
B
3

Use

xdg-su -u user -c command
Basswood answered 14/7, 2009 at 9:1 Comment(2)
I believe you still need to use xhost to allow local connections from any user.Lifeless
man xdg-su: xdg-su is for use inside a desktop session only.Basswood
E
2

Most solutions provided here don't integrate with Wayland and PulseAudio.

I wrote ego (Alter Ego) for this use case, it automatically handles xhost and Wayland and PulseAudio socket sharing: https://github.com/intgr/ego

So you just run ego app or ego -u somebody app

If you run into problems, please open an issue on GitHub. I may be the only user of it, so it hasn't gotten much testing yet.

(And I notice that I'm a decade late with this answer, but hopefully it will help somebody :D)

Earshot answered 7/3, 2021 at 4:27 Comment(0)
H
1

You probably need to tell your X server to accept connections from another user than the one owning the server instance (you). Look into the xhost command.

Heymann answered 14/7, 2009 at 8:42 Comment(0)
I
0

gksudo -u command

Impart answered 14/7, 2009 at 13:53 Comment(1)
Tried this on my Ubuntu desktop, it did not work (same error msg. as in question).Lifeless
Y
0
gksu -u <user> -c <command>

Replace <user> with the username to run the command as, and <command> with the command you want to run. Remember that the program will be run in the <user>s context, but in the current directory.

In the popping up window, enter the password of the target <user> of course.

Yarber answered 22/5, 2017 at 18:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.