xpra

  • 4 Replies
  • 2191 Views
*

Parsifal

  • Official Member
  • 36115
  • Bendy Light specialist
xpra
« on: September 23, 2011, 08:06:00 PM »
xpra is a programme which allows you to run X11 applications on one computer, and then connect to them from the same or any other machine. The difference between xpra and other methods of X11 forwarding is that:
  • applications you attach to with xpra appear on your desktop as any other program would, and
  • those applications stay open even once you disconnect from them, allowing you to reconnect later from the same or any other machine.
Some other X11 forwarding mechanisms share one of the above traits, but xpra is the only one (to the best of my knowledge) that possesses them both at the same time. Those who are familiar with the excellent programme GNU screen will know what I mean when I say that it is screen for X11.

Currently, I am using it to run XChat on my server and connect to that from home. This means that I can remain permanently connected to all my favourite IRC channels, even when my computer at home is shut down. In other words, I'll never miss any scrollback again.

And, since it can do X11 forwarding over SSH, I can authenticate using my existing SSH key that I use when I want to open a shell on my server, and all data is transmitted across one of the most secure network protocols available.

I've taken the time to work out how to get XChat on my server to use my GTK+ theme of preference, so that its menus, buttons and so forth look the same as everything else on my desktop.

The only remaining differences in appearance and behaviour from running it locally are:
  • It's slower. You can't avoid slowness when your software is running on another continent.
  • There is no icon in the notification area to tell me when I receive new messages. That's fine, I can live with that in exchange for the enormous benefit of being persistently connected.
If you're interested in reading further, see http://code.google.com/p/partiwm/wiki/xpra. If you would like to install it, there is currently an xpra package in Debian's testing and unstable distributions (though unfortunately not in stable or stable-backports yet; I had to backport it myself to install on my server, which fortunately went very smoothly).

Finally, here is a more technical overview from xpra(1):

Quote
DESCRIPTION
       Xpra is a tool which allows you to run X programs — usually on a remote
       host — and then direct their display to your local machine,  disconnect
       from  these  programs,  and reconnect from the same or another machine,
       all without losing any state.  It differs from standard X forwarding in
       that  it  allows  disconnection and reconnection without disrupting the
       forwarded application; it differs from VNC and similar  remote  display
       technologies  in that xpra is rootless: i.e., applications forwarded by
       xpra appear on your desktop as normal windows managed  by  your  window
       manager,  rather than being all "trapped in a box together".  Xpra also
       uses a custom protocol that  is  self-tuning  and  relatively  latency-
       insensitive,  and  thus is usable over network connections that are too
       slow or unreliable for standard X forwarding.
« Last Edit: September 23, 2011, 10:53:52 PM by Parsifal »
I'm going to side with the white supremacists.

*

Parsifal

  • Official Member
  • 36115
  • Bendy Light specialist
Re: xpra
« Reply #1 on: September 23, 2011, 08:19:11 PM »
Here is a screenshot of XChat running remotely using xpra over SSH, alongside Pidgin running locally. Note that they look exactly the same in terms of the colour and style of menus, buttons, scrollbars, and so forth.


Click for full size.
I'm going to side with the white supremacists.

*

EnigmaZV

  • 3471
Re: xpra
« Reply #2 on: September 23, 2011, 10:04:17 PM »
That's actually pretty neat. It's like your own personal SaaS.
I don't know what you're implying, but you're probably wrong.

*

Parsifal

  • Official Member
  • 36115
  • Bendy Light specialist
Re: xpra
« Reply #3 on: December 23, 2011, 05:58:16 AM »
I've concocted some simple daemontools scripts to manage xpra. For the uninitiated, daemontools is an init system that will automatically restart your process if it dies.

On the server side:

Code: [Select]
#!/bin/sh
cd ~steven
exec setuidgid steven xpra start :0 --no-daemon

And on the client side:

Code: [Select]
#!/bin/sh
cd ~steven
. ~steven/.keychain/luke-sh
export DISPLAY=':0.0'
export XAUTHORITY='/home/steven/.Xauthority'
exec setuidgid steven xpra attach --encoding=png -z9 ssh:steven@palpatine.steven-mcdonald.id.au:0

Then on the server side, I can create a separate daemontools service for each programme I want to run remotely. Currently, I only do this for xchat:

Code: [Select]
#!/bin/sh
cd ~steven
export DISPLAY=':0'
exec setuidgid steven xchat

This ensures that xpra and xchat are always running on the server, and that xpra attaches to the server automatically on my computer and gets restarted if it dies for some reason.
« Last Edit: December 23, 2011, 06:00:38 AM by Parsifal »
I'm going to side with the white supremacists.

*

Parsifal

  • Official Member
  • 36115
  • Bendy Light specialist
Re: xpra
« Reply #4 on: December 25, 2011, 02:54:12 AM »
An improved version of the client-side script, which waits for my SSH key to be available in my ssh-agent before attempting to connect:

Code: [Select]
#!/bin/sh
cd ~steven
export DISPLAY=':0.0'
export XAUTHORITY='/home/steven/.Xauthority'

while ssh-add -l 2>/dev/null | awk '{if ($3 == "/home/steven/.ssh/id_rsa") {exit 1}}'
do
        sleep 1
        . ~steven/.keychain/luke-sh
done

exec setuidgid steven xpra attach --encoding=png -z9 ssh:steven@palpatine.steven-mcdonald.id.au:0
I'm going to side with the white supremacists.