gpt4 book ai didi

linux - Ubuntu 自定义 URL 协议(protocol)处理程序

转载 作者:太空狗 更新时间:2023-10-29 11:09:45 30 4
gpt4 key购买 nike

我想问一个问题,但我会先展示我的文件

<html>
<body>
<a href="cloudje:firefox">Open firefox</a>
</body>
</html>

我的 .desktop 文件:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=/usr/bin/cloudjerun -c gedit
Name[en_US]=Gedit
Comment[en_US]=Small, easy-to-use program to access iTunesU media
Name=TunesViewer
Comment=Small, easy-to-use program to access iTunesU media
Icon=/usr/share/icons/hicolor/scalable/apps/tunesview.svg
Categories=Application;Network;
MimeType=x-scheme-handler/cloudje;
Comment[en_US.utf8]=Small, easy-to-use program to access iTunesU media

教程:http://jarrpa.net/2011/10/28/creating-custom-url-handlers-in-ubuntu-11-04-11-10-gnome-3-0/

好的,这很酷。 .desktop 文件将放在/usr/share/applications 中。如果您执行命令“xdg-open cloudje:firefox”或类似“xdg-open cloudje:example”的命令,它将始终使用名为“cloudjerun”的 Python 脚本执行 gedit。如何使用命令“xdg-open cloudje:firefox”执行 firefox?

我是否需要将“Exec=/usr/bin/cloudjerun -c gedit”替换为“Exec=/usr/bin/cloudjerun -c %U”或“Exec=/usr/bin/cloudjerun -c %s” ' 还是什么?

最佳答案

在桌面文件中 following parameters Exec 是可能的

Add...  Accepts...
%f a single filename.
%F multiple filenames.
%u a single URL.
%U multiple URLs.
%d a single directory. Used in conjunction with %f to locate a file.
%D multiple directories. Used in conjunction with %F to locate files.
%n a single filename without a path.
%N multiple filenames without paths.
%k a URI or local filename of the location of the desktop file.
%v the name of the Device entry.

因此,在您的情况下,您可以按照以下描述调整您的 Exec 条目:

Exec=/usr/bin/cloudjerun -c %u

请注意,虽然 %u 是完整的 uri,例如当您运行 xdg-open cloudje:firefox 时,%u 将是 cloudje:firefox。我认为最简单的方法是调整 cloudjerun python 脚本,在运行它之前删除 uri 的第一部分。

关于linux - Ubuntu 自定义 URL 协议(protocol)处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16376429/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com