8

I want to ask a question, but I will first show my files

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

My .desktop file:

[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

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

Ok, this is cool. The .desktop file will be placed in /usr/share/applications. If you execute the command 'xdg-open cloudje:firefox' or something like 'xdg-open cloudje:example', it will always execute gedit using a Python script named 'cloudjerun'. How can I execute firefox using the command 'xdg-open cloudje:firefox'?

Do I need to replace 'Exec=/usr/bin/cloudjerun -c gedit' to 'Exec=/usr/bin/cloudjerun -c %U' or 'Exec=/usr/bin/cloudjerun -c %s' or something?

1
  • 2
    The Tutorial link is no more working. Commented Oct 20, 2014 at 10:37

2 Answers 2

7

In a desktop file following parameters are possible for 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.

So in your case you can adjust your Exec entry as you described to the following:

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

Note though that %u is the complete uri so e.g. when you run xdg-open cloudje:firefox %u will be cloudje:firefox. Easiest I assume is to adjust the cloudjerun python script removing the first part of the uri before running it.

Sign up to request clarification or add additional context in comments.

1 Comment

If I was still working at the company I made this for, you would be helping me a lot! WebSockets were my solution!
-1

This might help
(its a program for creating custom protocol handlers easily)
(you will need to install kde-apps or kde-full and then run this, you will also need to run this in a Terminal.
Also you MUST run it as root(sudo ~/Downloads/ProtocolCreator.sh))
it will create a folder with the protocol handler name(like the https in https:) in your home directory. use $1 for getting the full url. there is no easy way to make it just be the part after [something]: ...
modify the file inside that folder to make it contain all you need
now with that said if you want to open firefox, use <a href="blablabla:firefox">Open Firefox</a> while the file in the folder has the content:
#!/bin/bash
firefox
now when the link is clicked, Firefox should open!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.