7

EDIT: This is not a duplicate as this question is the reverse of what the other question is asking. Here we know what is the application and we want to find its .desktop file that can be located in non standard places also. While the other question is about where the .desktop files can be placed.


I want to open images from an FTP server in the default image viewer rather than in the browser, so I wanted to know the path of default image viewer desktop file in Ubuntu. I tried the following:

cd -- /usr/share/applications
/usr/share/applications

$ find . -name '*.desktop' | grep image
./gnome-disk-image-mounter.desktop
./gnome-disk-image-writer.desktop

$ find . -name '*.desktop' | grep view
./calibre-ebook-viewer.desktop
./calibre-lrfviewer.desktop
./evince-previewer.desktop
./shotwell-viewer.desktop
./okularApplication_ghostview.desktop
./gcr-viewer.desktop
./gnome-info-overview-panel.desktop
./org.gnome.font-viewer.desktop
./paraview.desktop

But I still couldn't find it. Are there any other locations where the desktop files are stored?

3
  • Possible duplicate of Which *.desktop files belong where?
    – lamino
    Jul 24, 2019 at 16:18
  • @lamino This is not a duplicate as this question is the reverse of what the other question is asking. Here we know what is the application and we want to find its .desktop file that can be located in non standard places also. While the other question is about where the .desktop files can be placed. So this is one to many mapping. While the other is many to one mapping
    – Porcupine
    Jul 24, 2019 at 16:20
  • So this is one to many mapping. While the other is many to one mapping!
    – Porcupine
    Jul 24, 2019 at 16:22

3 Answers 3

7

A much faster and more universal search is with locate command:

$ locate *image*desktop
/usr/share/app-install/desktop/gimagereader:gimagereader-gtk.desktop
/usr/share/app-install/desktop/gnome-disk-utility:gnome-disk-image-mounter.desktop
/usr/share/app-install/desktop/gnome-disk-utility:gnome-disk-image-writer.desktop
/usr/share/app-install/desktop/imagej:imagej.desktop
/usr/share/app-install/desktop/imagemagick-6.q16:display-im6.q16.desktop
/usr/share/app-install/desktop/imagemagick:display-im6.desktop
/usr/share/app-install/desktop/imagevis3d:imagevis3d.desktop
/usr/share/app-install/desktop/kimagemapeditor:kde4__kimagemapeditor.desktop
/usr/share/app-install/desktop/simple-image-reducer:simple-image-reducer.desktop
/usr/share/app-install/desktop/trimage:trimage.desktop
/usr/share/applications/gnome-disk-image-mounter.desktop
/usr/share/applications/gnome-disk-image-writer.desktop
/usr/share/applications/screensavers/tessellimage.desktop

locate can search millions of files in a few seconds where it would take find many many minutes:

$ time find / -name '*image*.desktop'
real    0m52.563s
user    0m6.271s
sys     0m9.002s

$ time locate *image*desktop
real    0m0.705s
user    0m0.693s
sys     0m0.012s

Notice how grep was eliminated from original method and find command was ammended.

The disadvantage of locate is the database is updated daily. If you just installed the application you are searching for today, you will first need to run:

sudo updatedb
3

The name of the desktop file alone may not reveal sufficient information. The fundamental approach is to search the content of all .desktop files of the system to find the relevant one(s).

For example, the image viewer is displayed as Image Viewer in the Applications overview. Gnome Shell obtained that label from the .desktop file. To find the .desktop file (or files) that contains this string, execute

find / -name '*.desktop' -exec grep -H 'Image Viewer' {} \; 2>/dev/null

This uses find to find all .desktop files on the system. For each of the found files, grep is invoked, which searches for a string in the file, in this example Image Viewer. The 2>/dev/null suppresses the permission errors you inevitably get searching the root drive without root permissions.

0

Well my solution is very easy and here is how you do it if you are looking for the application with a icon in your apps

ls -la /usr/share/applications | grep <name_of_app_you_are_looking_for>

for Example i want to find location for some apps in my Ubuntu --- i want to find the desktop file for Google Chrome enter image description here

But it only works for the apps inside /usr/share/applications

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.