FunKey-OS/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_launcher

66 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Uncomment the following line to get debug info
#set -x
LOCK_FILE="/var/lock/launcher.lock"
PREVENT_LAUNCHER_FILE="/mnt/prevent_launcher"
REBOOTING_FILE="/run/rebooting"
if [ -f "${LOCK_FILE}" ]; then
echo "${LOCK_FILE} already exists"
exit 1
fi
touch "${LOCK_FILE}"
# Then loop to launch the launcher indefinitely
while true; do
# Check if prevent launcher file present
if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then
echo "${PREVENT_LAUNCHER_FILE} file found, not starting launcher"
sleep 5
else
LAUNCHER=$(get_launcher)
if [ ${LAUNCHER} == "gmenu2x" ]; then
# Launch gmenu2x
gmenu2x&
elif [ ${LAUNCHER} == "retrofe" ]; then
# Launch Retrofe
retrofe&
else
DEFAULT_LAUNCHER=retrofe
echo "Not recognized launcher: $LAUNCHER, setting $DEFAULT_LAUNCHER"
set_launcher $DEFAULT_LAUNCHER
fi
# Record the PID into a file, wait for the
# process to terminate and erase the recorded PID
record_pid $!
wait $!
erase_pid
# In case retrofe/opkrun quits with errors, clear graphic VT
termfix_all
# In case retrofe/opkrun quits with errors, reset default key mapping
keymap default
fi
# WD to prevent 100% CPU
sleep 0.5
# Exit if console rebooting
if [ -f $REBOOTING_FILE ]; then
break
fi
done
# Remove lock file and exit
rm "${LOCK_FILE}"
exit 0