Creating a .desktop file for a new application

178,090

Solution 1

For reference see the Freedesktop Desktop Entry Specification, but this should work:

[Desktop Entry]
Version=1.0
Name=Unipro UGENE
Comment=Unipro UGENE is a cross-platform visual environment for DNA and protein sequence analysis.
Exec=/home/samuel/ugene-1.11.5/ugene -ui
Path=/home/samuel/ugene-1.11.5/
Icon=/usr/share/icons/Humanity/apps/32/access.svg
Terminal=false
Type=Application
Categories=Utility;Development;

Some notes:

Version

  • Should be 1.0, it refers to the .desktop file version, not to the program version.

Name

  • The name that should be displayed on the menu.

Exec

  • The full path to the executable. No need to use '.', it just means the current dir

Path

  • The dir that will be set as current when the entry is run. You usually don't need to set it, but I have added it just in case. It is the same as using 'cd' in your command line

Icon

  • The path to the icon file that will be used for the file, it's likely that the one that you put doesn't exists, I have changed it for a generic one. You should change this to the file that you want the icon to use

Mimetype

  • Specifies the kind of files that this program is able to open. I've left it empty.

StartupWMClass

  • Only needed for some programs, It is usually needed by java programs but only set it if you notice some problems.

To use the desktop file from the Dash you will need to copy it to /usr/share/applications for any user to be able to use it (you will need administrator permissions) or to ~/.local/share/applications (where ~ means your user directory) if you just want it to be available for one user.

Solution 2

Instead of manually adding .desktop files, you can use the little GUI tool alacarte (Main Menu) to do this for you.

Installation:

sudo apt install alacarte

alacarte Screenshot

Share:
178,090

Related videos on Youtube

mariusC
Author by

mariusC

Updated on September 18, 2022

Comments

  • mariusC
    mariusC over 1 year

    I just installed the lastest version of UGENE. I works fine but in order to use it, I have to enter the following in the terminal: cd ugene-1.11.5/ then execute ./ugene -ui to launch UGENE GUI.

    This takes too long. I would like to build a .desktop file for UGENE to be used in Ubuntu 12.04 so that I can simply open it from the unity launcher.

    Not sure if this is helpful but the website says: By default ugene script launches the command-line version of UGENE.

    Here's what I have (not sure if it's right):

    [Desktop Entry]
    Version=1.0
    Name=my Unipro UGENE
    GenericName=Integrated Bioinformatics Suite
    Comment=Unipro UGENE is a cross-platform visual environment for DNA and protein sequence analysis.
    MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
    Exec=/home/samuel/ugene-1.11.5 ./ugene -ui -c %F
    Icon=/usr/share/icons/hicolor/scalable/apps/ugene.svg
    Type=Application
    Terminal=true
    Categories=Utility;Development;
    StartupWMClass=UGENE
    

    I added the launcher named my Unipro UGENE to my unity bar and tried opening it but it doesn't appear. I must be missing something. I don't know what the StartWMCClass field is suppose to be nor do I know whether I entered the correct MimeType.

    • Admin
      Admin about 11 years
      You can omit those. what is Adding Path? it is not required probably.. in exec put home/samuel/ugene-1.11.5/ugene -ui -c %F
    • Admin
      Admin about 11 years
      Terminal=true for CLI version may be needed. At least fales is not correct.
    • Admin
      Admin about 11 years
      thanks for the suggestions. I'll look into this some more later tonight. If I can't figure it out, I guess I'll start a bounty in 11 hours. Hope everyone's done their homework!!
    • Admin
      Admin about 7 years
      As a complement for anyone trying to create .desktop entries, use: desktop-file-install THE_DESKTOP_FILENAME_HERE.desktop Because it will show you any errors it finds on the file, and if everything is all right will copy it to the correct location /usr/share/applications and reload unity.
  • mariusC
    mariusC about 11 years
    excellent, works like a charm. thanks for providing a link to the specs and adding a detailed description on which ones you added. This way I know what to do next time I want to create a .desktop file.
  • Cas
    Cas about 11 years
    Just to note that I have fixed a common mistake in the desktop file; when using multiple values you need to include the trailing semi-colon.
  • Rahal Kanishka
    Rahal Kanishka almost 7 years
    what's this means? #!/usr/bin/env/ xdg-open
  • Javier Rivera
    Javier Rivera almost 7 years
    This is a shebang, en.wikipedia.org/wiki/Shebang_(Unix) , it tells the computer to use xdg-open to open the file when you try to run it as a script.
  • Miracles Happen
    Miracles Happen about 5 years
    Still the best, user-friendly option even in 2019!
  • Jonathan
    Jonathan about 5 years
    I can never remember the name of this program. I wish they called it Launcher Editor or Desktop File Creator because always google before I open it
  • PhoneixS
    PhoneixS over 4 years
    @Jonathan thankfully, you can use alacarte to change its name ;-)
  • user309383
    user309383 about 4 years
    I could never understood as to why this was not part of desktop manager from the beginning - this shall have been a 'create shortcut' function or something like that. On every new installation i spend hours looking what was the name of this utility.
  • SidOfc
    SidOfc almost 4 years
    Thanks, with this I managed to get "Sound" settings to show up in Albert :D (for reference: github.com/albertlauncher/albert/issues/877)
  • Ankit Tale
    Ankit Tale almost 3 years
    Still best option as compare to other.Thanks
  • Admin
    Admin about 2 years
    Thank you for these details. In Cinnamon 5.2.7 one can create a launcher by right-clicking on the desktop. It seems to be built into the desktop application.