Create desktop files to open applications via xdg-open in wsl

@Azeved00 I am trying to replicate your issue. I am using NixOS, though, not Debian. But I am using WSL 2.

And, I agree, the behavior of xdg-open is weird. I am not getting the exact same errors and issues as you. But no matter what I do, xdg-open insists on opening a PDF with elinks (which I have installed), even though xdg-mime query filetype and xdg-mime query default application/pdf do, in my case, return the correct values. Go figure.

For an entertaining read/rant on xdg-open, see this thread.

So… might you consider using an xdg-open alternative, like handlr or wsl-open? Both are available in nixpkgs. If I were in your shoes (which I kinda am, using WSL on my laptop at work), I would just use wslview by itself, or look at handlr.

Something else interesting: what happense if you execute the following?

export BROWSER=wslview

Then try xdg-open? I was pleasantly surprised by the results in my setup.

1 Like