系统相关
首页 > 系统相关> > linux-Ubuntu自定义URL协议处理程序

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

作者:互联网

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

<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’或其他内容?

谢谢,阿马努什

解决方法:

Exec在桌面文件中可以使用following parameters

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的第一部分.

标签:ubuntu,url,protocols,handler,linux
来源: https://codeday.me/bug/20191123/2066874.html