if ! grep ${KOREADER_DIR}/fonts/host /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting system fonts . . ."
mount -o bind /usr/java/lib/fonts ${KOREADER_DIR}/fonts/host
if ! grep ${KOREADER_DIR}/fonts/host /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting system fonts . . ."
mount -o bind /usr/java/lib/fonts ${KOREADER_DIR}/fonts/host
fi
# bind-mount altfonts
if[ -d /mnt/us/fonts ];then
mkdir -p ${KOREADER_DIR}/fonts/altfonts
if ! grep ${KOREADER_DIR}/fonts/altfonts /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting altfonts . . ."
mount -o bind /mnt/us/fonts ${KOREADER_DIR}/fonts/altfonts
fi
if[ -d /mnt/us/fonts ];then
mkdir -p ${KOREADER_DIR}/fonts/altfonts
if ! grep ${KOREADER_DIR}/fonts/altfonts /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting altfonts . . ."
mount -o bind /mnt/us/fonts ${KOREADER_DIR}/fonts/altfonts
fi
fi
# bind-mount csp fonts
if[ -d /var/local/font/mnt ];then
mkdir -p ${KOREADER_DIR}/fonts/cspfonts
if ! grep ${KOREADER_DIR}/fonts/cspfonts /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting cspfonts . . ."
mount -o bind /var/local/font/mnt ${KOREADER_DIR}/fonts/cspfonts
fi
if[ -d /var/local/font/mnt ];then
mkdir -p ${KOREADER_DIR}/fonts/cspfonts
if ! grep ${KOREADER_DIR}/fonts/cspfonts /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting cspfonts . . ."
mount -o bind /var/local/font/mnt ${KOREADER_DIR}/fonts/cspfonts
fi
fi
# bind-mount linkfonts
if[ -d /mnt/us/linkfonts/fonts ];then
mkdir -p ${KOREADER_DIR}/fonts/linkfonts
if ! grep ${KOREADER_DIR}/fonts/linkfonts /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting linkfonts . . ."
mount -o bind /mnt/us/linkfonts/fonts ${KOREADER_DIR}/fonts/linkfonts
fi
if[ -d /mnt/us/linkfonts/fonts ];then
mkdir -p ${KOREADER_DIR}/fonts/linkfonts
if ! grep ${KOREADER_DIR}/fonts/linkfonts /proc/mounts >/dev/null 2>&1;then
logmsg "Mounting linkfonts . . ."
mount -o bind /mnt/us/linkfonts/fonts ${KOREADER_DIR}/fonts/linkfonts
fi
fi
# check if we need to disable the system passcode, because it messes with us in fun and interesting (and, more to the point, intractable) ways...
# NOTE: The most egregious one being that it inhibits the outOfScreenSaver event on wakeup until the passcode is validated, which we can't do, since we capture all input...
# NOTE: Dump the fb so we can restore something useful on exit...
cat /dev/fb0 > /var/tmp/koreader-fb.dump
# NOTE: We want to disable the status bar (at the very least). Unfortunately, the soft hide/unhide method doesn't work properly anymore since FW 5.6.5...
# NOTE: And, oh, joy, on FW >= 5.7.2, this is not enough to prevent the clock from refreshing, so, take the bull by the horns, and SIGSTOP the WM while we run...
# NOTE: Dump the fb so we can restore something useful on exit...
cat /dev/fb0 >/var/tmp/koreader-fb.dump
# NOTE: We want to disable the status bar (at the very least). Unfortunately, the soft hide/unhide method doesn't work properly anymore since FW 5.6.5...
# NOTE: And, oh, joy, on FW >= 5.7.2, this is not enough to prevent the clock from refreshing, so, take the bull by the horns, and SIGSTOP the WM while we run...
# Sleep a tiny bit to workaround the logic in the 'new' (K4+) eInk controllers that tries to bundle updates,
# otherwise it may drop part of our messages because of other screen updates from KUAL...
# Unless we really don't want to sleep, for special cases...
if[ ! -n "${EIPS_NO_SLEEP}"];then
usleep 150000 # 150ms
fi
# Sleep a tiny bit to workaround the logic in the 'new' (K4+) eInk controllers that tries to bundle updates,
# otherwise it may drop part of our messages because of other screen updates from KUAL...
# Unless we really don't want to sleep, for special cases...
if[ ! -n "${EIPS_NO_SLEEP}"];then
usleep 150000# 150ms
fi
# And finally, show our formatted message centered on the bottom of the screen (NOTE: Redirect to /dev/null to kill unavailable character & pixel not in range warning messages)
# And finally, show our formatted message centered on the bottom of the screen (NOTE: Redirect to /dev/null to kill unavailable character & pixel not in range warning messages)
# through fmon, 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'.
exportFROM_NICKEL="false"
if pkill -0 nickel;then
FROM_NICKEL="true"
if pkill -0 nickel;then
FROM_NICKEL="true"
fi
if["${FROM_NICKEL}"="true"];then
# Detect if we were started from KFMon
FROM_KFMON="false"
if pkill -0 kfmon ;then
# That's a start, now check if KFMon truly is our parent...
if["$(pidof kfmon)" -eq "${PPID}"];then
FROM_KFMON="true"
fi
fi
if["${FROM_KFMON}"="true"];then
# Siphon nickel's full environment, since KFMon inherits such a minimal one, and that apparently confuses the hell out of Nickel for some reason if we decide to restart it without a reboot...
for env in $(xargs -n 1 -0 <"/proc/$(pidof nickel)/environ");do
# NOTE: Not particularly critical, we should be safe leaving it up, but since we reboot on exit anyway...
# Keep KFMon up for now to make sure it's not doing anything overly stupid we might have overlooked ;).
#if [ "${FROM_KFMON}" == "true" ] ; then
# killall kfmon 2>/dev/null
#fi
if["${FROM_NICKEL}"="true"];then
# Detect if we were started from KFMon
FROM_KFMON="false"
if pkill -0 kfmon;then
# That's a start, now check if KFMon truly is our parent...
if["$(pidof kfmon)" -eq "${PPID}"];then
FROM_KFMON="true"
fi
fi
if["${FROM_KFMON}"="true"];then
# Siphon nickel's full environment, since KFMon inherits such a minimal one, and that apparently confuses the hell out of Nickel for some reason if we decide to restart it without a reboot...
for env in $(xargs -n 1 -0 <"/proc/$(pidof nickel)/environ");do
# start kobo software because it was running before koreader
./nickel.sh &
else
if grep -q 'reboot_on_exit=false' /mnt/onboard/.adds/kfmon/config/koreader.ini 2>/dev/null;then
# The user wants to try to restart Nickel instead of rebooting!
./nickel.sh &
else
# By default, if we were called from KFMon, just reboot, because there might be a chance Nickel will get its panties in a serious twist on restore for one reason or another...
# And at best, we'd still restart with slightly broken suspend behavior anyway...
/sbin/reboot
fi
fi
if["${FROM_NICKEL}"="true"];then
if["${FROM_KFMON}" !="true"];then
# start kobo software because it was running before koreader
./nickel.sh &
else
if grep -q 'reboot_on_exit=false' /mnt/onboard/.adds/kfmon/config/koreader.ini 2>/dev/null;then
# The user wants to try to restart Nickel instead of rebooting!
./nickel.sh &
else
# By default, if we were called from KFMon, just reboot, because there might be a chance Nickel will get its panties in a serious twist on restore for one reason or another...
# And at best, we'd still restart with slightly broken suspend behavior anyway...
/sbin/reboot
fi
fi
else
# if we were called from advboot then we must reboot to go to the menu
# NOTE: This is actually achieved by checking if KSM or a KSM-related script is running:
# This might lead to false-positives if you use neither KSM nor advboot to launch KOReader *without nickel running*.
if ! pgrep -f kbmenu > /dev/null 2>&1;then
/sbin/reboot
fi
# if we were called from advboot then we must reboot to go to the menu
# NOTE: This is actually achieved by checking if KSM or a KSM-related script is running:
# This might lead to false-positives if you use neither KSM nor advboot to launch KOReader *without nickel running*.
# Make sure we kill the WiFi first, because nickel apparently doesn't like it if it's up... (cf. #1520)
# NOTE: That check is possibly wrong on PLATFORM == freescale (because I don't know if the sdio_wifi_pwr module exists there), but we don't terribly care about that.
# NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag. If re-specifying -r starts to fail one day, switch to rmmod without args, or modprobe -r.
# NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag. If re-specifying -r starts to fail one day, switch to rmmod without args, or modprobe -r.
rmmod -r ${WIFI_MODULE}
rmmod -r sdio_wifi_pwr
fi
# Flush buffers to disk, who knows.
@ -46,54 +49,53 @@ sync
# NOTE: Since we're not cold booting, this is technically redundant... On the other hand, it doesn't really hurt either ;).