fixed little regression when handling previous prevent_launcher file

This commit is contained in:
Vincent-FK 2021-06-09 00:26:46 +02:00
parent b2847c1cd4
commit bfed99494e
3 changed files with 60 additions and 59 deletions

View File

@ -21,7 +21,7 @@ fi
# Convert old prevent launcher file to new frontend disable file # Convert old prevent launcher file to new frontend disable file
if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then
mv "${PREVENT_LAUNCHER_FILE}" "{DISABLE_FRONTEND_FILE}" mv "${PREVENT_LAUNCHER_FILE}" "${DISABLE_FRONTEND_FILE}"
fi fi
usage() { usage() {
@ -37,12 +37,12 @@ set_frontend() {
local new_frontend="${1}" local new_frontend="${1}"
echo "Setting frontend: ${new_frontend}" echo "Setting frontend: ${new_frontend}"
if [ "${new_frontend}" = "none" ]; then if [ "${new_frontend}" = "none" ]; then
touch "${DISABLE_FRONTEND_FILE}" touch "${DISABLE_FRONTEND_FILE}"
else else
rm -f "${DISABLE_FRONTEND_FILE}" rm -f "${DISABLE_FRONTEND_FILE}"
fi fi
if [ "${frontend}" != "none" ]; then if [ "${frontend}" != "none" ]; then
pkill "${frontend}" pkill "${frontend}"
fi fi
echo "${new_frontend}" > "${FRONTEND_FILE}" echo "${new_frontend}" > "${FRONTEND_FILE}"
} }
@ -52,8 +52,8 @@ get_frontend() {
# Check if not empty # Check if not empty
if [ "x${frontend}" = "x" ]; then if [ "x${frontend}" = "x" ]; then
frontend="${DEFAULT_FRONTEND}" frontend="${DEFAULT_FRONTEND}"
echo "${frontend}" > "${FRONTEND_FILE}" echo "${frontend}" > "${FRONTEND_FILE}"
fi fi
# Return frontend name # Return frontend name
@ -62,62 +62,63 @@ get_frontend() {
init_frontend() { init_frontend() {
if [ -f "${LOCK_FILE}" ]; then if [ -f "${LOCK_FILE}" ]; then
>&2 echo "${LOCK_FILE} already exists" >&2 echo "${LOCK_FILE} already exists"
exit 1 exit 1
fi fi
touch "${LOCK_FILE}" touch "${LOCK_FILE}"
# Then loop to launch the frontend indefinitely # Then loop to launch the frontend indefinitely
while true; do while true; do
# Check if frontend disable file is present # Check if frontend disable file is present
if [ -f "${DISBALE_FRONTEND_FILE}" ]; then if [ -f "${DISABLE_FRONTEND_FILE}" ]; then
echo "${DISABLE_FRONTEND_FILE} file found, not starting frontend" echo "${DISABLE_FRONTEND_FILE} file found, not starting frontend"
sleep 5
else
# Umount any remaining OPK, if any
umount /opk >/dev/null 2>&1
rm -f "${LAST_OPK_FILE}"
local frontend="$(get_frontend)"
case "${frontend}" in
gmenu2x|retrofe)
"${frontend}"&
;;
none)
echo "no frontend"
sleep 5 sleep 5
;; else
*) # Umount any remaining OPK, if any
DEFAULT_FRONTEND=retrofe umount /opk >/dev/null 2>&1
echo "Unrecognized frontend: $frontend, setting $DEFAULT_FRONTEND" rm -f "${LAST_OPK_FILE}"
set_frontend "${DEFAULT_FRONTEND}"
;;
esac
# Record the PID into a file, wait for the process to # Launch selected frontend
# terminate and erase the recorded PID local frontend="$(get_frontend)"
pid record $! case "${frontend}" in
wait $! gmenu2x|retrofe)
pid erase "${frontend}"&
;;
# In case retrofe/opkrun quits with errors, clear graphic VT none)
termfix_all echo "no frontend"
sleep 5
;;
# In case retrofe/opkrun quits with errors, reset default key mapping *)
keymap default DEFAULT_FRONTEND=retrofe
fi echo "Unrecognized frontend: $frontend, setting $DEFAULT_FRONTEND"
set_frontend "${DEFAULT_FRONTEND}"
;;
esac
# Prevent 100% CPU usage # Record the PID into a file, wait for the process to
sleep 0.5 # terminate and erase the recorded PID
pid record $!
wait $!
pid erase
# Exit if console rebooting # In case retrofe/opkrun quits with errors, clear graphic VT
if [ -f "${REBOOTING_FILE}" ]; then termfix_all
break
fi # 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 done
# Remove lock file and exit # Remove lock file and exit

View File

@ -20,7 +20,7 @@ if [ ${#} -lt 1 ]; then
fi fi
case ${1} in case ${1} in
load) load)
if [ ${#} -ne 1 ]; then if [ ${#} -ne 1 ]; then
usage usage
fi fi
@ -52,7 +52,7 @@ case ${1} in
fi fi
;; ;;
save) save)
if [ ${#} -lt 2 ]; then if [ ${#} -lt 2 ]; then
usage usage
fi fi
@ -80,7 +80,7 @@ EOF
exec powerdown now exec powerdown now
;; ;;
*) *)
usage usage
;; ;;
esac esac

View File

@ -24,12 +24,12 @@ increase_volume() {
local new_volume=0 local new_volume=0
let new_volume=${current_volume}+${VOLUME_STEP} let new_volume=${current_volume}+${VOLUME_STEP}
if [ ${new_volume} -gt 100 ]; then if [ ${new_volume} -gt 100 ]; then
new_volume=100 new_volume=100
fi fi
# Change volume # Change volume
if [ ${new_volume} -ne ${current_volume} ]; then if [ ${new_volume} -ne ${current_volume} ]; then
set_volume ${new_volume} set_volume ${new_volume}
fi fi
# Notif # Notif
@ -44,12 +44,12 @@ decrease_volume() {
# Compute new volume value # Compute new volume value
local new_volume=0 local new_volume=0
if [ ${current_volume} -gt ${VOLUME_STEP} ]; then if [ ${current_volume} -gt ${VOLUME_STEP} ]; then
let new_volume=${current_volume}-${VOLUME_STEP} let new_volume=${current_volume}-${VOLUME_STEP}
fi fi
# Change volume # Change volume
if [ ${new_volume} -ne ${current_volume} ]; then if [ ${new_volume} -ne ${current_volume} ]; then
set_volume ${new_volume} set_volume ${new_volume}
fi fi
# Notif # Notif
@ -77,14 +77,14 @@ set_volume() {
# Set the new volume value in a bootloader variable # Set the new volume value in a bootloader variable
if [ ${?} -eq 0 -a ${current_volume} -ne ${new_volume} ]; then if [ ${?} -eq 0 -a ${current_volume} -ne ${new_volume} ]; then
fw_setenv volume ${new_volume} fw_setenv volume ${new_volume}
fi fi
# Turn on/off audio amplifier if necessary # Turn on/off audio amplifier if necessary
if [ ${new_volume} -eq 0 ]; then if [ ${new_volume} -eq 0 ]; then
audio_amp off audio_amp off
else else
audio_amp on audio_amp on
fi fi
} }