LV
Back to writing

// Linux · Linux Mint Debian Edition

Desktop Files: Adding Your Application to the GNOME Menus

Linux Mint Debian Edition comes by default with two graphical interfaces: Mate, which is a fork of Gnome 2, and Cinnamon, which is a fork of Gnome 3 that modifies it to look more like Gnome version 2. So, whether you use Mate or Cinnamon, you're using Gnome.

If you install a program and it doesn't show up in the Gnome menus, you can create a .desktop file so the system recognizes it automatically.

The simplest way to create a desktop file is to copy it from another file and change what matters, but if you want to learn more about the file and its possible parameters, I recommend these links:

http://developer.gnome.org/integration-guide/stable/desktop-files.html.pt_BR

http://standards.freedesktop.org/menu-spec/latest/apa.html

http://www.nautilus-actions.org/?q=node/377

For this demonstration I'll create a .desktop file for Google Chrome. I want Chrome to go into the Internet menu just like Firefox, so I'll use it as a base.

$ sudo cp /usr/share/applications/firefox.desktop /usr/share/applications/google-chrome.desktop
$ sudo pluma /usr/share/applications/google-chrome.desktop

The original file looked like this:

[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Name[ar]=متصفح الوِب فَيَرفُكْس
Name[ca]=Navegador web Firefox
Name[cs]=Firefox Webový prohlížeč
Name[es]=Navegador web Firefox
Name[et]=Firefoxi veebibrauser
Name[fa]=مرورگر اینترنتی Firefox
Name[fi]=Firefox-selain
Name[fr]=Navigateur Web Firefox
Name[hu]=Firefox webböngésző
Name[it]=Firefox Browser Web
Name[ja]=Firefox ウェブ・ブラウザ
Name[ko]=Firefox 브라우저
Name[nb]=Firefox Nettleser
Name[nl]=Firefox webbrowser
Name[nn]=Firefox Nettlesar
Name[no]=Firefox Nettleser
Name=Przeglądarka WWW Firefox
Name[pt]=Firefox Navegador Web
Name[pt_BR]=Navegador Web Firefox
Name[sk]=Firefox - internetový prehliadač
Name[sv]=Webbläsaren Firefox
Comment=Browse the World Wide Web
Comment[ar]=تصفح الشبكة العنكبوتية العالمية
Comment[ca]=Navegueu per el web
Comment[cs]=Prohlížení stránek World Wide Webu
Comment[de]=Im Internet surfen
Comment[es]=Navegue por la web
Comment[et]=Lehitse veebi
Comment[fa]=صفحات شبکه جهانی اینترنت را مرور نمایید
Comment[fi]=Selaa Internetin WWW-sivuja
Comment[fr]=Navigue sur Internet
Comment[hu]=A világháló böngészése
Comment[it]=Esplora il web
Comment[ja]=ウェブを閲覧します
Comment[ko]=웹을 돌아 다닙니다
Comment[nb]=Surf nettet
Comment[nl]=Verken het internet
Comment[nn]=Surf nettet
Comment[no]=Surf nettet
Comment=Przeglądanie stron WWW 
Comment[pt]=Navegue na Internet
Comment[pt_BR]=Navegue na Internet
Comment[sk]=Prehliadanie internetu
Comment[sv]=Surfa webben
GenericName=Web Browser
GenericName[ar]=متصفح وب
GenericName[ca]=Navegador web
GenericName[cs]=Webový prohlížeč
GenericName[es]=Navegador web
GenericName[et]=Veebibrauser
GenericName[fa]=مرورگر اینترنتی
GenericName[fi]=WWW-selain
GenericName[fr]=Navigateur Web
GenericName[hu]=Webböngésző
GenericName[it]=Browser Web
GenericName[ja]=ウェブ・ブラウザ
GenericName[ko]= 브라우저
GenericName[nb]=Nettleser
GenericName[nl]=Webbrowser
GenericName[nn]=Nettlesar
GenericName[no]=Nettleser
GenericName=Przeglądarka WWW
GenericName[pt]=Navegador Web
GenericName[pt_BR]=Navegador Web
GenericName[sk]=Internetový prehliadač
GenericName[sv]=Webbläsare
Exec=/opt/firefox/firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/icons/mozicon128.png
Categories=Application;Internet;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;
StartupWMClass=Firefox
StartupNotify=true

After editing, it looked like this:

[Desktop Entry]
Version=1.0
Name=Google Chrome
Name[pt_BR]=Navegador Web Google Chrome
Comment=Browse the World Wide Web
Comment[pt_BR]=Navegue na Internet
GenericName=Web Browser
GenericName[pt_BR]=Navegador Web
Exec=/opt/google/chrome %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/google/chrome/product_logo_256.png
Categories=Application;Internet;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;
StartupWMClass=Chrome
StartupNotify=true

The most important changes are:

Name => Application name
Exec => Path to the executable (the %u is specific to the browser opening a URL passed as a parameter).
Icon => Path to the icon (it can be jpg, png, svg or even the program's own executable).
Categories => Menu where the shortcut to the program will appear.

You can always use other .desktop files as a base for creating yours.

See also how to add your program to the path in this article.

I hope this helped!

Comments 0

No comments yet.