A Weird Imagination

Detachable X sessions

X forwarding#

Normally with X, it's easy to run an application on a remote computer just by using X forwarding:

local:~$ ssh -X host
host:~$ echo $DISPLAY
localhost:20.0
host:~$ xterm

The xterm will appear on your local computer.

But if you want to continue working with that application on a different remote computer (or once you are physically in front of the computer it is running on), then you're out of luck.

For an application running in the terminal, you can start it inside a GNU Screen (or tmux) session which you can detach and then attach to again on another ssh connection.

GNU Screen for X#

xpra (X Persistent Remote Applications) lets you move graphical applications from one computer to another in addition to fixing other problems with X forwarding. If you instead use xpra for the forwarding, then you can detach and reattach to the session at will.

For the initial setup, do

local:~$ ssh host
host:~$ xpra start :30
Entering daemon mode; any further errors will be reported to:
  /homes/gws/perelman/.xpra/:31.log
host:~$ DISPLAY=:30 screen -S xpra-test
host:~$ xterm

Then on the computer you actually want to interact with the graphical application on:

local:~$ xpra attach ssh/host/30

The xterm should appear, along with any other graphical applications you run in the xpra-test screen session.

To detach, either run

local:~$ xpra detach ssh/host/30

or simply attach on a new host and the first host will be automatically detached.

The details#

Why :30?#

Really any high numbered display should be fine. As xpra's man page notes, lower numbers are used by local X sessions and ssh forwarding, so starting at :30 or higher just gets out of their way. Unfortunately, unlike screen, xpra can't just use any names it wants because X programs expect to be given a display number.

Not just graphics#

The primary advantage of using X forwarding or xpra instead of VNC is that you get separate windows and features like copy and paste and drag and drop work. In general, applications act just like they are running on your local machine.

Additionally, xpra supports forwarding sound using PulseAudio, although I haven't gotten it to work yet.

Competitors#

NX also supports detaching and re-attaching sessions, although its original design goal was making X work better over poor network connections (which xpra also has some features for). NX has some licensing issues; the recent official versions are closed, but there are open-source forks of the older versions that are maintained.

xmove is a predecessor to xpra that stopped development in 1997.

Comments

Have something to add? Post a comment by sending an email to comments@aweirdimagination.net. You may use Markdown for formatting.

There are no comments yet.