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
I want to swap them to have:
:1 and user2 on
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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.
X clients authenticate themselves to the server by passing the authentication credentials from the file specified by
$XAUTHORITYis 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
~/.Xauthorityfile using "xauth merge ...".
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.