无法将 Google Chrome 设置为默认浏览器

Dav*_*cum 5 browser google-chrome default-browser

几个月前,我在笔记本电脑上全新安装了 Ubuntu 15.10。我已经备份了我以前的主文件夹并在安装的基础上恢复了它。我安装了 Google Chrome 并将其设置为我的默认浏览器,但链接总是会打开一个新的空白 Chrome 窗口,因此我将 Firefox 设置为我的默认浏览器。昨天我打算尝试将 Chrome 设置为默认设置,但该选项没有显示。

![详细设置画面。]

Chrome 的设置表明它已经是默认浏览器。

我已经尝试了在 Internet 的 Sun 下将 Google Chrome 设置为我的默认浏览器的所有方法都没有成功,首先是通过 apt 卸载清除 google-chrome-stable,然后从最新的 deb 重新安装。

设置 BROWSER 环境变量。

$ tail ~/.bashrc
export PATH=$PATH:/home/david/Android/Sdk/tools
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=~/virtualenvs
export ANDROID_HOME=/home/david/Android/Sdk

export BROWSER=`which google-chrome`
Run Code Online (Sandbox Code Playgroud)

设置 x-www-browser。

$ sudo update-alternatives --config x-www-browser
There are 3 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser).

  Selection    Path                           Priority   Status
------------------------------------------------------------
  0            /usr/bin/google-chrome-stable   200       auto mode
  1            /usr/bin/firefox                40        manual mode
* 2            /usr/bin/google-chrome-stable   200       manual mode
  3            /usr/bin/xlinks2                69        manual mode

Press <enter> to keep the current choice[*], or type selection number: 
Run Code Online (Sandbox Code Playgroud)

设置 gnome-www-browser。

$ sudo update-alternatives --config gnome-www-browser 
There are 2 choices for the alternative gnome-www-browser (providing /usr/bin/gnome-www-browser).

  Selection    Path                           Priority   Status
------------------------------------------------------------
  0            /usr/bin/google-chrome-stable   200       auto mode
  1            /usr/bin/firefox                40        manual mode
* 2            /usr/bin/google-chrome-stable   200       manual mode

Press <enter> to keep the current choice[*], or type selection number: 
Run Code Online (Sandbox Code Playgroud)

更新 xdg-settings

$ xdg-settings set default-web-browser google-chrome.desktop
Run Code Online (Sandbox Code Playgroud)

但是,详细信息设置窗口仍会显示 Firefox,并且来自 GUI 应用程序的所有链接都在 Firefox 中打开。

编辑:我注意到在 GTK 应用程序选择器中,例如当您右键单击一个文件并选择“打开方式 -> 其他应用程序...”时,Chrome 没有显示在列表中。.desktop 文件在 /usr/share/applications 中,我尝试执行sudo update-desktop-database,但它仍然没有显示。它确实出现在 Unity dash 中。

如果我查看 /usr/share/applications/mimeinfo.cache 然后我看到它已注册为 text/html、x-scheme-handler/http、x-scheme-hanlder/https 以及其他。

Dav*_*cum 4

我发现了问题的根源。.desktop 文件的全局位置是 /usr/share/applications/ 用户特定位置是 ~/.local/share/applications。无论出于何种原因,该目录中有一个 google-chrome.desktop 文件没有正确设置 MIME 元数据。由于本地文件会覆盖全局文件,因此 Google Chrome 不会被识别为网络浏览器。删除该文件后,我可以将 Google Chrome 设置为我的默认网络浏览器,现在链接可以在其中正确打开。