Score:1

xdg-open not working via ssh terminal session

al flag

I have performed file association for my custom extension(.vwxy), I have created the mime specification file and the desktop entry file for that.

I m able to launch my application via xdg-open <myfile.ext> on the terminal in ubuntu 20.04, but doing the same via ssh terminal session does not launch my application.

But my extension is registered for the mime, and the mime is registered for the application as can be seen by the result of the following commands in the ssh terminal.

gio info myFile.vwxy | grep "standard::content-type"

output : standard::content-type: application/myMimeType

 gio mime application/myMimeType

output:

Registered applications:
        MyApp.desktop
Recommended applications:
        MyApp.desktop

Is there anything that I m missing?

Terrance avatar
id flag
Does your `ssh` session have X forwarding enabled from the client by using `-X` or `-Y` when connecting to the server?
Vipul Gupta avatar
al flag
@Terrance No, It does not have it enabled. But how will it anyways impact the working of xdg-open?
Terrance avatar
id flag
xdg-open will open either an html link or a file. Either way, it is trying to launch a graphical application. X forwarding will send the data to the computer you are using generating the graphical application on your screen instead of the server.
Vipul Gupta avatar
al flag
Mine is not even a GUI application, it is a console application without any GUI component. Any idea why is it happening in that case?
Terrance avatar
id flag
One thing I have noticed is that whenever you try to run any application it tries to launch it on the local system and not the remote system through ssh. You might want to see: https://askubuntu.com/questions/1465485/xrandr-listproviders-not-showing-any-graphics-cards/1465540#1465540 where I show how a non-graphical application like `nvidia-smi` is returning my local system info and not the remote system info. You might be able to solve the it by running it through connecting to the other host with either a VNC connection or a RDP connection where it keeps the resources local to that system.
Terrance avatar
id flag
Sorry, that was xrandr that showed my local, not nvidia-smi
Vipul Gupta avatar
al flag
So, I understand about the GUI but should I be able to launch console application using xdg-open in an ssh session?
Terrance avatar
id flag
I am out of suggestions for you since you don't seem to want to try running your application with a `-X` connection. Your question also does not successfully show what your application is, so it is virtually impossible for me to come up with an answer for you.
Score:0
us flag

D-Bus is the reason here, a system for communication between applications.

If you login into your desktop (i assume Gnome), a dbus-daemon for you user is started automatically. If you login per ssh, the dbus variables are usually set to use the already running D-Bus session from a Desktop session (was first weird to me..)

To see it in action, just use this: You can use "watch -n 0.1 ps ux -U harry" to see the processes for the user "harry" using a different user per ssh. You can look at it during start of the Desktop session or during the ssh login.

A workaround is possible - to me it is a little like to betray the apps by giving them only the part they need.

This is from the dbus-run-session man page:

DESCRIPTION
       dbus-run-session is used to start a session bus instance of dbus-daemon from a shell script, and start a specified program in that session. The dbus-daemon will run for as long as the
       program does, after which it will terminate.

       One use is to run a shell with its own dbus-daemon in a text‐mode or SSH session, and have the dbus-daemon terminate automatically on leaving the sub‐shell, like this:

       dbus-run-session -- bash

       or to replace the login shell altogether, by combining dbus-run-session with the exec builtin:

       exec dbus-run-session -- bash
       ...

After you have the shell on the remote machine (i assume bash), run these commands:

 > export XDG_CURRENT_DESKTOP=GNOME
 > dbus-run-session -- bash

Then you have a shell and e.g. xdg-terminal worked for me. I assume the same applies to your use case.

How i got to this: I had a similar problem on my openSuse machine. After some hours i read a part of the D-Bus docs tried "dbus-monitor", "dbus-launch gnome-terminal" read the xdg-temrinal man page, and as last compared the XDG environment (env| grep XDG | sort), then use one of these variables.

The same Problem i had with the gpg passphrase dialog - is was using text mode when using ssh-X to login. but after starting the DBus, a GUI based dialog opened.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.