Is Exporting Librem 5 Graphical Programs Really Broken?

A while back, I created a topic in this forum asking for help to set the graphical display back to a PC when remoting-in to the Librem 5 via ssh. I thought I was doing something wrong when I couldn’t get that working. But after a few days of hacking on my Linux PC and my Librem 5 to get them to work together, I am starting to wonder if that fearure is broken on the Librem 5. I use ssh sometimes at work. Back before ssh was available, I used rlogin a lot. So I am no stranger to making this fearure and ones like it work. But after two days of heavy hacking, I had no luck. Each time I tried something new, I expected it to work. Even with several edits to the sshd_config file on the Librem 5, exporting the display to a PC is still broken on the Librem 5, at least to me. The best I could do is to get only x11 programs (xeyes, xclock, etc) running on the Librem 5, to display via my Ubuntu box, on the PC monitor byexporting the display from the localhost 127.0.0.1:10, on the Librem 5. But that feels like a weak workaround and none of the gnome applications will export to an external PC that way.

The reason this matters so much to me is that I can’t imagine creating an applications development environment that doesn’t put the Librem 5 phone display on the Development PC monitor. The consolation today was at least being able to edit text files on the Librem 5, using vi, while remoting in to the Librem 5 from my Ubuntu box. At least SSH gives me a bash prompt to work with on the PC. I even tried working both with and without using my VPN network and my non-vpn network, suspecting that my COX internet router might be blocking something within my own internal network.

So the question is: are the graphical programs broken as an export to remote PCs? Has anyone out there been able to get gnome-chess (for example) running from their Librem 5, to display on their PC, via ssh? If you can do it, please tell me how you got it to work. Setting up an internal VNC connection (just within my home) might be good too if that’s what it takes.

1 Like

When you say “export the display” I assume you mean X11 forwarding (ssh -X)? That works, just make sure WAYLAND_DISPLAY isn’t set:

ssh -X  -v <yourphone> 'WAYLAND_DISPLAY= gtk4-demo'
5 Likes

The earlier topic is presumably: Nothing Works to Set Display Back During SSH

so, yes.

For the benefit of the OP, the spacing in that remote command is critical.

2 Likes

At this point, I think I would rather just completely turn off Wayland and use x11 for my Librem 5 display. The reason is that I selected “X11Forwarding yes” in the /etc/ssh/sshd_config file and that didn’t do any good. I also tried “x11Uselocalhost no”. I’ve never needed to communicate directly with the localhost on a remote client before. That doesn’t seem like a good practice. Am I correct about that? Maybe the nuclear option (no Wayland anywhere), might help. Also, I am using the ssh -X option. That doesn’t seem to help. But since I had some luck with a few x11 programs via the client’s localhost but that the gnome programs wouldn’t work that way, I think it’s likely that Wayland is causing the problem.

The Librem 5 doesn’t have an /etc/gdm directory nor an /etc/gdm3 directory. echo $XDG_SESSION_TYPE does return “wayland”. How do I access the file to make the system display be x11 by default after every boot?

1 Like

Partially Solved:
The Librem 5 appears to be designed to use Wayland as the XDG session type on your phone display. The XDG session type is how your windows are managed. There are Wayland (the newest), X11 (what we had before Wayland), and tty (much older). SSH can use any of the three types of XDG protocols to connect two PCs. But both machines need to use the same protocol (tty, or x11, or wayland) to communicate. In all SSH sessions, the Librem 5 defaults to tty (the oldest XDG session type, that is not capable of communicating with Wayland sessions nor exporting graphical displays). However X11 appears to be backward compatible with tty. So the older x11-apps (an actual suite of older x11 applications originally written for x11 displays and that are a part of the official “x11-apps” suite of applications ) will run and display those graphical x11 applications remotely when using an SSH session via tty. But you can’t open a remote display from Wayland via a tty protocol. The Librem 5 does all ssh sessions using tty. My Ubuntu PC can open Wayland sessions with other Linux PCs that use Wayland for ssh also. But the Librem 5 only does ssh via tty. So some backward compatible x11 apps will work via an ssh session with the Librem 5. But many x11 apps and all apps written for wayland will fail to open a graphical display when communicating via ssh with the Librem 5. The best you can get in most cases is a bash window via ssh.

