14

When launching an application through the command line I successfully use:

gourmet --gourmet-directory $HOME/my/custom/path/

But it does not work when trying to replicate this behaviour on a .desktop file with:

Exec=gourmet --gourmet-directory $HOME/my/custom/path/ %F 

I am probably missing something very basic here, but I cannot get my head around this. Any help would be much appreciated.

castaway
  • 245
  • 1
  • 3
  • 6
  • Can you clarify why you are using `%F` ? should the application open a list of files or it is just an application launcher, then you can open the files from the GUI – lese Oct 25 '15 at 21:57
  • 1
    You can make separate script-file with full command like `gourmet --gourmet-directory $HOME/my/custom/path/` than put into `.desktop` full path to the script. – Costas Oct 25 '15 at 22:05
  • @lese, good point I actually realised %F was not required. Jodka Lemon's solution worked both with and without it. – castaway Oct 25 '15 at 23:20

1 Answers1

13

Only command line options with one hyphen are possible in the Exec field.

Exec=sh -c "gourmet --gourmet-directory $HOME/my/custom/path/ %F"

should work.

Jodka Lemon
  • 3,143
  • 13
  • 42
  • Just tried today and `-g=4536+76` and `--geometry=4536+76` both worked equally well as arguments in `.desktop` exec line with or **without** `sh -c` wrapper in Ubuntu 16.04.6 LTS Unity Desktop. – WinEunuuchs2Unix May 10 '20 at 15:34
  • Wrapping command in `sh -c` worked. I wanted to execute this `sudo rogauracore initialize_keyboard; sudo rogauracore black`. I executed it this way -- `Exec=sh -c "sudo rogauracore initialize_keyboard; sudo rogauracore black"` – Mohit Atray Feb 16 '21 at 12:13
  • Found this answer while searching for a solution to this problem - thanks @Jodka Lemon. But ... does anyone know *why* this restriction was created? – Duncan Bayne Apr 28 '21 at 02:28
  • 1
    It doesn't seems to be true anymore, as the Desktop Specification (https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html) uses "Exec" examples with two hyphens. If it's not working at your distro, consider opening a Bug Report. – eduardomozart Aug 02 '22 at 11:47