# Launch an application on desktop

**URL:** <https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137>\
**Category:** Development\
**Created:** [July 17, 2017, 12:49pm UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137 "2017-07-17T12:49:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![oyenamit](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@oyenamit](https://discourse.mozilla.org/u/oyenamit)\
**Post date:** [July 17, 2017, 12:49pm UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/1 "2017-07-17T12:49:43Z")

</div>

Hi,  
I am the author of [MacDict](https://addons.mozilla.org/en-us/firefox/addon/macdict/) extension.  
The extension launches the Dictionary application to lookup the selected word on Mac desktop.

I believe that there is no equivalent way to achieve the same behavior in WebExtensions API.  
I understand that this will compromise the security that WebExtensions aim to provide.  
Could someone please confirm that such an API is indeed not available in WebExtensions.

Thanks.

---

<div class="post-metadata">

**Author:** ![andreip](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/andreip/32/24181_2.png) [@andreip](https://discourse.mozilla.org/u/andreip)\
**Post date:** [July 17, 2017, 2:33pm UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/2 "2017-07-17T14:33:59Z")

</div>

You can have a standalone app that your Firefox WebExtension talks to. Look into [Native messaging](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging) and at the [native-messaging](https://github.com/mdn/webextensions-examples/tree/master/native-messaging) example WebExtension.

There is [a list of sample web extensions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples) and the APIs used. The [Browser Support](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs) table is also very useful.

---

<div class="post-metadata">

**Author:** ![oyenamit](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@oyenamit](https://discourse.mozilla.org/u/oyenamit)\
**Post date:** [July 18, 2017, 10:34am UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/3 "2017-07-18T10:34:47Z")

</div>

I missed mentioning that the application that I want to launch (Dictionary) is not developed by me.  
It is developed by Apple and is a built-in app in Mac OS X.  
So, I cannot communicate with it via Native messaging APIs.

---

<div class="post-metadata">

**Author:** ![andreip](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/andreip/32/24181_2.png) [@andreip](https://discourse.mozilla.org/u/andreip)\
**Post date:** [July 18, 2017, 11:05am UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/4 "2017-07-18T11:05:17Z")

</div>

Does it accept command line parameters? Does it talk to the outside world in any way? Make a standalone app that converts the native messanging API into the command line or whatever the Apple app knows.

---

<div class="post-metadata">

**Author:** ![oyenamit](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@oyenamit](https://discourse.mozilla.org/u/oyenamit)\
**Post date:** [July 19, 2017, 11:26am UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/5 "2017-07-19T11:26:52Z")

</div>

From the documentation of Native messaging, I understand that the manifest file of native app needs to be copied to a specified path. For example “~/Library/Application Support/Mozilla/NativeMessagingHost/”.

Also, as per the documentation, “The native application is not installed or managed by the browser: it’s installed using the underlying operating system’s installation machinery.”

So, how is the manifest file of native app supposed to be copied to the right place? I don’t think it can be done during installation of the extension (although I might be wrong here).

---

<div class="post-metadata">

**Author:** ![McEric](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@McEric](https://discourse.mozilla.org/u/McEric)\
**Post date:** [July 19, 2017, 5:33pm UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/6 "2017-07-19T17:33:31Z")

</div>

The application manifest would have to be distributed and installed the same way as your native application. You can’t get around providing some sort of installer for your custom native application. People would have to download the installer from somewhere else than [addons.mozilla.org](http://addons.mozilla.org).

I’m in the process of doing something similar and I’m really not looking forward to telling the users to download some shady installer to get the extension working, but there isn’t any other way right now.

---

<div class="post-metadata">

**Author:** ![oyenamit](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@oyenamit](https://discourse.mozilla.org/u/oyenamit)\
**Post date:** [July 21, 2017, 12:49pm UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/7 "2017-07-21T12:49:30Z")

</div>

Exactly! Telling users to install an application because Mozilla decided to make their add-ons more secure is just not going to work.

---

<div class="post-metadata">

**Author:** ![ericjung1](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/ericjung1/32/15471_2.png) [@ericjung1](https://discourse.mozilla.org/u/ericjung1)\
**Post date:** [July 22, 2017, 9:42pm UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/8 "2017-07-22T21:42:56Z")

</div>

> So, how is the manifest file of native app supposed to be copied to the right place?

You need to choose an installation location for your native app (in this case, a wrapper around dictionary) and use that location in your extension’s manifest.

> Telling users to install an application because Mozilla decided to make their add-ons more secure is just not going to work.

There is no other choice. The issue is that Mozilla does not want the responsibility for binaries in an addon. Binaries can easily by p0wn a device. By getting the addon author to coax the user into installing components which have nothing to do with Firefox, and by the user doing this installation of his own accord, the user now takes responsibility upon himself for any potentially installed binary malware.

---

<div class="post-metadata">

**Author:** ![McEric](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@McEric](https://discourse.mozilla.org/u/McEric)\
**Post date:** [July 23, 2017, 4:20am UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/9 "2017-07-23T04:20:19Z")

</div>

I think the point is that we didn’t have to deploy any binary components before to be able to talk to third-party applications already present on the user’s system (or at least launch them).

Due to the security restrictions in WebExtensions, we are not only forced to provide a custom binary for the same use case, but also talk the users into installing an installer from a source they don’t really know. Seems like a bad trade-off in terms of the user’s security.

So, the perfect thing for this use case would be not having to write and deploy any binary components at all and to be able to talk to normal third-party applications directly. I understand that this would put some responsibility back in Mozilla’s hands, but I think it would be a good thing for the user (and the extension developer). The user would still take most responsibility by accepting the “nativeMessaging” permission.

---

<div class="post-metadata">

**Author:** ![andreip](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/andreip/32/24181_2.png) [@andreip](https://discourse.mozilla.org/u/andreip)\
**Post date:** [July 26, 2017, 4:40pm UTC](https://discourse.mozilla.org/t/launch-an-application-on-desktop/17137/10 "2017-07-26T16:40:39Z")

</div>

Maybe you can somehow [reuse this native client](https://add0n.com/open-in.html), it’s also on [GitHub](https://github.com/andy-portmen/native-client/).
