If I ssh into a machine, I can run graphical applications if I enable X11 forwarding - I run gedit from the command line, and gedit pops up as a window. My question is this: Is there a way to make a window pop up for applications that are already running?
Example: Suppose I have two machines, A and B. I open gedit on A, and type some text and leave. Then I ssh into A from B. If I run gedit I'll just spawn another process. Can I access the gedit process that's already running (with some text)? Or is this a job for vnc?
Answer
Not really a solution to literal "grabbing windows of programs already running", but still…
Use xpra.
On X11, it is also known as screen for X11: it allows you to run programs, usually on a remote host, direct their display to your local machine, and then to disconnect from these programs and reconnect from the same or another machine, without losing any state.
[…]
Xpra also allows forwarding of sound, clipboard and printing services. Sessions can be accessed over SSH, or password protected over plain TCP sockets with or without SSL.
It has to be installed, configured and started beforehand, just like screen or tmux for console applications. You have to run your program via xpra in the first place, then you can do the magic of (re)connecting from different machines.
xpra is available as xpra package at least in Debian and Ubuntu. I have used it few times. The performance was better than for plain X forwarding.
Examples are here. The following are from man xpra on my Kubuntu:
xpra start :7Start an
xpraserver using display number:7.DISPLAY=:7 firefoxStart
firefoxrunning inside thexpraserver. Run this on the host wherexprawas started or in terminal forwarded byxpra. No window will appear until you attach withxpra attach.
You run the above examples on your A. Then you can attach directly from A:
xpra attach :7Attach to the
xpraserver that is using local display number:7. Any apps running on that server will appear on your screen.
or from your B:
xpra attach ssh:foo@frodo:7Use
sshto attach to thexpraserver that is running on machinefrodoas userfooand using display:7. Any apps running on that server will appear on your local screen.
No comments:
Post a Comment