Can start-stop-daemon use environmental variables?

I need to daemonize a Windows app running in Wine, and create a pid in /var/run. Since it requires an X11 session to run, I need to make sure the $DISPLAY variable is set in the running user's environment.

Assuming I already have a X11 session running, with a given display, here's what the start-stop-daemon line looks like in my /etc/init.d script:

start-stop-daemon --start --pidfile /var/run/wine-app.pid -m -c myuser -g mygroup -k 002 --exec /home/myuser/.wine/drive_c/Program\ Files/wine-app.exe

Unfortunately, my version of start-stop-daemon on Ubuntu 8.04 doesn't have the -e option to set environmental variables. I gather that you could simply set $DISPLAY before the command, like so:

VAR1="Value" start-stop-daemon ...

But it doesn't work. Since I'm using the -c {user} option to run as a specific user, I'm guessing there's an environment switch and VAR1 is lost. I've tried exporting DISPLAY from the running user's .profile and/or .bashrc but it doesn't work either.

Is there another way to do this? Is this even possible? Am I overlooking something?


You could write a shell script to set the variable and then run wine.


You can use env to modify the environment:

start-stop-daemon --start --pidfile /var/run/wine-app.pid -m -c myuser -g mygroup -k 002 --exec /usr/bin/env VAR1="Value" /home/myuser/.wine/drive_c/Program\ Files/wine-app.exe