fabiospampinato / vscode-open-in-application

Open an arbitrary file in its default app, or the app you want.
MIT License
20 stars 0 forks source link

Usage of xdg-open on unix system #8

Open ghost opened 5 years ago

ghost commented 5 years ago

Thanks for your extension

On linux systems, any file can be open with the system default application using the command xdg-open

For example in Fedora, xdg-open example.pdf will use evince to open example.pdf

Maybe this behavior could be enabled with a settings ?

fabiospampinato commented 5 years ago

We are using open under the hood for opening those applications. I think open itself is using xdg-open if no better solution is found (https://github.com/pwnall/node-open/blob/2d20d7c8946b2da243a59d9c727953bf06d77611/lib/open.js#L50), maybe the version of xdg-open that it's using is not up to date or something?

What is your use case?

ghost commented 5 years ago

I don't know what's the expected behaviour, but to be able to open pdf, i needed to add this to my settings.json :

  "openInApplication.applications": {
    "xlsx": "libreoffice",
    "xlsm": "libreoffice",
    "pdf": "evince",
    "adoc": "google-chrome",
    "html": "google-chrome"
  },

But i don't think this association is necessary, since in my terminal i can type: xdg-open test.html -> google-chrome is launched xdg-open test.pdf -> evince is launched

So i think it would be nice to see the extension using the system default application if the association is defined.

I hope this is more comprehensible

fabiospampinato commented 5 years ago

Isn't this already the case? What happens if you don't have any explicit association for the pdf extension and you trigger Open in Default Application from the context menu?

ghost commented 5 years ago

Nothing happens without explicit association.

fabiospampinato commented 5 years ago

Then that's a bug 🤔

ghost commented 5 years ago

How can I help you to get more information about the bug ? Nothing shows up on the dev console.

I'm on elementary os juno (a distribution based on ubuntu 18.04).

fabiospampinato commented 5 years ago

It's probably a bug in our open dependency. You can try replacing it with the more modern opn library instead, if that doesn't work either the problem is probably in the library itself.

ghost commented 5 years ago

Ok, i'll make a pull request if i get any result.

fabiospampinato commented 5 years ago

@pomdtr Ok, let me also know if that doesn't work, so that I can start thinking about another possible solution.

andreabenini commented 2 years ago

Hi @fabiospampinato , I've installed this app just like others folks on Linux (AMD64, Linux Arch, Current) and I can confirm same behavior. Linux Gnome/gtk users have xdg-open shell utility to open default applications, usually located at: /usr/bin/xdg-open, they don't have 'open'.
I've tried to create a soft link as well as a dummy shell script named open and saved as /usr/bin/open with these contents:

#!/usr/bin/env sh
/usr/bin/xdg-open "$1"

in order to simulate possible MacOS env but it doesn't work. This dummy scripts works fine entering open somefile.pdf from terminal and default app is selected (evince in my case, like many others) but it doesn't work from your vscode plugin. Are there other tests you'd like to have from it ? Dirty hacks like :

    // Open in applications plugin
    "openInApplication.applications": {
        "*": "/usr/bin/xdg-open"
    },

won't work so I'll manually insert file extensions as suggested from other users

fabiospampinato commented 8 months ago

Can anybody check if this is fixed in v2 of the extension?