I'm creating a webpage right now and am wondering if it is possible to input a command in HTML that will open an installed Ubuntu app like Chromium, or a terminal window, or Nautilus.
Is something like this possible? Thanks!
I'm creating a webpage right now and am wondering if it is possible to input a command in HTML that will open an installed Ubuntu app like Chromium, or a terminal window, or Nautilus.
Is something like this possible? Thanks!
Yes, you can by adding a new protocol handler in your Ubuntu. The following method will show you how to register the process of opening an application as
app://[application_name]
protocol handler in Ubuntu.1. Create application launcher script
In a terminal run:
This command will make a
bin
directory in yourhome
folder if you don't already have it.After run:
This will create the new file
open_app.sh
in gedit.Copy and paste the following script in the new created file:
Save the file and close it.
Go back into terminal and run:
to grant execute access for the script.
2. Create .desktop file for application launcher
Now you must create a .desktop launcher for the above script, and tell Ubuntu to use this launcher as
app://
protocol handler. Create/usr/share/applications/appurl.desktop
file using the following command:and add the following content:
Save the file and close it.
3. Refresh mime types database
In the file above, the line
MimeType=x-scheme-handler/app;
registerapp://
scheme handler, but to make it work we should update mime types database cache by executing command:4. Test from terminal
Now everything should work. To test that it works from terminal, run for example this command:
4. Test from browser using HTML
You can test from browser by using for example the following HTML web page:
The result:
Yes, it is called "Web-based protocol handlers". You need Chrome 13 or Firefox 3.0 or higher. I have seen it used to open LibreOffice.
Both Mozilla and updates.html5rocks have an explanation about how this works. (Open in Chrome/Chromium
chrome://settings/handlers
and it will show a list of current handlers. Firefox will list them inabout:config
.)Parts from the 1st link:
Registering
Setting up a web application as a protocol handler is not a difficult process. Basically, the web application uses registerProtocolHandler() to register itself with the browser as a potential handler for a given protocol. For example:
Where the parameters are:
When a browser executes this code, it should display a prompt to the user, asking permission to allow the web application to register as a handler for the protocol. Firefox displays a prompt in the notification bar area.
Example