为什么xdg-open使用wslview?

为什么xdg-open使用wslview?

使用 Ubuntu 22.04 LTS、KDE ​​Plasma 5,安装了 wine 7.8。

当我尝试使用该命令时,xdg-open .预期的 mime 类型(对于 inode/directory 是 Dolphin)没有被调用。相反,wslview被调用了。此外,我在尝试打开 Windows 注册表控制台工具时收到错误,但找不到文件:

原始错误:

barry@barry-laptop:~$ xdg-open .
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
WSL Interopability is disabled. Please enable it before using WSL.
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
[error] WSL Interoperability is disabled. Please enable it before using WSL.
/usr/bin/wslview: line 216: /mnt/c/Windows/System32/reg.exe: No such file or directory
/usr/bin/wslview: line 308: [: -ge: unary operator expected
[error] This protocol is not supported before version 1903.

我想xdg-open使用 mime 类型来控制,而不是 wslview。

inode/目录的 Mime 类型:

barry@barry-laptop:~$ xdg-mime query filetype .
inode/directory
barry@barry-laptop:~$ xdg-mime query default inode/directory
org.kde.dolphin.desktop

为什么它使用 wslview 而不是注册的 mime 类型?

研究:

sh -x /usr/bin/xdg-open .通过发出我看到的命令xdg-open .被翻译成kde-open5 .

barry@barry-laptop:~$ sh -x /usr/bin/xdg-open .
+ check_common_commands .
+ [ 1 -gt 0 ]
+ parm=.
+ shift
+ [ 0 -gt 0 ]
+ [ -z  ]
+ unset XDG_UTILS_DEBUG_LEVEL
+ [ 0 -lt 1 ]
+ xdg_redirect_output= > /dev/null 2> /dev/null
+ [ x. != x ]
+ url=
+ [ 1 -gt 0 ]
+ parm=.
+ shift
+ [ -n  ]
+ url=.
+ [ 0 -gt 0 ]
+ [ -z . ]
+ detectDE
+ unset GREP_OPTIONS
+ [ -n KDE ]
+ DE=kde
+ [ xkde = x ]
+ [ xkde = x ]
+ [ xkde = x ]
+ [ xkde = xgnome ]
+ [ -f /run/user/1000/flatpak-info ]
+ [ xkde = x ]
+ DEBUG 2 Selected DE kde
+ [ -z  ]
+ return 0
+ open_kde .
+ [ -n 5 ]
+ kde-open5 .
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
WSL Interopability is disabled. Please enable it before using WSL.
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
[error] WSL Interoperability is disabled. Please enable it before using WSL.
+ [ 0 -eq 0 ]
+ exit_success
+ [ 0 -gt 0 ]
+ exit 0

kde-open5是指向kde-open

barry@barry-laptop:~$ which kde-open5
/usr/bin/kde-open5
barry@barry-laptop:~$ ls -alh /usr/bin/kde-open5
lrwxrwxrwx 1 root root 8 May  5 12:56 /usr/bin/kde-open5 -> kde-open
barry@barry-laptop:~$ which kde-open
/usr/bin/kde-open
barry@barry-laptop:~$ ls -alh /usr/bin/kde-open
-rwxr-xr-x 1 root root 39K Mar 30 02:19 /usr/bin/kde-open

kde-open是二进制文件,无法通过 VIM 查看。不清楚如何配置文件类型和应用程序之间的关系,因为它不支持 MIME 类型。

答案1

我遇到了同样的问题,所以我调查了一下。我发现wslview声明它x-scheme-handler/file在位于以下位置的桌面条目中处理 mimetype /usr/share/wslu/wslview.desktop

[Desktop Entry]
Name=WSLView
Comment=Open files and addresses in Windows
Icon=windows
Exec=/usr/bin/wslview %U
Terminal=false
Type=Application
Categories=Utility;
MimeType=x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/file
X-Desktop-File-Install-Version=0.26

我猜想在决定如何打开文件时,方案处理程序file://优先于文件的 mimetype ;因此每个文件都使用 打开。卸载它解决了我的问题。xdg-openwslview

相关内容