1

I'm making a computer like an arcade machine with an academic game. I'm using Xsession to replace the desktop by an application. It's working fine. But when I go out from the game it returns to the LightDM - login screen. But I desire to shuts down instead back to LightDM. It's possible to do this?

Custom User Defined Session:

[Desktop Entry]
Encoding=UTF-8
Name=RacingGameX
Comment=Just the game!
Exec=/usr/share/xsessions/gameBash.sh
Type=Application

Bash Script:

xscreensaver -nosplash &
xrandr -r 60
exec /usr/bin/RacingGameX/RacingGameXExecutable
xrandr -r 75
sleep 5
sudo shutdown now # <- that's not working

Thanks for the help!

ulrich
  • 23

2 Answers2

1

The syntax for shutdown from command line is

sudo shutdown -P now ## for system POWEROFF
sudo shutdown -h now ## for system HALT or POWEROFF

If that did not work we can also perform a forced poweroff

sudo poweroff --force

In case we start the script from a user session (as was the case in a custom session) we can either allow users to shutdown without root privileges (don't use sudo in your script then!) or follow answers to below questions to shutdown without root privileges from a user session:

Takkat
  • 144,580
1

First of all I thank the members Takkat and David Foerster for the help. :)

The solution I've found:

If you have problem like this post, one solution is get the consolekit and insert the following code in your bash script to shutdown the system:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

The bash script will be:

xscreensaver -nosplash &
xrandr -r 60
/usr/bin/RacingGameX/RacingGameXExecutable
xrandr -r 75
sleep 5
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
ulrich
  • 23