Running graphical Linux programs remotely through Xpra

Tags linux xpra

You can install and use Xpra on your Linux, Windows, or Mac device to run graphical applications through an SSH connection to a remote Linux computer, such as colossus.it.mtu.edu or guardian.it.mtu.edu. 

Colossus and Guardian are for students to perform coursework remotely on a Linux machine and are configured to not require a VPN connection. Xpra is also installed on fully managed RHEL8 office workstations, but you will need to connect to the VPN on your computer in order to connect to them.

Linux

  1. Connect to the VPN if you are off-campus and you are connecting to a RHEL8 fully managed office workstation.
  2. Install Xpra on your computer. It may be available from your distribution’s repositories, although Xpra recommends avoiding distribution packages. You can also download and install from Xpra’s Linux downloads.
  3. Open a terminal.
  4. Run a command with the following format. Xpra recommends including --pulseaudio=no, which will disable audio forwarding to save CPU and bandwidth. You can remove this option if you need to use audio. Read on for suggestions on a more convenient way to use Xpra and find applications’ commands.
    xpra start ssh:username@computername --exit-with-client --exit-with-children --start-child=”application” --pulseaudio=no
  5. Enter your Michigan Tech account password when prompted. Note that the password prompt can be followed by debug output, making it unclear that the program is waiting on you.
  6. A window should display, if the command entered creates a GUI. If you run a terminal, any windows you create from it will also appear.

Windows or Mac

  1. Connect to the VPN if you are off-campus and you are connecting to a RHEL8 fully managed office workstation.
  2. Install Xpra on your computer from Xpra’s download section. You may receive warnings due to Xpra not currently being a Windows verified publisher and Xpra moving to https from http rather slowly.
  3. Open Xpra.
  4. Select Start.
  5. Select or enter the following in the next window.
    • The defaults: Seamless Session, Remote Host, SSH on port 22.
    • Enter your Michigan Tech account name.
    • Enter the remote computer name. For example, colossus.it.mtu.edu
    • Display: Leave blank
    • Command: Enter the command for the application you would like to run. Read on for suggestions on a more convenient way to use Xpra and find applications’ commands.
    • Xpra recommends opening the “three-check” icon or volume icon’s menus and disabling audio forwarding to save CPU and bandwidth.
    • Select both the “exit with application” and “exit with client” checkboxes. Unchecking the former may necessitate the use of the “Attach” menu instead of the “Start” menu in the future. Though ssh sessions will close after some period of no activity automatically, please check the latter to conserve resources short-term.
  6. Select Start & Attach.
  7. Enter your Michigan Tech password when prompted.
  8. A window should display, if the command entered creates a GUI. If you run a terminal, any windows you create from it will also appear.

Additional features

Xpra has many additional features. Please note that while Xpra’s dynamic switching between various compression algorithms and enhancements, such as scroll detection, make it much faster than X forwarding or VNC, it suffers from the same unpredictable application functionality. Many applications may not launch at all, while others may work perfectly out-of-the-box or once launched with certain arguments (e.g.,  --no-remote --no-xshm for Firefox).

Running applications

Running a terminal such as xterm may be helpful. This will prevent the whole connection from dropping if an application crashes. It also, as shown below, allows you to search for an application’s correct name and start multiple applications.

Some application commands do not match up perfectly with their names or are inconsistent across Linux distributions. Some examples are: Google Chrome, which is google-chrome-stable; VSCode, which is simply code; and IntelliJ, which is either intellij or intellij-idea-ultimate-edition depending on the Linux distribution.

Commands may also not be in standard directories, meaning they cannot be tab-completed. In addition to starting to type the name and hitting tab twice to see similar options, one can use the following command:
grep -RFil “name” /usr/share/applications

For “Chrome” this returned the following:
/usr/share/applications/mimeinfo.cache
/usr/share/applications/google-chrome.desktop
/usr/share/applications/org.gnome.ChromeGnomeShell.desktop

Running gtk-launch google-chrome will run google-chrome-stable, the actual command for Google Chrome as outlined in /usr/share/applications/google-chrome.desktop which we found with grep.

Multiple applications

If you’d like to run multiple applications, add &>/dev/null & to your command. For example, to run Mathematica and leave the terminal available, use the command:
mathematica &>/dev/null &

The &>/dev/null section silences its output, which can hide errors but allows one to still type without Mathematica interrupting. The & is the important part and runs the application in the background. Without it, the terminal would wait for Mathematica to exit before one can use the terminal. Mathematica would still close if one closed the terminal window using the above method, but running the disown command immediately after would prevent that behavior.

Further usage

There are many other ways to use Xpra. In an advanced example, one can start Xpra by specifying a local X display number. Then one can export that DISPLAY in the window manager configuration (or whatever else applications are launched from) to make it as though one is sitting at the remote computer. Visit Xpra’s Usage wiki page for more examples.

Details

Article ID: 144168
Created
Tue 6/14/22 11:27 AM
Modified
Fri 7/1/22 7:11 AM