The icons which you see in the Dash or in the Applications Overview come from a set of .desktop
files.
The format of a .desktop
file is given in the Desktop Entry Specification by FreeDesktop.org.
The system-wide .desktop
files live in /usr/share/applications/
or, for snappified applications, in /var/lib/snapd/desktop/applications/
.
In order to modify one of them, copy it to $HOME/.local/share/applications/
and edit the copy. When a file in your $HOME/.local/share/applications/
is found with the same name as a system-wide file it takes precedence, so that your modified copy will be used in preference to the system-wide file.
(Note that for some silly reason a desktop file needs to have the executable bit set -- rwxr-xr-x
works fine. Gnome is strange. Make sure that you don't change the mode of the file when copying it.)
For example, if you right-click on the Firefox icon in the Dash, by default it offers two actions: Open a New Window and Open a New Private Window. Let's add a third action, Open Google in a New Window:
Copy the system-wide Firefox desktop description file to your per-user applications folder:
cd ~/.local/share/applications
cp /var/lib/snapd/desktop/applications/firefox_firefox.desktop .
(Assuming that you have the snappified Firefox which is bundled with the system. If you have replaced it with a natively installed Firefox, you will copy it from /usr/share/applications/
.)
Edit the private copy of the .desktop
file:
gedit firefox_firefox.desktop
The file has the general structure of an .ini
file, that is, stanzas with names in [
brackets]
and zero or more assignments of the form <setting>=
<value> in each stanza.
The first stanza is [Desktop Entry]
. In this stanza you will find a line saying Actions=NewWindow;NewPrivateWindow;
, which gives the names of the stanzas describing the predefined actions. Edit it to say Actions=NewWindow;NewPrivateWindow;NewGoogleWindow;
.
Then add at the end of the file a stanza named [Desktop Action NewGoogleWindow]
by copying the [Desktop Action NewWindow]
stanza.
You see a line with Name=
; this is what gets displayed when you right click the icon in the Dash or in the Applications Overview.
The Name[
xx]=
lines give translations in various languages; you can safely delete them, except maybe the line giving the translation in your native language, if you want it.
The line Exec=
gives the command line to be executed. Some characters have special meanings; be sure to read the relevant part of the specification.
The best is to change the Exec=
line you have copied as little as possible; for the example, this is changed to
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/firefox_firefox.desktop /snap/bin/firefox -new-window https://www.google.com
(This is a long line. Scroll to the right to see all of it.)
(Again, this is for the snappified Firefox as shipped with the system. If you have replaced it with a natively installed Firefox, the details may be different.)
Save the edited copy, log out and log in again. (Because the .desktop
files are read only when starting a new user session. "GNOME is designed to help you have the best possible computing experience.")