Minor Kobo startup script cleanups (#6102)

* Start re-factoring the launcher detection code in order to future-proof
it
reviewable/pr6099/r2
NiLuJe 4 years ago committed by GitHub
parent 1a91893576
commit be72203b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
.gitignore vendored

@ -12,6 +12,7 @@ lua-*
.reader.kpdfview.lua
*.kdev4
.kdev4/*
.kateconfig
.vimrc
.vscode/*
*.o

@ -73,15 +73,15 @@ export STARDICT_DATA_DIR="data/dict"
# export external font directory
export EXT_FONT_DIR="/mnt/onboard/fonts"
# fast and dirty way of check if we are called from nickel
# through fmon/KFMon, or from another launcher (KSM or advboot)
# Do not delete this line because KSM detects newer versions of KOReader by the presence of the phrase 'from_nickel'.
export FROM_NICKEL="false"
# Quick'n dirty way of checking if we were started while Nickel was running (e.g., KFMon),
# or from another launcher entirely, outside of Nickel (e.g., KSM).
VIA_NICKEL="false"
if pkill -0 nickel; then
FROM_NICKEL="true"
VIA_NICKEL="true"
fi
# NOTE: Do not delete this line because KSM detects newer versions of KOReader by the presence of the phrase 'from_nickel'.
if [ "${FROM_NICKEL}" = "true" ]; then
if [ "${VIA_NICKEL}" = "true" ]; then
# Detect if we were started from KFMon
FROM_KFMON="false"
if pkill -0 kfmon; then
@ -91,13 +91,22 @@ if [ "${FROM_NICKEL}" = "true" ]; then
fi
fi
# Siphon a few things from nickel's env (namely, stuff exported by rcS *after* on-animator.sh has been launched)...
eval "$(xargs -n 1 -0 <"/proc/$(pidof nickel)/environ" | grep -e DBUS_SESSION_BUS_ADDRESS -e NICKEL_HOME -e WIFI_MODULE -e LANG -e WIFI_MODULE_PATH -e INTERFACE 2>/dev/null)"
export DBUS_SESSION_BUS_ADDRESS NICKEL_HOME WIFI_MODULE LANG WIFI_MODULE_PATH INTERFACE
# Check if Nickel is our parent...
FROM_NICKEL="false"
if [ -n "${NICKEL_HOME}" ]; then
FROM_NICKEL="true"
fi
# If we were spawned outside of Nickel, we'll need a few extra bits from its own env...
if [ "${FROM_NICKEL}" = "false" ]; then
# Siphon a few things from nickel's env (namely, stuff exported by rcS *after* on-animator.sh has been launched)...
eval "$(xargs -n 1 -0 <"/proc/$(pidof nickel)/environ" | grep -e DBUS_SESSION_BUS_ADDRESS -e NICKEL_HOME -e WIFI_MODULE -e LANG -e WIFI_MODULE_PATH -e INTERFACE 2>/dev/null)"
export DBUS_SESSION_BUS_ADDRESS NICKEL_HOME WIFI_MODULE LANG WIFI_MODULE_PATH INTERFACE
fi
# flush disks, might help avoid trashing nickel's DB...
# Flush disks, might help avoid trashing nickel's DB...
sync
# stop kobo software because it's running
# And we can now stop the full Kobo software stack
# NOTE: We don't need to kill KFMon, it's smart enough not to allow running anything else while we're up
killall -TERM nickel hindenburg sickel fickel fmon 2>/dev/null
fi
@ -316,11 +325,9 @@ if [ -n "${ORIG_CPUFREQ_GOV}" ]; then
echo "${ORIG_CPUFREQ_GOV}" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
fi
if [ "${FROM_NICKEL}" = "true" ]; then
if [ "${FROM_KFMON}" != "true" ]; then
# start kobo software because it was running before koreader
./nickel.sh &
else
if [ "${VIA_NICKEL}" = "true" ]; then
if [ "${FROM_KFMON}" = "true" ]; then
# KFMon is the only launcher that has a toggle to either reboot or restart Nickel on exit
if grep -q "reboot_on_exit=false" "/mnt/onboard/.adds/kfmon/config/koreader.ini" 2>/dev/null; then
# KFMon asked us to restart nickel on exit (default since KFMon 0.9.5)
./nickel.sh &
@ -328,6 +335,9 @@ if [ "${FROM_NICKEL}" = "true" ]; then
# KFMon asked us to restart the device on exit
/sbin/reboot
fi
else
# Otherwise, just restart Nickel
./nickel.sh &
fi
else
# if we were called from advboot then we must reboot to go to the menu

@ -9,7 +9,9 @@ export LD_LIBRARY_PATH="/usr/local/Kobo"
# Reset PWD, and clear up our own custom stuff from the env while we're there, otherwise, USBMS may become very wonky on newer FW...
# shellcheck disable=SC2164
cd /
unset OLDPWD EXT_FONT_DIR TESSDATA_PREFIX FROM_NICKEL STARDICT_DATA_DIR LC_ALL KO_NO_CBB
unset OLDPWD
unset LC_ALL TESSDATA_PREFIX STARDICT_DATA_DIR EXT_FONT_DIR
unset KO_NO_CBB
# Ensures fmon will restart. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start.
(

Loading…
Cancel
Save