Distribute your XULRunner app
2 - Linux
2.1 Linux common
- 2.1.1 Generalities
- 2.1.2 Create a launcher
- 2.1.3 Icons for our windows
- 2.1.4 Desktop integration
- 2.1.5 Distribute a tar.gz
We target the platform Linux in this part. And this is the simplest case.
For all distributions that I have take a look at, XULRunner is available from the package manager, and Firefox is based on it. So XULRunner can easily be a dependency of your application.
2.1.2 Create a launcher
It's easy to create a launcher, simply create a shell script named
myapp.sh, into your main application folder
(those which contains
application.ini) with the following
#!/bin/sh CUR_DIR=$(dirname $(readlink -f "$0")) if [ -x /usr/bin/xulrunner ]; then /usr/bin/xulrunner "$CUR_DIR/application.ini" $@ elif [ -x /usr/bin/firefox ]; then /usr/bin/firefox -app "$CUR_DIR/application.ini" $@ else echo "Error: unable to find XULRunner or Firefox!" fi
and make it executable:
chmod +x myapp.sh
The script retrieves in which folder is it from, then launches the
application.ini file via xulrunner if found, firefox with
-app argument otherwise. The script passes eventual
additional arguments too (like
-jsconsole for example).
Later in this howto, when we'll create the deb and rpm packages, we
will add a symbolic link to this file into
Note: the readlink -f argument used in this script is available only in the GNU version, so in all Linux distributions, but not in some other unix like systems, like Mac OSX for example.
2.1.3 Icons for our windows
As is, the app is launched, but the icon displayed in the task
bar is the XULRunner generic one, or the Firefox icon. It's easy
to display our own icon. Simply create a folder named '
inside the main chrome folder of the app, then create inside
another one named '
default'. Copy 3 png files, named
default16.png, default32.png, and default48.png. That's all, now
this is your own icon that's displayed.
|- samples_chapter_2/ |- myapp/ |- chrome |- icons/ |- default/ |- default16.png |- default32.png |- default48.png
2.1.4 Desktop integration
For a complete desktop integration, we now need to create some additional
.desktop file, and some associated icons. This
allows our app to appear in the applications menu of the windows manager.
As example, here's the content of a
[Desktop Entry] Version=1.0 Encoding=UTF-8 Name=MyApp Comment=a Hello World XULRunner app Comment[fr]=un Bonjour Monde pour XULRunner. Exec=/usr/bin/myapp Terminal=false Type=Application Categories=Utility; Icon=myapp
Exec entry is described
in detail here, we use a symbolic link to our launcher, from
/usr/bin/ (the standard for executable on Linux). Its real
location will be in
Icon entry content the name of our
icons that we will create below.
Comment entry is optional, and can be
localized (like some others entries, see the spec), here there's a default
value, and a french (fr) one.
If the app handles some mime types, i.e. can open some type of files,
you must add a line with a
MimeType entry, for example:
This myapp.desktop file is intended to be placed in the final
stage into the
(See http://www.freedesktop.org/wiki/Specifications/menu-spec and http://www.freedesktop.org/wiki/Specifications/basedir-spec for more details)
Now we need some icons. We will use png and svg (xpm is possible too, but seems deprecated, I don't use it). We can have several sizes, personaly I have restricted to 4 png (16x16, 22x22, 32x32, 48x48), as suggested by the Tango Guidelines, plus a 48x48 svg.
These images must be named myapp.png, and myapp.svg .
And they should be finally placed into the following folders:
2.1.5 Distribute a tar.gz
Our application is runnable as is with its launcher, so you can
distribute it as a simple
tar.gz. To create it:
tar -zcvf myapp.tar.gz myapp
A user can download it, unpack it anywhere, and launch it via myapp.sh.
But to be more friendly, a package usuable by the package manager of the distribution, with the complete desktop integration, is preferable. That's what we will see in the next sections.
You can download all the samples of this chapter 2 (Linux) in the samples_chapter_2.tar.gz archive.