The way to test this on your own is to initiate an ssh session to your Librem 5 from your Linux PC. From your pc when logged in to the librem 5, you’ll be in a terminal window. Type in: echo $XDG_SESSION_TYPE . You should see a return of: tty . Then type the same thing in to a terminal window on your Librem 5. You will then see a return of: wayland .

Here is how to run a few x11 apps from your Librem 5, on your Linux PC. Use ssh to log in to your Librem 5 from your Linux PC.

ssh -X purism@192.168.xx.x
Use the actual ip address from the IP app on the Librem 5.

Set the display back from your Librem 5 to your PC from that ssh session.

export DISPLAY=127.0.0.1:10

I think that with all of the wayland stuff running on your phone and on your PC, that Wayland blocks access to your PC via your IP address, when using tyy. I had to use the localhost address (127.0.0.1:10) to get the Librem 5 display to show up on my PC monitor, and only those older x11-app programs worked graphically via ssh. You may have to download and install some of the older x11-apps to your Librem 5 to make this work. Xeyes, xclock, or xcalc are just a few. I can’t remember if I installed those myself or not.

I tried to disable tty on the Librem 5 by editing /etc/ssh/sshd_config file in hopes that the x11 would take over. All that did was break ssh. So I had to re-enable ssh from a terminal on the Librem 5 to get ssh working again. I thought to disable wayland on the phone but realized that that could break the display configuration, thus locking out the display (and me). So until someone can get ssh on the Librem 5 to use wayland, purism should document this flaw.

Can anyone else out there verify this information for me? Just logging in to your phone from a pc via ssh and then verifying the xdg session type (described above) as tty should be all that is needed. It is possible (but unlikely) that only my phone has this flaw. I saw some esoteric looking fixes for this on the internet. But I didn’t want to trust the fate of my Librem 5 to some stranger who said “try this”, and could brake the phone.

3 Likes

At this point, I think I would rather just completely turn off Wayland and use x11 for my Librem 5 display.

The graphical session run on the device is all Wayland.

Note that what I wrote above disables Wayland for remote forwarding rather than enabling it. You can automate this by adding

if [ -n "$SSH_CLIENT" ]; then
	export WAYLAND_DISPLAY=
fi

in .bashrc on the Librem 5

4 Likes

Wayland is just a set of protocols and the session type XDG_SESSION_TYPE=wayland indicates that apps should prefer that protocol over other ones. It doesn’t block anything and things fall back to x11 where needed using XWayland (that’s why you can type xterm on the phone and it will open a local window).

The issue you have on the L5 is that apps try to be smart and when logged in via ssh detect that there’s a Wayland socket in /run/user/<userid> and prefer that one over using x11. By setting the WAYLAND_DISPLAY to empty (or something other non-sensical) GTK apps fall back to x11.

4 Likes

If the Librem 5 can’t use an ssh session using Wayland, then ssh communications is probably not a good configuration for Librem 5 application development. Granted, a bash prompt on a big screen using a keyboard and mouse is better than doing development on the screen and keyboard of the phone. But if exporting a display on the Librem 5 is limited to tty protocol, then Purism either should have, or should now document that for us. As a non-expert in this area, it took me a solid three days to learn the different protocols and to figure this out on my own.

Has anyone here had any luck getting the Librem 5 working using VNC, and with a remote graphical environment working via VNC? I would rather not have to spend another three days or more figuring this out by myself. The phone has some kind of VNC configurations settings. I don’t know how to use them. But I do have my own router-level VNC network with a WIFI connection to it.

I guess that convergence using USB and the phone’s own big-display desktop might be the only good option left.

1 Like

