4

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... :)

Greenonline
  • 1,330
  • 8
  • 23
  • 31
Ashwin Surana
  • 826
  • 3
  • 10
  • 33

5 Answers5

8

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
vlc33
  • 91
  • 1
  • 2
5

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.

Greenonline
  • 1,330
  • 8
  • 23
  • 31
Ashwin Surana
  • 826
  • 3
  • 10
  • 33
  • 3
    It's good you got your problem resolved but this solution is unlikely to be correct. Desktop files are not executed so should not require to be marked executable. Take a look in /usr/share/applications: none of the desktop files are marked executable. – Jussi Kukkonen Aug 25 '13 at 09:09
  • Hmm, actually now I remember Some OSes (Ubuntu?) have added this executable limitation for files outside the standard XDG desktop file locations... If they've extended that policy, then I guess you may be right after all. It's still not a universal solution, but I'll remove my down-vote in any case. – Jussi Kukkonen Aug 25 '13 at 09:32
  • 1
    At least on Arch Linux's version of Gnome, the `.desktop` files in `/usr/share/applications/` are not executable and work as expected. However, if e.g. the file's `Exec=` entry has incorrect syntax, the application would not show up in Activities and `gtk-launch` would report a misleading error message "no such application". Once the file's content is fixed, Gnome would automatically recognize it, though it would only appear in the Activities menu on the second search attempt. There is no need to perform any manual "refresh" action like running a special command, log out or restart. – Peter Bašista Sep 19 '20 at 21:02
1

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.

Tim S.
  • 2,187
  • 1
  • 25
  • 40
0

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

masm
  • 77
  • 9
  • I went through the requirements of Arronax. It says it requires Gnome 3.4 but I'm using Ubuntu 11.04 with Gnome version 2.32. – Ashwin Surana Nov 29 '12 at 18:49
0

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 
A. Rick
  • 649
  • 5
  • 11