-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin manager #4159
Plugin manager #4159
Conversation
"Kobo light"? is that for the warmth controls that some of the new Kobo devices have? The "Comfort lighting"? Some might think they can use their reader as a "flashlight" like with a Smartphone or that you can disable the regular front light, this way. This could be a good place for some inline manual function descriptions, for the plugins. |
@KenMaltby: Right. Should be: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of a silly comment perhaps, but shouldn't that be full_name
?
frontend/pluginloader.lua
Outdated
local lfs = require("libs/libkoreader-lfs") | ||
local logger = require("logger") | ||
local _ = require("gettext") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because it's a low-level module which didn't previously require()
much (lfs & logger only), and you don't know at which point it may be imported (well, it's used late, but still), it'd be safer to move the require()
s for UIManager, InfoMessage and _ in the single callback where they are used. (So that when something require("pluginloader"), it doesn't go yet importing UIManager & the widget stuff.)
frontend/pluginloader.lua
Outdated
sandboxPluginEventHandlers(plugin_module) | ||
table.insert(self.plugins, plugin_module) | ||
if (plugins_disabled and plugins_disabled[entry:sub(1, -10)]) then | ||
sandboxPluginEventHandlers(plugin_module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need this sandboxPluginEventHandlers()
for disabled plugins (?)
frontend/pluginloader.lua
Outdated
element.fullname = plugin.fullname or plugin.name | ||
element.name = plugin.name | ||
element.enable = false | ||
if element.name ~= "storagestat" then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we could put "storagestat" in a module local
local PLUGINS_OBSOLETE = {
"storagestat"=true,
}
so it's no more harcoded there and above (where you added it 1 or 2 weeks ago).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another module or where to put PLUGINS_OBSOLETE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this module, just under local DEFAULT_PLUGIN_PATH = "plugins"
.
local DEFAULT_PLUGIN_PATH = "plugins"
local OBSOLETE_PLUGINS = {
"storagestat" = true,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
frontend/pluginloader.lua
Outdated
callback = function() | ||
local plugins_disabled = G_reader_settings:readSetting("plugins_disabled") or {} | ||
plugins_disabled[plugin.name] = plugin.enable | ||
plugin.enable = not plugin.enable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an unclear shortcut :) to store the former value before the not
, because we want true
in the settings when it's becoming false
.
But we don't want false
in the settings when it's becoming true
, we'd prefer nil
, so it's not stored in the setting and we only have the list of disabled plugins in it (with all =true
)
So, you may do that after the not
, with a clearer if plugin.enable then store nil (=erase) else store true end
Indeed, plugins could all have a (I'm still not sure what zsync, kosync, evernote and calibrecompanion do :) |
kosync is some kind of progress sync, zsync some kind of local filesharing I believe, Evernote is some kind of notes sync and calibre companion does whatever calibre companion does, but I forget what that is. |
Evernote and Calibre Companion function with or in a related manner to the commercial software, with the same names. Zsync lets you "publish" the book you are reading and then be able to "subscribe to" it on other devices running KOReader. |
Can you give me short description for all plugins. Please :)
|
frontend/pluginloader.lua
Outdated
else | ||
plugins_disabled[plugin.name] = nil | ||
end | ||
plugin.enable = not plugin.enable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still like to see it done after the plugin.enable = not plugin.enable
, so it uses the new value instead of the old one:
plugin.enable = not plugin.enable
if plugin.enable then
plugins_disabled[plugin.name] = nil
else
plugins_disabled[plugin.name] = true
end
Here are the first few. Off to feed the cats.
Automatically turns the frontlight on and off once brightness in the environment reaches a certain level. Only supported on Kindle (?).
Collects and displays battery statistics.
Exports hightlights and notes to the Evernote cloud.
Keeps the device awake to prevent automatic Wi-Fi disconnects.
A basic text editor for making small changes to plain text files. |
Something like this: Perhaps replacing the URL with the link under "related WiKi" If we had a local html copy of the WiKi on our device, it would be the preferred linked source. |
Retrieves RSS and Atom news entries and saves them as HTML files.
Obsolete :)
Suspends the device when no interaction for some time.
Controls the fronlight with gestures on the left border of screen.
Improves your reading speed with the help of two vertical lines over the text.
Allows connecting and transfering files to the device over SSH.
Shows system statistics.
Synchronizes the device time with NTP servers.
Service to other widgets: allows tasks to be run regularly in the background.
Alternative display modes for file browser and history.
How are you?
Synchronizes your reading progess to a server and across your devices.
Shows an alarm after a specified amount of time.
Keeps and displays your reading statistics.
Executes simple commands and shows their output.
Receives articles sent with the Send2Ebook PC/Android application.
Keep company to calibre :)
Allows browsing and searching Goodreads database of books: shows cover, description... (well, you know what it does better than me :) |
Thanks for descriptions :) |
@@ -240,6 +240,7 @@ BackgroundRunner:_schedule() | |||
local BackgroundRunnerWidget = WidgetContainer:new{ | |||
name = "backgroundrunner", | |||
fullname = _("Background runner"), | |||
description = _([[Service to other widgets: allows tasks to be run regularly in the background.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups, I meant: Service to other plugins. Sorry.
plugins/SSH.koplugin/main.lua
Outdated
@@ -20,6 +20,8 @@ end | |||
|
|||
local SSH = WidgetContainer:new{ | |||
name = 'SSH', | |||
fullname = _("SSH"), | |||
description = _([[Allows connecting and transfering files to the device over SSH.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd be transferring, but I'll suggest the plainer
Connect and transfer files to the device using SSH.
name = "AutoSuspend", | ||
name = "autosuspend", | ||
fullname = _("Auto suspend"), | ||
description = _([[Suspends the device when no interaction for some time.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suspends the device after a period of inactivity?
(Merely grammatically speaking, suspends the device when no interaction has occurred for some time.)
@@ -238,6 +239,8 @@ BackgroundRunner:_schedule() | |||
|
|||
local BackgroundRunnerWidget = WidgetContainer:new{ | |||
name = "backgroundrunner", | |||
fullname = _("Background runner"), | |||
description = _([[Service to other plugins: allows tasks to be run regularly in the background.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Service to other plugins: allows tasks to run regularly in the background.
@@ -23,6 +23,8 @@ require("ffi/zeromq_h") | |||
--]] | |||
local CalibreCompanion = InputContainer:new{ | |||
name = "calibrecompanion", | |||
fullname = _("Calibre companion"), | |||
description = _([[Send documents from Calibre library directly to device via Wifi connection]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calibre (lowercase c)
Wi-Fi (I vote wifi but at some point we decided on Wi-Fi)
plugins/goodreads.koplugin/main.lua
Outdated
@@ -9,6 +9,9 @@ local _ = require("gettext") | |||
local NetworkMgr = require("ui/network/manager") | |||
|
|||
local Goodreads = InputContainer:new { | |||
name = "goodreads", | |||
fullname = _("Goodreads"), | |||
description = _([[Allows browsing and searching Goodreads database of books.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Goodreads database of books
plugins/hello.koplugin/main.lua
Outdated
name = 'Hello', | ||
name = 'hello', | ||
fullname = _("Hello"), | ||
description = _([[This is debug plugin]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a debugging plugin.
plugins/kobolight.koplugin/main.lua
Outdated
@@ -22,6 +22,8 @@ local swipe_touch_zone_ratio_warmth = { x = 7/8, y = 1/8, w = 1/8, h = 7/8, } | |||
|
|||
local KoboLight = WidgetContainer:new{ | |||
name = 'kobolight', | |||
fullname = _("Frontlight gesture controller"), | |||
description = _([[Controls the fronlight with gestures on the left border of screen.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frontlight
plugins/kosync.koplugin/main.lua
Outdated
@@ -20,6 +20,8 @@ end | |||
|
|||
local KOSync = InputContainer:new{ | |||
name = "kosync", | |||
fullname = _("Progress sync"), | |||
description = _([[Synchronizes your reading progess to a server and across your devices.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
across your KOReader devices?
@@ -19,6 +19,8 @@ local NetworkMgr = require("ui/network/manager") | |||
|
|||
local TimeSync = WidgetContainer:new{ | |||
name = "timesync", | |||
fullname = _("Time sync"), | |||
description = _([[Synchronizes the device time with NTP servers.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synchronizes the device with with NTP servers to within a few milliseconds of UTC?
I don't know, that might still sound a bit mystical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synchronizes the time between the device and the time on the Internet. ?
plugins/zsync.koplugin/main.lua
Outdated
@@ -15,6 +15,8 @@ int rmdir(const char *); | |||
require("ffi/zeromq_h") | |||
local ZSync = InputContainer:new{ | |||
name = "zsync", | |||
fullname = _("Zsync"), | |||
description = _([[Devices in the same Wifi network can transfer documents between each other directly.]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wi-Fi
"backgroundrunner" seems to me more a meta-plugin than a plugin. Is it wise to to allow it's deactivation ? |
It's used only by the AutoFrontLight plugin on Kindle Voyage and Oasis, and by the newer Kobo with warmth light (KoboPowerD:calculateAutoWarmth). So, I guess these auto front light will just not work if one disables this plugin. But that's the purpose of disabling plugins :) I rambled on BackgroundRunner in #3078 (comment) and #3608 (comment) |
Sounds like something I would want to turn off. If I don't need it, having it do anything every 2 seconds is something I would like to prevent. |
Mhhhh, there's something wrong with this PR. koreader/frontend/pluginloader.lua Lines 65 to 66 in 0732379
to after this block, you are actually loading the plugin: koreader/frontend/pluginloader.lua Lines 71 to 75 in d865bf8
(You needed that to get its name and description.) For example, background runner now runs its stuff even if disabled, because it does schedule itself in the body of the module, and not in a function: koreader/plugins/backgroundrunner.koplugin/main.lua Lines 238 to 245 in d865bf8
I really don't see how to easily fix that... |
Split it up into a main.lua and a metadata.lua or something along those lines? |
Yep, that could work ( |
To me it sounds like something that should be autoloaded and switched on as de dependency. If nothing depends on it it should switch off automatically. |
Or perhaps device dependent? |
Reference: #2544 and #4054
![test - koreader_015](https://user-images.githubusercontent.com/22982594/44087612-ad3fcd00-9fc0-11e8-88f8-745fdcc1d067.png)
![test - koreader_016](https://user-images.githubusercontent.com/22982594/44087613-ad731c78-9fc0-11e8-8747-b43d89449e9b.png)
This PR gives you the option of enabling/disabling any plugin via the GUI. This is a continuation of the work @poire-z in #4054.
Screenshots: