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!

2
  • exec transfers control to the executable named behind it. As it stands, sudo shutdown now is never reached. You should remove exec. This may be just one obstacle on the way to the solution. Feb 18, 2015 at 0:14
  • Thanks @DavidFoerster. I see the difference now. I thought the command exec was to run an application.
    – ulrich
    Feb 18, 2015 at 12:12

2 Answers 2

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:

3
  • Thanks for your answer Takkat! But that's commands line have tried and dont work. Btw I have followed your instructions in this question - askubuntu.com/questions/23932/…
    – ulrich
    Feb 17, 2015 at 22:17
  • @ulrich: totally missed that, sorry, you can't use sudo in your script - see edit.
    – Takkat
    Feb 18, 2015 at 7:31
  • It worked! Thanks very much @Takkat! I posted in the main post the solution.
    – ulrich
    Feb 18, 2015 at 12:14
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

You must log in to answer this question.

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