Pocketbook: Launcher OS integration (#6620)

* Bring in restart koreader & shutdown device exit options
* Existing instance reused for opens via native book explorer
pull/6621/head
ezdiy 4 years ago committed by GitHub
parent c9a339ead0
commit 4857e97e30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,8 +29,7 @@ local PocketBook = Generic:new{
hasKeys = yes,
hasFrontlight = yes,
canSuspend = no,
hasExitOptions = no,
canRestart = no,
canPowerOff = yes,
needsScreenRefreshAfterResume = no,
home_dir = "/mnt/ext1",
@ -55,6 +54,20 @@ function PocketBook:blacklistCBB()
end
end
-- Helper to try load externally signalled book whenever we're brought to foreground
local function tryOpenBook()
local path = os.getenv("KO_PATH_OPEN_BOOK")
if not path then return end
local fi = io.open(path, "r")
if not fi then return end
local fn = fi:read("*line")
fi:close()
os.remove(path)
if fn and util.pathExists(fn) then
require("apps/reader/readerui"):showReader(fn)
end
end
function PocketBook:init()
-- Blacklist the C BB before the first BB require...
self:blacklistCBB()
@ -89,6 +102,7 @@ function PocketBook:init()
return "Suspend"
end
elseif ev.code == C.EVT_FOREGROUND or ev.code == C.EVT_SHOW then
tryOpenBook()
ui:setDirty('all', 'partial')
if quasiSuspended then
quasiSuspended = false
@ -210,6 +224,10 @@ function PocketBook:setAutoStandby(isAllowed)
inkview.iv_sleepmode(isAllowed and 1 or 0)
end
function PocketBook:powerOff()
inkview.PowerOff()
end
function PocketBook:initNetworkManager(NetworkMgr)
function NetworkMgr:turnOnWifi(complete_callback)
if inkview.NetConnect(nil) ~= C.NET_OK then

@ -4,6 +4,19 @@ export LC_ALL="en_US.UTF-8"
# working directory of koreader
KOREADER_DIR=/mnt/ext1/applications/koreader
# file through which we communicate instanced opens
export KO_PATH_OPEN_BOOK=/tmp/.koreader.open
# check for and notify a running instance
INSTANCE_PID=$(cat /tmp/koreader.pid 2> /dev/null)
if [ "${INSTANCE_PID}" != "" ] && [ -e "/proc/${INSTANCE_PID}" ]; then
echo "$@" > "${KO_PATH_OPEN_BOOK}"
exec /usr/bin/iv2sh SetActiveTask "${INSTANCE_PID}" 0
fi
# we're first, so publish our instance
echo $$ > /tmp/koreader.pid
# update to new version from OTA directory
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
@ -39,14 +52,18 @@ if [ -e crash.log ]; then
mv -f crash.log.new crash.log
fi
RETURN_VALUE=85
while [ ${RETURN_VALUE} -eq 85 ]; do
export KO_EXIT_CODE="/tmp/.koreader.exit"
RETURN_VALUE="85"
while [ "${RETURN_VALUE}" = "85" ]; do
rm -f "${KO_EXIT_CODE}"
./reader.lua "${args}" >>crash.log 2>&1
RETURN_VALUE=$?
RETURN_VALUE=$(cat ${KO_EXIT_CODE})
done
rm -f /tmp/koreader.pid
if pidof reader.lua >/dev/null 2>&1; then
killall -TERM reader.lua
fi
exit ${RETURN_VALUE}
exit "${RETURN_VALUE}"

@ -321,6 +321,14 @@ end
-- Exit
local function exitReader()
-- Exit code can be shoddy on some platforms due to broken library dtors calling _exit(0) from os.exit(N)
local ko_exit = os.getenv("KO_EXIT_CODE")
if ko_exit then
local fo = io.open(ko_exit, "w+")
fo:write(tostring(exit_code))
fo:close()
end
local ReaderActivityIndicator =
require("apps/reader/modules/readeractivityindicator")

Loading…
Cancel
Save