Adding menu items to GNOME menu or Unity

18,629

Solution 1

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.

Solution 2

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

Solution 3

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.

Share:
18,629
Ashwin Surana
Author by

Ashwin Surana

Working in the Finance Engineering division of Goldman Sachs.

Updated on June 27, 2022

Comments

  • Ashwin Surana
    Ashwin Surana almost 2 years

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

  • Ashwin Surana
    Ashwin Surana over 11 years
    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.
  • Jussi Kukkonen
    Jussi Kukkonen over 10 years
    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
    Jussi Kukkonen over 10 years
    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.
  • Ashwin Surana
    Ashwin Surana over 9 years
    There was a reason why i needed it to be written as a desktop file rather than following the manual procedure.
  • Peter Bašista
    Peter Bašista over 3 years
    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.
  • raddevus
    raddevus about 2 years
    Fantastic!! Couldn't find out how to do this anywhere else. Exact steps I needed. 👍🏽