[SOLVED] - Create and place icon in Gnome Applications menu

Issues related to applications and software problems
User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

[SOLVED] - Create and place icon in Gnome Applications menu

Post by warron.french » 2019/05/10 20:36:14

I would like to create a .desktop file for a custom application, and I have figured out how to do that.

The way I did it was duplicate the icon for firewall-config.desktop; rename it, tweak the syntax internally and etcetera.

Once I have completed that process my icons are dropped into Applications > Other menu. I would like to control the placement of the icon.

How do I create another menu folder, and then place my custom icon in it?

I don't know what to google search, and I am not sure I am using the proper terms on this forum for that matter.
Last edited by warron.french on 2019/05/15 23:56:40, edited 3 times in total.
Thanks,
War

Mikhail29
Posts: 12
Joined: 2019/03/23 11:43:32

Re: Create and place icon in Gnome Applications menu

Post by Mikhail29 » 2019/05/10 22:18:36

If I understand you correctly...
jamalm wrote:There are 3 locations you should be concerned with:

/usr/share/desktop-directories
/etc/xdg/menus/applications-merged
/usr/share/applications
Bear in mind the last location is system-wide specific, if you want it just for your user, use: ~/.local/share/applications

Firstly we:

Create a file called APPNAME.menu (substitute APPNAME for whatever you want to call it) in the folder location /etc/xdg/menus/applications-merged
Input these contents:

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
"http://www.freedesktop.org/standards/me ... nu-1.0.dtd">
<Menu>
<Name>Applications</Name> <!-- This is necessary for your directory to appear in the applications drop down -->
<Menu> <!--app -->
<Name>app</Name>
<Directory>APPNAME.directory</Directory>
<Include>
<Category>APPNAME</Category>
</Include>
</Menu> <!-- End app -->
</Menu> <!-- End Applications -->

Save the file and create another file called APPNAME.directory in the folder location ( it should be the same name specified in the .menu file) /usr/share/desktop-directories with these contents:

[Desktop Entry]
Type=Directory
Name=AppName
Icon=/path/to/icon

Note the .directory filename should be exactly the same as the .directory name you entered in the .menu file above.

Create a standard .desktop file in ~/.local/share/applications or /usr/share/applications with these contents (substituting for your own program of course and the Categories=line MUST BE the same as the name you gave the .directory file eariler)

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/path/to/executable.sh
Name=ApplicationToRun
Icon=/path/to/icon
Categories=APPNAME
Comment=Comment for users

User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

Re: Create and place icon in Gnome Applications menu

Post by warron.french » 2019/05/13 00:56:58

Jamalm, thanks for the info.

Can you please explain why this is three parts?
I can see why it would be two parts (icon, and where to place it), but I am confused on why the .desktop, .directory and .menu parts... even with this link - https://access.redhat.com/documentation ... plications

Your instructions made the process easier to understand.
Thank you,
Thanks,
War

User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

Re: Create and place icon in Gnome Applications menu

Post by warron.french » 2019/05/13 01:20:43

This worked for me:

/etc/xdg/menus/applications-merged/warron.menu

Code: Select all

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
"http://www.freedesktop.org/standards/me ... nu-1.0.dtd">
<Menu>
<Name>Applications</Name> <!-- This is necessary for your directory to appear in the applications drop down -->
<Menu> <!--app -->
<Name>app</Name>
<Directory>warron.directory</Directory>
<Include>
<Category>warron</Category>
</Include>
</Menu> <!-- End app -->
</Menu> <!-- End Applications -->
/usr/share/desktop-directories/warron.directory

Code: Select all

[Desktop Entry]
Name=warron
Comment=Warron Desktop programs
Icon=im-local-xmpp
Type=Directory
/usr/share/applications/warron.desktop

Code: Select all

[Desktop Entry]
Name=Warron Prog1
Comment=Firewall Configuration
Icon=im-local-xmpp
Categories=warron
# Translators: These are searchable keywords for the firewall configuration tool
Keywords=firewall;network;security;iptables;netfilter;
Exec=/usr/bin/firewall-config
Type=Application
StartupNotify=true
Terminal=false
X-Desktop-File-Install-Version=0.23
This was enough for me to complete the test/modeling of what I wanted to do.
Thanks,
Thanks,
War

Mikhail29
Posts: 12
Joined: 2019/03/23 11:43:32

Re: Create and place icon in Gnome Applications menu

Post by Mikhail29 » 2019/05/13 13:11:00

warron.french wrote:
2019/05/13 00:56:58
Can you please explain why this is three parts?
I did not particularly study this question, but somehow I searched for this information and added it to my bookmarks. But nevertheless, as I understand it .menu is a kind of link being created for the menu of the graphical shell that should be displayed. .directory is essentially a virtual menu folder where all application launch shortcuts will be placed when added, and .desktop itself is essentially a command to start a program. That is, the three links are obtained. Desktop refers to the menu directory ".directory", and in turn .directory refers to a new menu item in the .menu system. Although this is only my personal judgment, I can be mistaken.

User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

Re: Create and place icon in Gnome Applications menu

Post by warron.french » 2019/05/14 17:39:15

Mikhail29,

I seem to be having a problem with reproducing the success of this process on RHEL7.

Is it supposed to be different on RHEL7? The process worked for me at home on CentOS-7.

Sorry, I need a little more help,
Thanks,
War

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Create and place icon in Gnome Applications menu

Post by aks » 2019/05/14 18:34:06

AFAIK Gnome confirms to XDG:
https://specifications.freedesktop.org/ ... atest.html
(although what version of gnome and what version of xdg is respected may come into play).

User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

Re: Create and place icon in Gnome Applications menu

Post by warron.french » 2019/05/15 23:54:46

All, thank you for the support. I made some minor mistake apparently, but got it fixed.

I don't remember precisely what it was, but it had something to do with capitalization matching, not just for the filename within the <Directory> tag.

I am all set, thanks!

My RPM work, and the delivery of these Gnome menu and icons has been completed.
Thank you for "teaching me to fish" instead of "feeding me."
Thanks,
War

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: [SOLVED] - Create and place icon in Gnome Applications menu

Post by aks » 2019/05/16 17:04:41

I like fishing .....

User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

Re: [SOLVED] - Create and place icon in Gnome Applications menu

Post by warron.french » 2019/05/16 18:00:07

Me, too, I have not done it in a long time though.

The reference to fishing was: "Feed a man, he eats for a day. Teach him to fish and he eats for life." That's where I was going with the fishing reference.

I don't know how well dispersed the expression is though.
Thanks,
War

Post Reply