nephewtom
nephewtom

Reputation: 3121

Open Windows native exe program via xdg-open in WSL

When using man in Linux, many commands list URLs, which in some terminals like gnome-terminal or terminator are clickable.

For example, man ls shows:

A clickable URL when hovering over with the mouse

Which allows to click on http://www.gnu.org/software/coreutils.

Clicking on it in Gnome terminator under WSL makes it hung.
And shows this output in the terminal that started terminator:

etomort@ES-00002604:/mnt/c/Users/etomort
$ /usr/bin/xdg-open: 782: /usr/bin/xdg-open: : Permission denied
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: x-www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: firefox: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found


[1]+  Stopped                 terminator  (wd: ~)
(wd now: /mnt/c/Users/etomort)
[2]   Done                    terminator

Is there a way to make xdg-open in WSL to call a Windows exe program?

Note: this question is related but more specific.
And the only answer is not useful for this purpose.

Upvotes: 2

Views: 3297

Answers (3)

ArtemGr
ArtemGr

Reputation: 12567

SQLite uses xdg-open to open query results in an external program (.excel).

Given that wslview from wslu was failing with Access is denied, I've linked xdg-open to wsl-open:

sudo apt install nodejs
sudo npm install -g npm
sudo npm install -g wsl-open
cd /usr/bin/ && sudo ln -s wsl-open xdg-open

Now

sqlite3 :memory: -cmd ".header on" -cmd ".excel" "select 1,2,3"

works via the xdg-open symlink.

Upvotes: 0

jawira
jawira

Reputation: 4618

Try using wslview instead of xdg-open, it works in Windows 10 wsl.

Install with:

sudo apt install wslu

source: https://manpages.ubuntu.com/manpages/impish/man1/wslview.1.html

Upvotes: 1

Oliver Sorg
Oliver Sorg

Reputation: 71

I ran into the same issue with Hashicorp Vault in WSL.

I created a script that basically forwards xdg-open to powershell -c start

Not tested much though.

sudo tee /usr/local/bin/xdg-open <<EOF
#!/bin/sh

powershell.exe -c start "'\$@'"
EOF
sudo chmod +x /usr/local/bin/xdg-open

Cheers Oliver

Upvotes: 6

Related Questions