diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 75e234e60..2389433e7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,7 @@ Scripting improvements Interactive improvements ------------------------ +- ``help`` and ``fish_config`` no longer open to a "Your file couldn't be accessed" page when fish is running in a Chrome OS Crostini Linux VM and URLs are opened in Chrome running outside the VM. New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/share/functions/help.fish b/share/functions/help.fish index 0fd612d08..71531babb 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -142,12 +142,20 @@ function help --description 'Show help for the fish shell' set fish_help_page "index.html#$fish_help_item" end + # In Crostini Chrome OS Linux, the default browser opens URLs in Chrome running outside the + # linux VM. This browser does not have access to the Linux filesystem. This uses Garcon, see e.g. + # https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/garcon/#opening-urls + # https://source.chromium.org/search?q=garcon-url-handler + string match -q '*garcon-url-handler*' $fish_browser[1] + and set -l chromeos_linux_garcon + set -l page_url - if test -f $__fish_help_dir/index.html + if test -f $__fish_help_dir/index.html; and not set -lq chromeos_linux_garcon # Help is installed, use it set page_url file://$__fish_help_dir/$fish_help_page - # For Windows (Cygwin, msys2 and WSL), we need to convert the base help dir to a Windows path before converting it to a file URL + # For Windows (Cygwin, msys2 and WSL), we need to convert the base + # help dir to a Windows path before converting it to a file URL # but only if a Windows browser is being used if type -q cygpath and string match -qr '(cygstart|\.exe)(\s+|$)' $fish_browser[1] diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index bfe33d1b9..cfddf73f4 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -71,6 +71,16 @@ def is_termux(): return "com.termux" in os.environ["PATH"] and find_executable("termux-open-url") +def is_chromeos_garcon(): + """ Return whether we are running in Chrome OS and the browser can't see local files """ + # In Crostini Chrome OS Linux, the default browser opens URLs in Chrome + # running outside the linux VM. This browser does not have access to the + # Linux filesystem. This uses Garcon, see for example + # https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/garcon/#opening-urls + # https://source.chromium.org/search?q=garcon-url-handler + return "garcon-url-handler" in webbrowser.get().name + + # Disable CLI web browsers term = os.environ.pop("TERM", None) # This import must be done with an empty $TERM, otherwise a command-line browser may be started @@ -1549,6 +1559,8 @@ def runThing(): sys.exit(-1) elif is_termux(): subprocess.call(["termux-open-url", url]) + elif is_chromeos_garcon(): + webbrowser.open(url) else: webbrowser.open(fileurl)