Question

I want to add a menu item of my application to the GNOME menu. I had created a desktop file for it and placed it in /usr/share/applications, but the menu item is not appearing in the GNOME menu. Below is my desktop file which I created in the name of Aces.desktop...

[Desktop Entry]
Encoding=UTF-8
Version 1.0
Name=Aces
Comment=Compile and Execute C programs
Categories=GNOME;Application;Development;
Exec=/usr/share/Aces/Aces
Icon=/usr/share/Aces/icon.png
Terminal=false
Type=Application
StartupNotify=true

After placing it in /usr/share/applications, I tried restarting the PC and still it did not work.

Any kind of help is appreciatable... :)

Was it helpful?

Solution

I've found my silly mistake :) I forgot to give executable privileges to the desktop file. So after you give executable privileges to the desktop file by the command

chmod +x <desktop file path>

place it in

/usr/share/applications  /* So the menu option is available to all the user */

or

~/.local/share/applications  /* In this case the menu option is available only to that particular user*/

after you apply the executable permission, the desktop file will take the name and icon specified by you, in the .desktop file.

OTHER TIPS

Well I just managed to add my program to Debian 9 / Ubuntu latest Unity interface on three steps.

0.- In you application folder locate or create a squared 72x72 or 96x96 or 128x128 or so on icon with .xpm or .png extension.

1.- In you application folder copy from /usr/share/applications/{example}.desktop, rename it to {myapp}.desktop and craft it to meet your application requirements

2.- run this then edit back {myapp}.desktop in case of problems

$ desktop-file-validate {myapp}.desktop

3.-run this to install your launcher into the appropiate directory and bring it lo live

in case of 'just for current user' do: 
$ desktop-file-install --dir=/home/{user}/.local/share/applications/ {myapp}.desktop

'for all users' (/usr/share/applications/) do as root:
# desktop-file-install {myapp}.desktop

The term "Gnome Menu" can be a bit ambiguous, but I use MATE-Desktop (the Gnome 2 clone), and the easiest way I've found to add an item to the Applications menu (for example) is to right click on "Applications" and click on "Edit Menu". You can get edit the menus, show or hide various sections, and add a new item with the command, description, icon, etc. Note that right-clicking on any sub-menu (like 'Programming') doesn't work -- it has to be the main 'Applications' menu on your gnome panel.

You can use Arronax, if you want to do this quickly.

This answer uses Firefox and CentOS as an example, but these steps should work for any application. The example assumes that you already have GVim installed.

If you don't, simply pick any other menu item that doesn't use hyphens in its title. For example, using chromium-browser.desktop would be bad, while using caja.desktop would be goodness.

1 DOWNLOAD, INSTALL AND TEST FIREFOX FROM MOZILLA SITE

cd /usr/local
sudo wget http://ftp.mozilla.org/pub/firefox/releases/81.0/linux-x86_64/en-US/firefox-81.0.tar.bz2
sudo tar xvjf firefox-81.0.tar.bz2 
sudo rm -fr firefox-81.0.tar.bz2 
sudo ln -s /usr/local/firefox/firefox /usr/bin/firefox
firefox &

2 FIND AND ‘INSTALL’ FIREFOX ICONS

find /usr/local/firefox -name \*.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default16.png /usr/share/icons/hicolor/16x16/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default32.png /usr/share/icons/hicolor/32x32/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default48.png /usr/share/icons/hicolor/48x48/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default64.png /usr/share/icons/hicolor/64x64/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default128.png /usr/share/icons/hicolor/128x128/apps/firefox.png

3 ‘CREATE’ A FIREFOX DESKTOP FILE

cd /usr/share/applications
sudo cp -p gvim.desktop firefox.desktop
sudo sed -i "s/Gvim/Firefox/g" firefox.desktop 
sudo sed -i "s/GVim/Firefox/g" firefox.desktop
sudo sed -i "s/gvim/firefox/g" firefox.desktop 
sudo sed -i "s/Categories=Utility;TextEditor;/Categories=Network;WebBrowser;/g" firefox.desktop 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top