سؤال

My program requires an environment variable as part of one of its parameters:

myprogram --folder=$HOME/.special

However, if I put this into a .desktop file's exec line, it doesn't work:

Exec=myprogram --folder=$HOME/.special

The $HOME seems to resolve to nothing.

هل كانت مفيدة؟

المحلول

By default environment variables do not seem to be resolved by all implementations, however you can instead exec sh, which will resolve the passed environment variable. Note that the desktop spec also requires you to escape the = and $ character with a backslash. So you want:

Exec=sh -c "myprogram --folder\=\$HOME/.special"

For the full list of characters that need escaping, see the specification

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top