4

I have 2 linux machines up and running. If I connect from one to the other over

ssh -X 192.168.1.6

I am able to start xterm or firefox and the window is displayed as expected at the machine I am working on.

But if I start gnome-terminal or meld, the windows of these programs are displayed on the remote machine.

There seems to be no general authentication problem, as I got no error message. I already found that thread: How can I launch gnome-terminal remotely on my headless server? (fails to launch over X11 forwarding)

and from there the script:

#! /bin/bash
ID=foo.bar$RANDOM
GDK_BACKEND=x11 /usr/libexec/gnome-terminal-server --app-id "$ID" &
sleep .4        # yuck
gnome-terminal --app-id "$ID"
wait

works for gnome-terminal. But for meld is no option --app-id .

I there a way to get the windows displayed on the correct machine?

BTW: linux version is 5.15.12-200.fc35.x86_64 fedora on both machines

How to get it work without any additional scripting and environment hacks:

Simply disable wayland everywhere! On fedora gdm login screen provides a little nearly hidden menu on login screen after you have selected the user to login. There is a little gear wheel, in current gnome version it is down right, and there select "gnome under X11" to get rid of wayland problems. After this also touch screen works, font rendering is improved a lot and mouse pointer calibration is working perfect. None of them is working with wayland... only as a side note! Attention: You have to disable wayland always and everywhere, on host and on remote side!

2 Answers 2

2

As far as I've understood, the important part in directing the program to use the X11 forwarding is the GDK_BACKEND=x11 variable. Without it, a GNOME application will default to Wayland windowing system, which will cause the window to be displayed on the remote machine.

The --app-id is there only to stop gnome-terminal from trying to connect to any other existing instance of gnome-terminal-server which might be running on the same user account on the remote host (associated with a local session on that host), or might be started on-demand by the session D-Bus, unaware of the requirement to use the X11 forwarding. Instead, gnome-terminal will only talk to the specific gnome-terminal-server instance that was told to use the X11 forwarding with the GDK_BACKEND=x11 environment variable.

gnome-terminal only needs the --app-id thing because gnome-terminal is not really a terminal application: it's just a small client application that makes a D-Bus call to gnome-terminal-server which creates the actual terminal window(s). It is a workaround for gnome-terminal being unable to tell gnome-terminal-server: "Hey, when creating this new terminal window, use the X11 backend with this $DISPLAY and $XAUTHORITY instead of whatever default display arrangement you may already have."

If my theory is correct, then you should be able to start meld with a simple:

GDK_BACKEND=x11 meld

If this works, then you could create a simple wrapper script like this:

#!/bin/sh
if [ "$SSH_CONNECTION" != "" ] && [ "$DISPLAY" != "" ]; then
    GDK_BACKEND=x11 /usr/bin/meld "$@"
else
    exec /usr/bin/meld "$@"
fi

Assuming the real meld is located at /usr/bin/meld, you could name this script meld and place it to some directory that is in $PATH before /usr/bin, and then meld would always do the right thing, whether you're running locally or over a SSH X11 forwarding.

Or you might even add to the ~/.bash_profile, ~/.profile or equivalent on the remote machine a simple test to set GDK_BACKEND=x11 for all programs whenever your session is associated with a SSH connection that has X11 forwarding:

if [ "$SSH_CONNECTION" != "" ] && [ "$DISPLAY" != "" ]; then
    export GDK_BACKEND=x11
fi
1
  • OK, meld is now working and indeed it is a problem if remote machine runs a wayland session. If the remote runs wayland, I am still not able to get a gnome terminal up and running on my forwarded connection, only if I run via the script I showed in my question above. The simplest thing I now do: never run wayland! I have so many problems with wayland... I already disabled wayland everywhere. I simply forget it on the new vbox. Thanks to remember me that wayland is the devil everywhere :-)
    – Klaus
    Commented Jan 4, 2022 at 13:01
0

Could do the opposite: install waypipe on both ends (this makes wayland apps forward the way ssh -X or ssh -Y do for X11). You run "waypipe ssh -X (blah)" instead of "ssh -X (blah)" and waypipe modified the ssh command line to forward a port, run a remote waypipe and set the environment variables so wayland apps use it.

Don't have to disable wayland then, your X11 apps will forward over X forwarding and wayland ones over waypipe.

(Note, I'm still using X11 at the moment, so I haven't tried this; but reportedly waypipe works very well.)

2
  • I currently can't try it out because I removed all and everything which is related to wayland. Wayland brakes all and everything for my use cases. It is not able to handle two touch screens on a single PC, it is not able to handle two mouse pointers, it can not manage window handling on multiple devices if one of them is remote and hundreds of problems more. Most important: There is no support at all! You can ask everywhere, on mailing lists, on dev community, ask god. No answer! I stay as long as possible on X. Maybe by keeping old systems on a virtual machine! Wayland is still a nightmare!
    – Klaus
    Commented Feb 6, 2023 at 10:47
  • Gotta admit the support is what turned me off Wayland. "Wayland can't do (some use case)". The answer was NEVER "Not supported yet, but here's how we could do that", it was "Why would you want to do that?" Until waypipe came out that was the response to "I want to run individual programs remotely" ("Why? Use remote desktop") to the point that I assumed wayland had a graphics API rather than a protocol to serialize. (Waypipe just serializes wayland commands and dmabufs so they can be run over a connection.)
    – hwertz
    Commented Feb 7, 2023 at 17:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .