View Single Post
Old 01-15-2017, 03:00 PM   #366
tshering
Wizard
tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.
 
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
emergency power off if KOReader exits spontaneously

The information in this post is obsolete. See this post.


Spoiler:
I want to share an idea that might never make it into an updated version of KSM. Imagine you are running KOReader and leave the device alone for a long time, trusting that KOReader's automatic suspend function will kick in (or maybe you manually suspend the reader), but for some reason there occurs a problem and KOReader exits and gives control back to KSM. Since KSM does not have an auto suspend function, the device will stay awake until you return, or until the battery will be flat.

To prevent this from happening we try to do the following. 1) We modify KOReader so that it informs KSM whether the user made KOReader exit. 2) We modify KSM to display a message if KOReader exists without being explicitly asked by the user to do so; and to power the device down, if there is no user input for 20 seconds or so.

1.1) Modification of KOReader: modify .adds\koreader\frontend\apps\filemanager\filemanag ermenu.lua; code to insert is marked in red.
Spoiler:
Code:
        home = {
            icon = "resources/icons/appbar.home.png",
            callback = function()
                local file = io.open("/tmp/koreader_exit_message","w")
                if file then
                  file:write("userexit")
                  file:close()
                end
                if SetDefaults.settings_changed then
                    SetDefaults.settings_changed = false
                    UIManager:show(ConfirmBox:new{
                        text = _("You have unsaved default settings. Save them now?"),
                        ok_callback = function()
                            SetDefaults:saveSettings()
                        end,
                    })
                else
                    UIManager:close(self.menu_container)
                    self.ui:onClose()
                end
            end,
        },


1.2) Modification of KOReader: modify .adds\koreader\frontend\apps\reader\modules\reader menu.lua; code to insert is marked in red.
Spoiler:
Code:
        home = {
            icon = "resources/icons/appbar.home.png",
            remember = false,
            callback = function()
                local file = io.open("/tmp/koreader_exit_message","w")
                if file then
                  file:write("userexit")
                  file:close()
                end
                self:onTapCloseMenu()


If KOReader exits spontaneously, you will find a log file /log/koreader_exit_log.txt. Use "explore" to navigate there and read the file.


You can test the function by launching KOReader with the new script, and then kill it by telnet:
Code:
[root@(none) ~]# killall reader.lua
I removed the archives here, since they are not needed if you install the patch for Auro One and Auro Edition 2 (which is compatible with all devices):

Last edited by tshering; 02-12-2017 at 04:39 PM.
tshering is offline   Reply With Quote