I just thought that I would ask what the best way to do this is.
I have a need to execute a program AFTER the player is started. It seems that if you use the irattach binary to start up the IrDA stack BEFORE the player app starts, something in the player app interferes with the IrDA stack, and IrDA is flaky.
I have a shell script called start_empire that contains the following:
#!/bin/bash
echo "start_empire: sleeping for $1 seconds..."
/usr/local/bin/sleep $1
echo "start_empire: Starting Empire..."
/usr/local/bin/irattach /dev/ttyS2
/usr/local/bin/empire
I added a line in my config.ini that reads:
;@EXEC_ONCE /bin/bash -c "/usr/local/bin/start_empire 7 &"
This does the job. It seems like 7 seconds is the sweet spot (on my player) where it will wait from the EXEC_ONCE line to after the player has started. The timing has to be configurable by modifying a variable in config.ini, since it will be different on other players.
Is there a better/cleaner way to do this, or is the shell script the best way to get this done? Would a better way be to modify empire.c so it does the irattach only after waiting for X seconds?