Ubuntu – Finding .desktop files based on their titles

unityunity-dash

That's part 2 of a question asked earlier (to be able to give credit to the answers individually).

When I type into the Dash applications show up with their title (also when hovering over the launcher), how can I find the associated desktop file. When I look into the usual suspect locations (/usr/share/applications and ~/.local/share/applications) with Nautilus I see the titles, but not the file names (not even in properties which sucks). When I look from the command line I see the file names but not the titles (a switch would be nice).

How can I get a listing (a custom column?) that shows them next to each other?

Best Answer

Command line

grep ^Name=  /usr/share/applications/* | sed 's/:Name=/   /'

grep searches in all file in /usr/share/applications/ for a line starting with Name=.

For each line it finds it prints filename:line, for example

/usr/share/applications/yelp.desktop:Name=Help

To make it look a bit better we use sed 's/:Name=/ /' to replace :Name= with (three spaces)

Quick hack for the list view in Nautilus:

Install the package python-nautilus, create the folder ~/.local/share/nautilus-python/extensions and save the following code as ~/.local/share/nautilus-python/extensions/filename-column.py:

import os
import urllib

from gi.repository import Nautilus, GObject

class FilenameColumn(GObject.GObject, Nautilus.ColumnProvider, Nautilus.InfoProvider):
    def __init__(self):
        pass

    def get_columns(self):
        return Nautilus.Column(name="NautilusPython::fd_filename_column",
                               attribute="fd_filename",
                               label="file name",
                               description="file name"),

    def update_file_info(self, file):
        filename = file.get_name()        
        file.add_string_attribute('fd_filename', filename)

Run nautilus -q; nautilus& at the command line to restart Nautilus. Then in the nautilus menu go to Edit -> Preferences -> List Columns and activate the file name column (you may want to move it up, too). Now you have an additional column in list view that always shows the file name.

Isn't exactly pretty but does it's job.

Related Question