From db4a30ff07eb13f7d3ec2b387cb7b8385aa7940c Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 5 Jul 2014 15:05:03 +0200 Subject: [PATCH] Add an 'ASAP' variant to the KOReader KUAL menu. Does away with the added ~3s of sleep, in exchange of possible UI quirks at startup. --- kindle/extensions/koreader/menu.json | 12 +++++++ kindle/koreader.sh | 49 +++++++++++++++++----------- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/kindle/extensions/koreader/menu.json b/kindle/extensions/koreader/menu.json index e747f5462..a0e7d23e0 100644 --- a/kindle/extensions/koreader/menu.json +++ b/kindle/extensions/koreader/menu.json @@ -26,6 +26,18 @@ "priority": 4, "action": "/mnt/us/koreader/koreader.sh", "params": "--framework_stop" + }, + { + "name": "Start the filemanager (ASAP)", + "priority": 5, + "action": "/mnt/us/koreader/koreader.sh", + "params": "--asap /mnt/us/documents" + }, + { + "name": "Open the last document (ASAP)", + "priority": 6, + "action": "/mnt/us/koreader/koreader.sh", + "params": "--asap" } ] } diff --git a/kindle/koreader.sh b/kindle/koreader.sh index 8eb750311..0ca4e06fb 100755 --- a/kindle/koreader.sh +++ b/kindle/koreader.sh @@ -37,27 +37,36 @@ PILLOW_DISABLED="no" # Keep track of if we were started through KUAL FROM_KUAL="no" +# By default, don't stop the framework. +if [ "$1" == "--framework_stop" ] ; then + shift 1 + STOP_FRAMEWORK="yes" + NO_SLEEP="no" +elif [ "$1" == "--asap" ] ; then + # Start as soon as possible, without sleeping to workaround UI quirks + shift 1 + NO_SLEEP="yes" + STOP_FRAMEWORK="no" +else + STOP_FRAMEWORK="no" + NO_SLEEP="no" +fi + # Detect if we were started by KUAL by checking our nice value... if [ "$(nice)" == "5" ] ; then FROM_KUAL="yes" - # Yield a bit to let stuff stop properly... - logmsg "Hush now . . ." - # NOTE: This may or may not be terribly useful... - usleep 250000 + if [ "${NO_SLEEP}" == "no" ] ; then + # Yield a bit to let stuff stop properly... + logmsg "Hush now . . ." + # NOTE: This may or may not be terribly useful... + usleep 250000 + fi # Kindlet threads spawn with a nice value of 5, we aim for the same -2 as the KF8 reader logmsg "Be nice!" renice -n -7 $$ fi -# By default, don't stop the framework. -if [ "$1" == "--framework_stop" ] ; then - shift 1 - STOP_FRAMEWORK="yes" -else - STOP_FRAMEWORK="no" -fi - # we're always starting from our working directory cd /mnt/us/koreader @@ -124,13 +133,15 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then # NOTE: One more great find from eureka (http://www.mobileread.com/forums/showpost.php?p=2454141&postcount=34) lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.hideMe();"}' PILLOW_DISABLED="yes" - # NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing the title bar - usleep 250000 - # NOTE: If we were started from KUAL, we risk getting a list item to popup right over us, so, wait some more... - # The culprit appears to be a I WindowManager:flashTimeoutExpired:window=Root 0 0 600x30 - if [ "${FROM_KUAL}" == "yes" ] ; then - logmsg "Playing possum to wait for the window manager . . ." - usleep 2500000 + if [ "${NO_SLEEP}" == "no" ] ; then + # NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing the title bar + usleep 250000 + # NOTE: If we were started from KUAL, we risk getting a list item to popup right over us, so, wait some more... + # The culprit appears to be a I WindowManager:flashTimeoutExpired:window=Root 0 0 600x30 + if [ "${FROM_KUAL}" == "yes" ] ; then + logmsg "Playing possum to wait for the window manager . . ." + usleep 2500000 + fi fi fi fi