Skip to content

Commit f082f2e

Browse files
committed
wsl: use wslview to launch browser in Windows from WSL
When installed inside of a Linux environment we typically look for a set of utilities to open the user's preferred browser (xdg-open, gnome-open, kfmclient). However, if we are actually in a WSL (Windows Subsystem for Linux) distribution, these utilties may not be/are not present. Instead we can try and use the `wslview` utility that will launch the user's browser on the _Windows host_. Appending `wslview` to the list of utilities to open the browser means no behaviour change for existing Linux users, but for WSL distros we now have a chance to still open the browser.
1 parent 1d668b1 commit f082f2e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/shared/Core/BrowserUtils.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ public static void OpenDefaultBrowser(IEnvironment environment, Uri uri)
3939
//
4040
// We try and use the same 'shell execute' utilities as the Framework does,
4141
// searching for them in the same order until we find one.
42-
foreach (string shellExec in new[] {"xdg-open", "gnome-open", "kfmclient"})
42+
//
43+
// One additional 'shell execute' utility we also attempt to use is `wslview`
44+
// that is commonly found on WSL (Windows Subsystem for Linux) distributions that
45+
// opens the browser on the Windows host.
46+
foreach (string shellExec in new[] {"xdg-open", "gnome-open", "kfmclient", "wslview"})
4347
{
4448
if (environment.TryLocateExecutable(shellExec, out string shellExecPath))
4549
{

0 commit comments

Comments
 (0)