Score:1

How to find a .desktop file for a given gnome search icon

cn flag

Is there a generic way to find the .desktop entry for a specific menu entry in the gnome-search bar?

For example, I was trying to find the .desktop entry for the gnome Settings application. As shown in this image:


Note that I already found this particular .desktop file because I knew that the official application name is gnome-control-center.
Thus the following command got me the right file:

$ locate '*.desktop' | grep gnome-control-center
/usr/share/applications/gnome-control-center.desktop

However, this is not foolproof because the name of a desktop entry can be different from the application name.

So, I would love to learn a generic way of finding the .desktop entry for a given icon.

Score:1
zw flag

I would do this by using the following command:

grep -r "Name.*=Settings" --include="*.desktop" --exclude-dir=boot,dev,proc,run,snap,sys / 2> /dev/null

where:

  • grep -r "Name.*=Settings" - recursively finds needed line with displayed Settings word on icon;
  • --include="*.desktop" - instructs grep to search only inside desktop-files;
  • --exclude-dir=boot,dev,proc,run,snap,sys - excludes directories from search;
  • / - means to start search in the top directory;
  • 2> /dev/null - sends all errors to /dev/null to hide them.
melvio avatar
cn flag
Awesome, I'll mark it as accepted. It is good to add that this works well because `Name` is a required field in the desktop-entry specification https://specifications.freedesktop.org/desktop-entry-spec/latest/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.