7

I have created a simple xulrunner app and it works great when invoked from command line.

clain@desktop:~$ xulrunner /home/clain/myapp/application.ini

The problem is that I need to keep the terminal open while the app is running. is there a way I can launch the app with a desktop shortcut / desktop entry?

I have tried to make a desktop entry file like below but when running it I got the error "Invalid desktop entry file: '/home/clain/Desktop/myapp'"

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=MyApp
GenericName=MyApp XulRunner
Exec=xulrunner /home/clain/myapp/application.ini
TryExec=xulrunner /home/clain/myapp/application.ini
Terminal=false
Type=Application
MimeType=text/xml;application/xhtml+xml;application/x-javascript;application/x-php;application/x-java;text/x-javascript;text/html;text/plain;

Name[en_IN]=MyApp
Comment[en_IN]=Standalone MyApp SSB

I am running on Lubuntu 14.04 LTS (Trusty Tahr)

3 Answers3

4

You have a couple of options.

You could either run from the graphical "Run Command" - the equivalent of Windows + R. You can also find this in the start menu on Windows.

On Ubuntu, you use Alt + F2 to open this:

And on lubuntu it is "Menu" -> "Run".

And then run the command

xulrunner /home/clain/myapp/application.ini

graphically, without a terminal being needed.


Your second option is to run in a terminal, but unlink it from the terminal with the & character, like so:

xulrunner /home/clain/myapp/application.ini &

this will start it as a separate process. Here is an example with Gedit:

As you can see, I can run another command without affecting Gedit. It will keep running. If I was to not use the & the terminal would be attached. Closing the terminal gives this message:

And of course if I do close it Gedit will stop. If I use the &, there is no active process so the terminal can just be closed.


Finally, if you do really need a desktop shortcut, you could use this .desktop file.

[Desktop Entry]
  Version=1.0
  Encoding=UTF-8
  Name=MyApp
  Exec=xulrunner /home/tim/xulrunner/application.ini
  Terminal=false
  Type=Application

I've cut out the unnececary parts which, so this may work. Add in the line Icon = /path/to/iconname.svg to give it an icon.

Also note that you can simply put an icon is ~/.icons or /usr/share/icons. Then if your icon name is "MyApp.svg" just use the line Icon = MyApp.

If you still want the "TryExec" line, which isn't needed, A.B.'s answer explains why you do.

Tim
  • 33,500
1

The entry TryExec is wrong and that's the reason for your error message:

Invalid desktop entry file: '/home/clain/Desktop/myapp'

The definition for TryExec is

Path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example).

Use

TryExec=xulrunner

because

xulrunner /home/clain/myapp/application.ini

isn't an executable file. It's an executable with a parameter.

A.B.
  • 92,125
0

you can write a script like this:

#!/bin/bash
xulrunner /home/clain/myapp/application.ini

then save that script some place Im calling "myapp" for example. you can then make myapp executable, by giving the command chmod +x myapp or by right clicking the file, going tot hte permissions tab and checking the make executable box.

You can then make you script a system command, using the ln command you simply put a symbolic link to myapp in somewhere in the PATH. echo $PATH to see what your options are. I'll be using "/usr/local/bin"

then you give a command like this: sudo ln -s /absolute/path/to/myapp /usr/local/bin/myapp

or to make a Desktop Icon:

ln -s /absolute/path/to/myapp /home/user/Desktop/myapp

now your app is usable from the command-line, you can type $myapp, and it will run.

now, you can now create panel, or dock custom launchers, which will not occupy your terminal, even though they will be calling the terminal.

Alternatively,xulrunner /home/clain/myapp/application.ini & isn't bad advice, but if you make a script, and a link, and or custom launchers, you never have to type that stuff again. You can right click the panel, and select "Add To Panel" then select custom application Launcher. Then you can give the command "myapp" or call the script directly.

j0h
  • 15,365