1

I run Debian Jessie with GNOME3.

I'm in a situation where two users are logged-in:

user1 is on :0 and user2 is on :1.

I want to swap them to have:

user1 on :1 and user2 on :0.

  • 1
    I'm curious: why do you want to do this? I suppose you want to swap them without logging them out and back in, is that correct? – Stephen Kitt May 6 '16 at 21:14
  • You are correct. I want the sessions to stay intact. I want this because of the situation described here: stackoverflow.com/questions/37080599/… – baldurmen May 6 '16 at 21:26
3

There is a way to add users to a given display and remove users from a given display, but not to just swap. You could do this by having each user run xauth to add the other user to their display, and then using xauth to remove themselves from the original screen. That seems like a lot of work, since it involves copying authorization data from one account to another, and multiple steps.

Further reading:

X clients authenticate themselves to the server by passing the authentication credentials from the file specified by $XAUTHORITY (or $HOME/.Xauthority if $XAUTHORITY is unset). This file is normally only readable by its owner, so other users on the same system can't access the X session.

If you want to grant other accounts access to your X session, extract the authentication credentials using "xauth extract ...", transfer them to the other account, then have that account add them to its own ~/.Xauthority file using "xauth merge ...".

  • I'll try this out next week when I have some free time and if I am able to do what I wish to do, I'll post step by step instructions – baldurmen May 7 '16 at 0:16
  • @baldurmen Note that this probably doesn't do what you want: it allows user1 to launch new programs on the display where user2 logged in, and vice versa. It doesn't change which display is shown on each console, and it doesn't affect already-running programs. – Gilles May 7 '16 at 18:52
1

This is not possible. The X server knows which display number it's handling and it doesn't have an interface to change that.

(Ok, technically it's possible by running a debugger on the X server process and issuing the right commands. The wrong commands will crash the X server if you're lucky. This is not likely to succeed.)

Whatever problem you're trying to solve is sure to have a better solution. Most programs use the display number indicated by the DISPLAY environment variable. Running env DISPLAY=:1 someprogram instead of someprogram will take care of 99% of the cases — that's what the X library does by default. For the remaining 1% that have :0 hardcoded in the application, if the program is dynamically linked, LD_PRELOAD (explanation and example) should do the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.