安装 google-chrome
sudo dpkg --install google-chrome-stable_current_amd64.deb
每次我运行 chrome 时,它都会要求我将 chrome 设置为默认的网络浏览器。
我尝试修复它Settings
或者即使卸载了 iceweasel,我仍然无法将 chrome 设置为我的默认浏览器。
请帮忙。提前致谢。
编辑:
我尝试了 terdon 先生的建议,但仍然遇到同样的问题。
这是 chrome.desktop
~$ cat /usr/share/applications/chrome.desktop
Name=Google Chrome
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
X-Ayatana-Desktop-Shortcuts=NewWindow;NewIncognito
Exec=/usr/bin/google-chrome %U
这是 mimeapps.list
~$ cat .local/share/applications/mimeapps.list
[Default Applications]
text/html=google-chrome.desktop
x-scheme-handler/http=google-chrome.desktop
x-scheme-handler/https=google-chrome.desktop
x-scheme-handler/about=google-chrome.desktop
x-scheme-handler/unknown=google-chrome.desktop
答案1
默认应用程序在文件中定义~/.local/share/applications/mimeapps.list
。用你喜欢的文本编辑器打开该文件并更改
x-scheme-handler/http=firefox.desktop
x-scheme-handler/https=firefox.desktop
到
x-scheme-handler/http=chrome.desktop
x-scheme-handler/https=chrome.desktop
只要您有,这应该就可以chrome.desktop
工作
/usr/share/applications/
。
更新:
如果您没有chrome.desktop
文件,/usr/share/applications/
请使用以下行创建一个:
Name=Google Chrome
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
X-Ayatana-Desktop-Shortcuts=NewWindow;NewIncognito
Exec=/opt/google/chrome/google-chrome %U
更改/opt/google/chrome/google-chrome
为 返回的任何内容which google-chrome
。
答案2
默认是/usr/share/applications/mimeinfo.cache,他被读入/usr/share/applications/*.desktop
grep -R x-scheme-handler/http /usr/share/applications/*.desktop
/usr/share/applications/chromium.desktop:MimeType=text/html;text/xml;application/xhtml+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https; /usr/share/applications/firefox.desktop:MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x -方案处理程序/https;
我的做法是修改用户的~/.local/share/applications/mimeinfo.cache将x-scheme-handler/http(http协议)、x-scheme-handler/https(https协议)通过chrome.desktop指定打开。
将这些代码保存到 foo ;然后 sh ./foo
#!/bin/bash
cd ~/.local/share/applications/
sed -i '/http=\|https=/d' mimeinfo.cache
cat >>mimeinfo.cache<<EOF
x-scheme-handler/http=chrome.desktop;
x-scheme-handler/https=chrome.desktop;
EOF