1

For example I have a menu when I right-click. In it, I can see 'open terminal'.

But where does Linux get the information about what to open and how can I change it to a custom option?

2
  • 2
    Hi and welcome to the site. Please edit your question and give us some more context. Where do you see this menu? When you right click on what? In what program? Using what Linux distribution? What desktop environment? This isn't a Linux feature, it will be specific to whatever set of tools you are using.
    – terdon
    Jun 26, 2018 at 12:05
  • You might want to have a look at mime types. Jun 26, 2018 at 12:18

1 Answer 1

4

"Linux" by itself is just a kernel and does not need to know. It is the graphical environment which is usually launching a runner, which then again launches the application.

XDG

Only the runner needs to know what to "do". Most graphical environment runners understand and use the XDG Desktop Entry specification. A more easy read on the subject would be the Arch linux wiki page. Like most freedesktop specifications, you will find that the syntax is very similar to windows' *.ini files.

Quotes

These qoutes are extracted from the arch wiki page, linked above. They hopefully summarize enough to give you the answer you are looking for.

Application entry

Desktop entries for applications, or .desktop files, are generally a combination of meta information resources and a shortcut of an application. These files usually reside in /usr/share/applications or /usr/local/share/applications for applications installed system-wide, or ~/.local/share/applications for user-specific applications. User entries take precedence over system entries.

Example file contents

[Desktop Entry]

# The type as listed above
Type=Application

# The version of the desktop entry specification to which this file complies
Version=1.0

# The name of the application
Name=jMemorize

# A comment which can/will be used as a tooltip
Comment=Flash card based learning tool

# The path to the folder in which the executable is run
Path=/opt/jmemorise

# The executable of the application, possibly with arguments.
Exec=jmemorize

# The name of the icon that will be used to display this entry
Icon=jmemorize

# Describes whether this application needs to be run in a terminal or not
Terminal=false

# Describes the categories in which this entry should be shown
Categories=Education;Languages;Java;

Run in terminal option

Some runners allow for "Run in terminal" option. In that case, the runner actually executes the default terminal (konsole for KDE, gnome-terminal for gnome) and appends the program's name to the terminal. For example for konsole with the -e option would run a command instead of the configured shell:

konsole -e command

Usually the runner will use .desktop files for both the terminal and the application to establish their execution commands.

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