作为普通用户收到此错误:
~$ xdg-open http://www.google.com/
xdg-open: no method available for opening 'http://www.google.com/'
~$
~$ xdg-mime query default text/html
~$
代码来自 /usr/bin/xdg-open
# if BROWSER variable is not set, check some well known browsers instead
if [ x"$BROWSER" = x"chromium" ]; then
BROWSER=links2:elinks:links:lynx:w3m
if [ -n "$DISPLAY" ]; then
BROWSER=firefox:mozilla:epiphany:konqueror:chromium:google-chrome:$BROW$
fi
fi
open_envvar "$1"
exit_failure_operation_impossible "no method available for opening '$1'"
}
操作系统:Ubuntu 16.04 Gnu/Linux
答案1
xdg-open 用于 URI 的 MIME 类型是x-scheme-handler/<scheme>
,在您的情况下是x-scheme-handler/http
和x-scheme-handler/https
。您可以为那些使用所需 .desktop 文件的用户添加一个条目
${XDG_CONFIG_HOME:-$HOME/.config}/mimeapps.list
文件。