Quote:
Originally Posted by Aeris
What does Kindle Menu do?
- Provides a "slide to show" function, like Android: just slide your finger from the top bar to make Kindle Menu show (this features lasts "only" until you reboot the device or the framework)
|
I've made Upstart script to automatically enable magic swipe/slide after Pillow starts (at boot or on explicit restarting):
Spoiler:
Code:
start on started pillow
env DISABLE=false
script
# Wait for pillow on 'started pillow' event.
if [ "x${JOB}" == "xpillow" -a "x${UPSTART_EVENTS}" == "xstarted" ]; then
lipc-wait-event com.lab126.pillow stateChange
sleep 2
fi
# Reset DISABLE variable to false if it has a non-standard value.
if [ "x${DISABLE}" != "xtrue" ]; then
DISABLE=false
fi
# Id of Pillow container where magic swipe should be started.
SWIPE_START_PILLOW_ID=search_bar
# JavaScript executed in context of Pillow container.
# It's glued into one big line (newlines are removed), so syntax
# semicolons are required and any comments must be block comments (not line
# comments).
SCRIPT=`cat << 'JAVASCRIPT' | tr -d '\n' \
| sed \
-e 's,",\\\\",g' \
-e "s/__JUST_DISABLE__/${DISABLE}/g"
/* JavaScript code is started. */
(function () {
/* HTML element where magic swipe should be started. */
const SWIPE_START_ELEMENT = document.getElementById("menu");
/* Path to HTML file with custom dialog (without .html extension). */
const DIALOG_PATH = "/mnt/us/custom_dialog/index";
if (typeof window.__disableMagicSwipe__ === "function") {
window.__disableMagicSwipe__();
}
if (__JUST_DISABLE__) {
return;
}
if (SWIPE_START_ELEMENT === null) {
nativeBridge.logInfo(
"user-dialog",
DIALOG_PATH,
"Swipe start element is null");
return;
}
window.__disableMagicSwipe__ = function () {
SWIPE_START_ELEMENT.removeEventListener("mousedown", mouseDownHandler);
SWIPE_START_ELEMENT.removeEventListener("mouseup", mouseUpHandler);
document.body.removeEventListener("mouseout", mouseOutHandler);
delete window.__disableMagicSwipe__;
};
var swiped = false;
var mouseDownHandler = function () { swiped = true; };
var mouseUpHandler = function () { swiped = false; };
var mouseOutHandler = function () {
if (swiped) {
swiped = false;
nativeBridge.setLipcProperty(
"com.lab126.pillow",
"customDialog",
'{"name": "../../../..' + DIALOG_PATH + '"}'
);
}
};
SWIPE_START_ELEMENT.addEventListener("mousedown", mouseDownHandler);
SWIPE_START_ELEMENT.addEventListener("mouseup", mouseUpHandler);
document.body.addEventListener("mouseout", mouseOutHandler);
})();
/* JavaScript code is ended. */
`
MESSAGE='{
"pillowId": "'${SWIPE_START_PILLOW_ID}'",
"function": "'${SCRIPT}'"
}'
lipc-set-prop -s com.lab126.pillow interrogatePillow "$MESSAGE"
end script
It should be placed in
/etc/upstart under any name with
.conf extension (like
/etc/upstart/magic_swipe.conf).
I think it's safe enough. Stock scripts aren't depending on this custom job, so any accidental error shouldn't break booting process.
It could be run manually. If script is named
magic_swipe.conf, then to enable magic swipe execute
To disable it run, execute
Code:
start magic_swipe DISABLE=true
These commands are idempotent, they are always doing what you want and disabling before enabling or enabling twice in a row or something similar isn't an error.
Manual enabling of magic swipe is
required after Pillow was disabled and then enabled again via setting of special LIPC property (like KOReader startup script does when
stop_framework option isn't passed). Unfortunately, it looks like Pillow doesn't inform anybody about these state changes. I've just changed
koreader.sh:
Spoiler:
Right after
Code:
lipc-set-prop com.lab126.pillow disableEnablePillow enable
add
To set:
- path to HTML file with custom dialog, change value in line with const DIALOG_PATH =
- Pillow component and its HTML element, where magic swipe should be started, change values in lines with SWIPE_START_PILLOW_ID= and const SWIPE_START_ELEMENT =
By default, script will instantiate
/mnt/us/custom_dialog/index.html when swipe starting from Menu button in search bar will be performed.