-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemulationstation.sh
executable file
·45 lines (43 loc) · 1.63 KB
/
emulationstation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# * A link named emulationstation pointing to the ES executable must be in the
# same directory as this script file.
# * reboot and poweroff are symlinks to systemctl. systemd only allows to
# shutdown the system to logged in users. This is the reason those
# commands cannot be used in this script. DBus must be used
# for rebooting/powering off.
esdir="$(dirname $0)"
echo "Starting emulationstation.sh in $esdir"
while true; do
rm -f /tmp/es-restart /tmp/es-sysrestart /tmp/es-shutdown
# Dump core for debugging purposes.
ulimit -c unlimited; "$esdir/emulationstation" --no-exit --debug "$@"
# Default running method, do not allow ES to exit.
# "$esdir/emulationstation" --no-exit "$@"
ret=$?
echo "EmulationStation returned $ret"
if [ $ret -eq 139 ]; then
echo "EmulationStation crashed. Restarting..."
continue
fi
if [ -f /tmp/es-restart ]; then
echo "Restarting EmulationStation..."
continue
fi
if [ -f /tmp/es-sysrestart ]; then
echo "Rebooting system..."
rm -f /tmp/es-sysrestart
# reboot
dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.Reboot" boolean:true
break
fi
if [ -f /tmp/es-shutdown ]; then
echo "Shutting down system..."
rm -f /tmp/es-shutdown
# poweroff
dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.PowerOff" boolean:true
break
fi
break
done
echo "Ending emulationstation.sh. Will return $ret"
exit $ret