2

When using Nautilus and I navigate to the /usr/share/applications directory I get a listing of the meta data that is extracted from all of the .desktop files that live in that directory.

So the file in my example called "Oracle Java 7 Runtime" in Nautilus translates to the file JB-java.desktop which I took a wild guess at. In Nautilus the properties dialog does not reveal the name of that file, so its a hit and miss approach to get the file name.

Is there a better way? Short of looking for the string "Oracle Java 7 Runtime" in all of the files in the directory which is a bit clumsy.

2 Answers 2

2

The reply by @green7 is OK if you like the terminal.

However, this can be done directly from Nautilus, although it requires a script.

  1. I have written the script for you. I don't know how to attach a script to this answer, so please download it from my file area.
  2. Save this file to the following folder:
    ~/.gnome2/nautilus-scripts
    This means the folder nautilus-scripts within .gnome2 inside your home folder. Note the . in front of .gnome2; this means it is a hidden file, and you need to press Ctrl+H within Nautilus to be able to see it. If the nautilus-scripts folder doesn't exist, create it.
  3. Once you have saved the script there, you need to make it executable. Right-click the file in Nautilus, select Properties > Permissions > Allow executing file as program > Close.
  4. Finally, you have to close Nautilus and re-open it (you may have to log out and in again, although I don't think you do).

Now, to use the script, use Nautilus to find those desktop files again. Select one or more of them > right-click > Scripts > Show .desktop name.

An example is shown below.

Example of three desktop files..

2
  • Thank you very much for taking the time, this example will set me on an adventure of Nautilus scripting.
    – Meer Borg
    Mar 11, 2013 at 5:20
  • Doogfar, I have found Nautilus scripting highly useful. For example, I have a scripts to do: MD5, SHA1 and SHA256 sums for files; open as administrator; and create hard links. Here's something for you to try: right-click anywhere in Nautilus > Scripts > Open Scripts Folder > Show more details. Mar 11, 2013 at 10:50
1

I wrote a script to do so:

#! /bin/bash
# is: Inline file search script
# Save as: /usr/bin/is and mark executable

filename="$1"
echo -n "Enter the command name: "
commandName=""
while [ -z "$commandName" ];
do
read commandName
done

exec $commandName $filename 

To add auto-completion to the script:


# Save as: /etc/bash/completion.d/is

_is()
{
  local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    if [[ ${cur} == * ]]; then
        COMPREPLY=( $(find ./ -maxdepth 1 -iname "*${cur}*" | cut -d '/' -f 2) ) 
        return 0
    fi
}
complete -F _is is

It is an inline file search utility.

Suppose you’re in a directory having a lot of files. You want to search for a file but you remember it’s name only in bits and pieces.

For example, if you just remember oracle, all you have to do is:

  • Browse to the directory
cd /path/to/the/directory
  • Type the following and press TAB:
is oracle
  • It will show you the list of all the files having oracle in their names.
  • You can then modify the argument and press TAB to select a particular file.
  • Then press Enter to select a program to open that file.
1
  • Thanks for this alternative solution, which also expands my Linux knowledge, thank you for the lesson
    – Meer Borg
    Mar 11, 2013 at 5:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .