3

I am making .desktop for teamspeak as their programmers didn't.

It ought to work for everyone and to do so I need to target home folder universaly with EXEC.

So let's pretend program X is in ~/.local

  • /home/username/.local/X this way works only for me

EDIT: This solved it for EXEC but doesn't apply to the ICON thus I placed it to /usr/share/icons which is workaround.

Tichun
  • 73
  • 1
  • 5
  • why did you accept an answer that does not even *possibly* work?? Relative paths like `$HOME` do not work in a `.desktop` file. – Jacob Vlijm Feb 20 '16 at 22:21
  • " That's not enough. See askubuntu.com/a/139198/158442 – muru Feb 19 at 19:37 " as you can see it was posted *before* you did comment here and I have had also *already* included in my EDIT.. so congratulations for writing before reading. – Tichun Feb 24 '16 at 21:20
  • I mentioned you accepted an answer *before* the edit was made on the answer (an edit after my comments on the answer). You should accept an *answer*, not including a comment in your own question. As said, you accepted a non working answer. – Jacob Vlijm Feb 24 '16 at 21:25

1 Answers1

5

You can use the environment variable HOME. It stores the absolute path to the current user's home folder.

Here's how you can use it:

Exec=/bin/sh -c "$HOME/.local/X"

It's very important putting the $ before HOME so it's read as a variable. Also do not forget write HOME in capital letters only.

Don't forget to wrap shell variable using " double quote else it will fail at execution time.

vrkansagara
  • 113
  • 4
Eduardo Cola
  • 5,757
  • 3
  • 18
  • 32
  • That's not enough. See http://askubuntu.com/a/139198/158442 – muru Feb 19 '16 at 19:37
  • @EduardoCola I'd appreciate if you don't take it as-, -nor make it- a personal thing. When using `sh -c` or `/bin/bash -c` anything can be done, since either `sh` or `bash` is running the command then. When using your construction directly in the `Exec=` line, it simply doesn't *possibly* work, and the answer is a non- working one. You shouldn't want that. Accepted or not. – Jacob Vlijm Feb 20 '16 at 23:41
  • `plasmashell` expands `~` in `Exec` just fine, no need for `/bin/sh`. – Maxim Egorushkin Sep 11 '22 at 11:04
  • @MaximEgorushkin Just checked: it does not expand `~` in `Exec`, but it does expand `$HOME` (without `sh -c ...`) – Shevchuk Feb 14 '23 at 02:03
  • @Shevchuk Your experience is different from mine. I invoke my `*.desktop` files with `Exec=~/...` on daily basis and `plasmashell` executes them without fail. My login shell is `/bin/bash`. You may like to verify your checks. – Maxim Egorushkin Feb 22 '23 at 00:50
  • @Shevchuk Post a [minimal, complete and reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) if you need help. – Maxim Egorushkin Feb 22 '23 at 01:14