Of course it can. It’s just a regular GNU/Linux computer, you can use regular tools like wayvnc, waypipe or X11 forwarding via ssh tunnel just like you would when remoting to any other PC.

2 Likes

Thanks dos,

After your reply, I tried something that did work to export the display for most programs. When gnome-chess came up on the remote pc (where it is not installed), I knew that the issue was mostly resolved for me. Firefox crashed the ssh session. But several other (all gnome) programs worked. Feel free to critique my instructions below if you have a better method as I came here looking for advice.

The method of setting the display to a remote client now requires the use of export WAYLAND_DISPLAY=192.168.0.1:0 (your actual ip address replacing mine in this example). I am more old-school, using:
export DISPLAY=192.168.0.1:0. That old-school method doesn’t work any more as I found after three days of everything not working. Interestingly though, even though it’s working now, the XDG session type still shows as tty when Wayland is running remotely.

For those who want to use a remote display, even on later programs, here is what works most of the time.

1.) From your Librem 5 terminal type: xhost + [ENTER]
This lets any device remote-in to your Librem 5 as a remote connection. Alternately, you can use: xhost (your client device ip address) . This is much more secure. The Librem 5 wouldn’t let me run xhost remotely. But it works from the Librem 5 itself.

2.) From your linux PC terminal type: ifconfig [ENTER]. Then write down your PC’s ip address. Example: 192.168.0.74 .

3.) From your What IP app on the Librem 5, write down the ip address. Example: 192.168.0 90.

4.) From your Linux PC terminal type:
ssh -X purism@192.168.0.90

5.) After step 4, you are actually logged in to your Librem 5 from your PC. The terminal session on your PC is actually from your Librem 5 as a remote connection.

6.) You can verify the remote connection by seeing “purism@pureos:~$” from the terminal on your PC, just like it shows up on a terminal session on your Librem 5.

7.) Type:
“export WAYLAND_DISPLAY=192.168.0.74:0” (from step 2 and without the quotation marks). Your ip address may be different.
This tells the Librem 5 to open its programs on the PC display, not on its own display.

8.) From the terminal session on the PC type “gnome-chess” (no quotation marks). If gnome chess opens on the PC screen, it works. If it opens on your Librem 5, something wasn’t done correctly.

9.) You can open most programs this way if you can find out the program’s real name. For example, if you type “chess” the “gnome-chess” program will not open. Theoretically, you should now have full access to all programs and settings on your Librem 5, from your Linux PC.

1 Like

SSH is a bit different from that. It is more like a swiss army knife protocol.

The bottom line for SSH is that it establishes a secure connection between two computers. That’s it.

That secure connection then multiplexes any number of channels over the top of it. A channel may be carrying

  • a shell session (in the forward direction)
  • an arbitrary TCP connection (in the forward direction)
  • an arbitrary TCP connection (in the reverse direction)
  • X11 (in the reverse direction)
  • file access (in the forward direction)

where “forward” means “client to server”.

As such, while SSH was a great improvement over telnet from a security point of view, SSH is actually a bit of a security nightmare. (That’s no big deal of course if your are the sole user of client and server, particularly if client and server are on the same local network.)

2 Likes

Thanks Irvingwade. I am still learning. With three days of failure, I probably won’t forget how to make this work going forward. At work, I am spoiled. The domain there knows me. The IT department there apparently has built in a lot of alias definitions that cause old outdated commands to still work. So I know what to expect as outouts. But the required inputs in the real world can be quite unforgiving. The online advice found in google searches can be years old. The first time I saw a “WAYLAND_DISPLAY=” command was in this thread. I tried it and it worked.

To assist in the ssh connection, on my Linux PC, I created a user named “purism”, and gave that user a password of 123456. I used that profile in the ssh connection to the Librem 5. I don’t know if that helped with the connection or not. On an applications development PC, should the user share the same name and password as is used on the Librem 5? Without a domain to manage permissions, I wasn’t sure where the authentication originates from. My guess now is that with an xhost +, any user can probably log in to the Librem 5 remotely.

1 Like