Score:1

How can I change the command used to open an application?

in flag

Ubuntu 22.04LTS.

In Kubuntu (for instance) I could right-click on a program's icon and select "Properties" and add command line switches. In Ubuntu, that option doesn't exist.

The basic day-to-day stuff is simplified for ease of use, I presume, but I like having more options than fewer.

Any way to get to the application command?

Score:1
in flag

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:

  1. 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/.)

  2. Edit the private copy of the .desktop file:

    gedit firefox_firefox.desktop
    
  3. 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.

  4. 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;.

  5. 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.)

  6. 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.")

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.