12

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?

3 Answers 3

3

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

1
  • Haven't had the chance to put this in to practice, but I wrote the script and it seems like the best way to go. Thanks for the tip! Apr 9, 2010 at 21:07
23

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
1

The Gentoo version of start-stop-daemon utility has an -e/--env option:

start-stop-daemon --start --pidfile /var/run/wine-app.pid -m \
    -c myuser -g mygroup -k 002 -e VAR1="Value" -e VAR2="Other value" \
    --exec /home/myuser/.wine/drive_c/Program\ Files/wine-app.exe
1
  • Welcome! This answer is OK for general reference, but the OP mentions that "my version of start-stop-daemon on Ubuntu 8.04 doesn't have the -e option"
    – TylerW
    Feb 23, 2022 at 16:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .