首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么xdg使用wslview?

为什么xdg使用wslview?
EN

Ask Ubuntu用户
提问于 2022-05-19 17:07:53
回答 1查看 1.4K关注 0票数 2

使用Ubuntu22.04LTS,KDE等离子5,安装葡萄酒7.8。

当我尝试使用命令xdg-open .时,不会调用预期的mime类型(对于inode/目录是Dolphin)。相反,调用wslview。此外,我还收到一个试图打开windows注册表控制台工具的错误,但未能找到该文件:

原始错误:

代码语言:javascript
复制
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.

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

inode/目录的

Mime类型:

代码语言:javascript
复制
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 .

代码语言:javascript
复制
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的符号链接。

代码语言:javascript
复制
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类型。

EN

回答 1

Ask Ubuntu用户

发布于 2023-05-26 20:22:20

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

代码语言:javascript
复制
[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://的方案处理程序在xdg-open决定如何打开文件时优先于文件的mimetype;所以每个文件都使用wslview打开。卸载它解决了我的问题。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1409481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档