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.
Type sysdm. cpl into the input field and hit Enter or press Ok. In the new window that opens, click on the Advanced tab and afterwards on the Environment Variables button in the bottom right of the window.
To list all the environment variables, use the command " env " (or " printenv "). You could also use " set " to list all the variables, including all local variables. To reference a variable, use $varname , with a prefix '$' (Windows uses %varname% ).
To display the values of environment variables, use the printenv command. If you specify the Name parameter, the system only prints the value associated with the variable you requested.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With