8

I've created a .desktop file to launch our application. Our application requires, that a certain environment variable is configured correctly. Where can I configure this environment variable on a per-user base (the usual candidates I know, like ~/.bashrc and ~/.profile don't work).

Maybe there is a work-around, so I can configure it in the Exec= line of the .desktop file before launching the application?

Mike L.
  • 5,937

1 Answers1

17

In the desktop file itself, you can execute the program through env:

Exec=/usr/bin/env VAR=value /usr/bin/yourprogram

Alternatively, use a wrapper script (e.g. /usr/bin/yourprogram.env):

#!/bin/sh
VAR=value
export VAR
exec /usr/bin/yourprogram.real "$@"

However, both are poor solutions, since Unity will not be able to correctly track the program if it is started through a wrapper.

It would be much better to get ~/.profile working – make sure you're using the correct syntax and all that:

export VAR=value

or

VAR=value
export VAR

Also remember that ~/.profile is only read when you log in, so you must log out after changing it.

grawity
  • 501,077