My 3-year girl loves SuperTux. She can't control the mouse, so the game should run automatically on startup. After the game, the computer should shut down automatically.
However when I put the below command in "crontab -e":
@reboot env DISPLAY=:0.0 /usr/games/supertux2 && echo "PASSWORD" | sudo -S shutdown -h now
The first part runs the game on an old PC at boot time. I expected the second part of the command to turn off the computer when my girl exits the game but it isn't working.
Doesn't the chain-command A && B
mean when the A finished, start B?
How can I automate the powering off computer when the game is closed?
Technically,
A && B
will only execute B when A is successful (exits with status of EXIT_SUCCESS, i.e. 0). Likewise,A || B
will only execute B when A fails. Another option could beA; B
which should execute B regardless of the exit status of A, but not until A has completed. I don't know how the games is currently exiting, but if it is not exiting with an EXIT_SUCCESS status, then B won't get executed.To test this you can run the following commands and see which ones generate the string:
Finally, you could create a shell script /usr/games/supertux2.sh:
And then call that on reboot, rather than /usr/games/supertux2