6

My default application for opening PDF files is Adobe Acrobat XI Pro.

I would like to be able to open PDF files using this program via the Windows Subsystem for Linux.

Currently when I run xdg-open main.pdf I am getting this output:

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/run-mailcap line 528.
Error: no "view" rule for type "application/pdf" passed its test case
       (for more information, add "--debug=1" on the command line)
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'main.pdf'

Running xdg-mime query default application/pdf gives me evince.desktop . I am not sure what this is.

Running grep -i "pdf" /usr/share/applications/defaults.list gives me:

application/pdf=evince.desktop
application/x-bzpdf=evince.desktop
application/x-gzpdf=evince.desktop
application/x-xzpdf=evince.desktop
3
  • 1
    I don't think there is any practical way at all of doing this before 1903 (currently in Insider Preview); are you running that? If not there's no viable xdg-mime configuration that could do it and you'll need to wait a few months. Commented Apr 5, 2019 at 4:57
  • @MichaelHomer right now I'm running version 1803 and was about to upgrade to 1809
    – Abraham
    Commented Apr 5, 2019 at 4:59
  • 1
    1903 has a 9P server and associated Windows VFS support to access files inside the Linux environments, but you can't get to them from the outside before that. The one other hope is that if all the PDFs you want to access are inside /mnt/... you could reverse-engineer the host paths (i.e. turn /mnt/c/foo/bar.pdf into C:\foo\bar.pdf) and launch Acrobat against that, but otherwise I think you're out of luck for the moment. It's going to be a bit tricky even afterwards but I imagine someone will build the tooling once it's doable. Commented Apr 5, 2019 at 5:05

1 Answer 1

3

It seems to me that you're trying to open a file from the Windows Subsystem for Linux but with a program (Adobe Acrobat) installed on your Windows host OS.

In this case I suggest you to not use xdg-open but to simply pass the open command from Bash to the Windows terminal directly (note: I'm expecting Adobe Acrobat to be your default pdf reader on Windows).

This can be done from Bash in the WSL by typing:

cmd.exe /C start <your file>

This will open the Windows terminal in the background, evaluate which program use to open the file (using Windows default file associations) and if successful open the file in Windows (you can find the same information by typing cmd /? in cmd.exe).

To avoid typing the full line every time you can also alias the open command by editing the .bash_aliases file:

open='cmd.exe /C start'

This will allow you to do open <file> using Windows file associations.

4
  • There is a good reason to open a Windows native program from xdg-open. When I do a man, many commands show URLs that I would like to open clicking on them. Those clicks trigger xdg-open which I would like to open with chrome.exe
    – nephewtom
    Commented Jun 17, 2019 at 11:26
  • @gibbone would it work if I add it to .bashrc? Like this : alias open='cmd.exe /C start'. The command you provided works but open doesn't work.
    – Agent 0
    Commented Jun 16, 2020 at 22:28
  • @Kourosh if the command works maybe there is something missing in the way you defined the alias. Have you tried modifying directly the .bash_aliases file? Also, after modifying .bashrc have you tried doing source .bashrc? Here you can find more help, maybe.
    – gibbone
    Commented Jun 17, 2020 at 20:16
  • I didn't change anything but somehow it got fixed on its own! open <file_name> works fine now, thanks!
    – Agent 0
    Commented Jun 19, 2020 at 6:07

You must log in to answer this question.

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