replace xxx_launcher scripts by frontend script
Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
parent
ee49693543
commit
961e7dbf24
|
@ -23,7 +23,7 @@ export HOME=/mnt/FunKey
|
|||
mkdir -p "${HOME}"
|
||||
export MEDNAFEN_HOME=$HOME/.mednafen
|
||||
mkdir -p "${MEDNAFEN_HOME}"
|
||||
cp -n "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/"
|
||||
cp "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/"
|
||||
export GMENU2X_HOME="$HOME/.gmenu2x"
|
||||
mkdir -p "${GMENU2X_HOME}"
|
||||
|
||||
|
@ -59,6 +59,6 @@ assembly_tests >/dev/null 2>&1
|
|||
# Restart saved application/game if any
|
||||
instant_play load
|
||||
|
||||
# Start launcher
|
||||
echo "Start launcher"
|
||||
start_launcher >/dev/null 2>&1 &
|
||||
# Start frontend
|
||||
echo "Start frontend"
|
||||
frontend init >/dev/null 2>&1 &
|
||||
|
|
|
@ -0,0 +1,152 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Uncomment the following line to get debug info
|
||||
#set -x
|
||||
|
||||
SELF="$(basename ${0})"
|
||||
LAUNCHER_FILE="$HOME/Launchers/launcher.txt"
|
||||
FRONTEND_FILE="$HOME/.frontend"
|
||||
PREVENT_LAUNCHER_FILE="/mnt/prevent_launcher"
|
||||
DISABLE_FRONTEND_FILE="/mnt/disable_frontend"
|
||||
DEFAULT_FRONTEND=retrofe
|
||||
LOCK_FILE="/var/lock/frontend.lock"
|
||||
REBOOTING_FILE="/run/rebooting"
|
||||
|
||||
# Convert old launcher file to new frontend
|
||||
if [ -f "${LAUNCHER_FILE}" ]; then
|
||||
mv "${LAUNCHER_FILE}" "${FRONTEND_FILE}"
|
||||
rm -rf $(dirname "${LAUNCHER_FILE}") 2>/dev/null
|
||||
fi
|
||||
|
||||
# Convert old prevent launcher file to new frontend disable file
|
||||
if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then
|
||||
mv "${PREVENT_LAUNCHER_FILE}" "{DISABLE_FRONTEND_FILE}"
|
||||
fi
|
||||
|
||||
usage() {
|
||||
>&2 echo "Usage: ${SELF} init"
|
||||
>&2 echo " ${SELF} get"
|
||||
>&2 echo " ${SELF} set gmenu2x|retrofe|none"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set_frontend() {
|
||||
mkdir -p "$(dirname "$FRONTEND_FILE")"
|
||||
local frontend=$(get_frontend)
|
||||
local new_frontend="${1}"
|
||||
echo "Setting frontend: ${new_frontend}"
|
||||
if [ "${new_frontend}" = "none" ]; then
|
||||
touch "${DISABLE_FRONTEND_FILE}"
|
||||
else
|
||||
rm -f "${DISABLE_FRONTEND_FILE}"
|
||||
fi
|
||||
if [ "${frontend}" != "none" ]; then
|
||||
pkill "${frontend}"
|
||||
fi
|
||||
echo "${new_frontend}" > "${FRONTEND_FILE}"
|
||||
}
|
||||
|
||||
get_frontend() {
|
||||
local frontend=$(cat "${FRONTEND_FILE}" 2>/dev/null | head -1)
|
||||
|
||||
# Check if not empty
|
||||
if [ "x${frontend}" = "x" ]; then
|
||||
frontend="${DEFAULT_FRONTEND}"
|
||||
echo "${frontend}" > "${FRONTEND_FILE}"
|
||||
fi
|
||||
|
||||
# Return frontend name
|
||||
echo "${frontend}"
|
||||
}
|
||||
|
||||
init_frontend() {
|
||||
if [ -f "${LOCK_FILE}" ]; then
|
||||
>&2 echo "${LOCK_FILE} already exists"
|
||||
exit 1
|
||||
fi
|
||||
touch "${LOCK_FILE}"
|
||||
|
||||
# Then loop to launch the frontend indefinitely
|
||||
while true; do
|
||||
|
||||
# Check if frontend disable file is present
|
||||
if [ -f "${DISBALE_FRONTEND_FILE}" ]; then
|
||||
echo "${DISABLE_FRONTEND_FILE} file found, not starting frontend"
|
||||
sleep 5
|
||||
else
|
||||
local frontend="$(get_frontend)"
|
||||
case "${frontend}" in
|
||||
gmenu2x|retrofe)
|
||||
"${frontend}"&
|
||||
;;
|
||||
|
||||
none)
|
||||
echo "no frontend"
|
||||
sleep 5
|
||||
;;
|
||||
|
||||
*)
|
||||
DEFAULT_FRONTEND=retrofe
|
||||
echo "Unrecognized frontend: $frontend, setting $DEFAULT_FRONTEND"
|
||||
set_frontend "${DEFAULT_FRONTEND}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# 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
|
||||
|
||||
# Prevent 100% CPU usage
|
||||
sleep 0.5
|
||||
|
||||
# Exit if console rebooting
|
||||
if [ -f "${REBOOTING_FILE}" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove lock file and exit
|
||||
rm "${LOCK_FILE}"
|
||||
}
|
||||
|
||||
# Check number of arguments
|
||||
if [ ${#} -lt 1 -o ${#} -gt 2 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
case "${1}" in
|
||||
set)
|
||||
if [ ${#} -ne 2 ]; then
|
||||
usage
|
||||
fi
|
||||
set_frontend "${2}"
|
||||
;;
|
||||
|
||||
get)
|
||||
if [ ${#} -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
get_frontend
|
||||
;;
|
||||
|
||||
init)
|
||||
if [ ${#} -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
init_frontend
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
exit 0
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Check args
|
||||
if [ ${#} -ne 0 ]; then
|
||||
echo "Usage: $(basename ${0})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Launcher File
|
||||
LAUNCHER_FILE=$HOME/Launchers/launcher.txt
|
||||
DEFAULT_LAUNCHER=retrofe
|
||||
|
||||
# Check that file exists
|
||||
[ -f "$LAUNCHER_FILE" ] || set_launcher $DEFAULT_LAUNCHER >/dev/null 2>&1
|
||||
|
||||
# Check Launcher
|
||||
launcher=$(cat "$LAUNCHER_FILE" | head -1)
|
||||
|
||||
# Check not empty
|
||||
[ -z "$LAUNCHER_FILE" ] && launcher=$DEFAULT_LAUNCHER; set_launcher $launcher >/dev/null 2>&1
|
||||
|
||||
# Return launcher name
|
||||
echo $launcher
|
||||
|
||||
exit 0
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Check number of args
|
||||
if [ ${#} -ne 1 ]; then
|
||||
echo "Usage: $(basename ${0}) launcher"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Launcher File
|
||||
LAUNCHER_FILE=$HOME/Launchers/launcher.txt
|
||||
mkdir -p "$(dirname "$LAUNCHER_FILE")"
|
||||
|
||||
# Check Launcher
|
||||
NEW_LAUNCHER=${1}
|
||||
echo "Setting launcher: ${NEW_LAUNCHER}"
|
||||
echo ${NEW_LAUNCHER} > "$LAUNCHER_FILE"
|
||||
|
||||
exit 0
|
|
@ -1,65 +0,0 @@
|
|||
#!/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
|
Loading…
Reference in New Issue