How to hijack an already running X11 application via ssh -X?

Dear Lazyweb,

I have always wondered whether it is possible to "hijack" an already running X11 application on a remote server...

Say I have a box at home which has a running X11 server with many applications, e.g. Firefox, xchat, xmms, whatever. Now, say I'm somewhere else with my laptop and login with "ssh -X" into my home box. I can now start X11 applications and they will be shown on my laptop screen. So far so good.

But... how can I get one of the applications that were already running before I logged in from remote to be displayed on my laptop screen? Is it possible? How?

Just curious.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

A year later, did you

A year later, did you succeed? My findings after trying the solutions offered here:

xmove to old or something, does not work: "gethostbyname failed: No such file or directory" as well as X authorization issues.

vnc does work, but only on the whole screen, not on application level, or is this somehow possible?

gtk-demo indeed shows it can be done if the application supports it itself. probably the most promising solution if it becomes a standard.

Moving from one Display to another needs toolkit support

some programms/toolkits support moving applications from one Xserver to another.
I think gtk has the needed lowlevel stuff.

try installing gtk2.0-examples (for debian based systems) and run gtk-demo, select Change Display and push windows from that demo to other xservers.
It works for me... But i don't know any application that exposes that functionality in it's normal user interface. (xemacs can do something similar but not quite the same)....

It seems all that's missing is some nice way to force applications to call gtk_window_set_display(...) at the right time... maybe some clever gtk plugin/module anyone? (or for the wicked: maybe gdb ist enough? XD)

VNC

You may install a vnc server and log in to that X session over vnc. This worked for me using Windows and/or Debian GNU Linux.

Give it a try.

x11vnc

http://karlrunge.com/x11vnc/
works fine for me with script #1.
( just a bit of setup to do the first time with vnc passwords, etc... )

xmove

The only thing I found was running xmove before launching any application. xmove creates a virtual X display (For example :1), and allows to move any app between real X displays.

However, it is no really moving the app, only redirecting its display...

VNC

Another option is VNC. It is possible to run a VNC server that connects to the remote X11 server, and serves it up over the RFB protocol. GNOME and KDE both have built in software to do this (GNOME's is called vino). If you use another desktop environment then you can run x0rfbserver to do the same.

xmove

An alternative would be xmove, however that requires you to start the applications under a virtual DISPLAY and then select where it is drawn.
It doesn't support some of the extensions that gnome etc seem to require either - NX is almost certainly a better choice, but just in case...

Vino

If you are using GNOME i think Vino does allmost what you want, but with vnc.

Probably impossible

Notice that your old application:
- runs on the remote host
- displays on the remote host's X server
while the new application (the one in ssh -X):
- runs on the remote host
- displays on the local host's X server

So this probably makes it impossible to do what you want.

The only solution would be to use the X equivalent of GNU screen, which must be either freenx (as already pointed out) or vnc.

VNC for :0

Run one of the VNC servers that serves the currently display, such as x0rfbserver (package rfb) or x11vnc, using DISPLAY=:0, then run an appropriate vnc viewer. ssh -X not needed, though you may want to tunnel the VNC connection.

xmove

Not quite ssh, but when last I asked this question I was pointed to xmove, which didn't work out for me. But maybe you're more lucky.

.Xauthority

I think if you grab your .Xauthority file on your home box and move it local or integrate its authorization info into your local .Xauthority, you can begin to screw with it. But I may just be talking out of my butt here.

xmove

You can use xmove, and application that allow the user to move applications from one X Display to another one. It exists as Debian package. It has a restriction: xmove should be running before you want to move the application. That is all.

There is another project under work, where you can move process between computers (in a similar fashion of xmove). This is being developed using the same code base of swsusp: if you can save a portion of memory to hibernate, you can restore that "image saved" in another computer with similar installation.

I do not remember the name of that project and I am too tired to look at the bookmarks at this hour of the day.

xmove

apt-cache show xmove

-- Of course, it requires you to have started the original app in the xmove pseudo-server as well...

x11vnc, xmove

I see 2 ways to do this.

One is vnc (which you can also use with an already running X indeed), but has that window-in-window failure-to-abstract.
x11vnc - VNC server which uses your current X11 session

Another is xmove, which requires you to have started the apps with xmove before (just like you start terminal apps in screen if you expect to want to continue to use them remotely).
xmove - allows you to move programs between X Window System displays

FreeNX. It may be more of a

FreeNX. It may be more of a solution then you really want.

http://freenx.berlios.de/

Try xmove

Hi Uwe,

You could try xmove. From the desription:
"allows you to move programs between X Window System displays"

Gregor

xmove?

Never tested it, but it seems to do something similar to what you want:

http://packages.debian.org/unstable/x11/xmove