Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a command with a working .desktop Exec key as follows:

Exec=env XDG_CONFIG_HOME=/home/bean/.config/gedit/ gedit %U

I would like to use the $HOME variable instead and it works in the terminal but not when used in the .desktop file. Please correct me if I'm wrong, but I assume this is because of improper "escape characters".

I have tried numerous variations of the command with \ and {} but to no avail. After looking around I'm not even sure if what I want can be accomplished.

share|improve this question
up vote 0 down vote accepted

There are no special characters there that you would need to escape, so no it's not an escaping issue. I just read through the freedesktop.org .desktop file specification and it does not explicitly mention environment variables, neither to allow nor disallow them. Nevertheless, neither $HOME nor ~ seem to be expanded in the exec field of a .desktop file.

So, it looks like what you're attempting is not possible.

share|improve this answer
Thank you, @terdon. I have been looking through examples of how other applications do it and they all seem to use absolute paths in the exec field. – beanaroo Mar 6 '14 at 23:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.