2017-12-17 17:27:24 +00:00
|
|
|
local Screensaver = require("ui/screensaver")
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
|
|
local function screensaverType() return G_reader_settings:readSetting("screensaver_type") end
|
|
|
|
local function screensaverDelay() return G_reader_settings:readSetting("screensaver_delay") end
|
|
|
|
local function lastFile()
|
|
|
|
local lfs = require("libs/libkoreader-lfs")
|
|
|
|
local last_file = G_reader_settings:readSetting("lastfile")
|
|
|
|
if last_file and lfs.attributes(last_file, "mode") == "file" then
|
|
|
|
return last_file
|
|
|
|
end
|
|
|
|
end
|
2018-01-21 18:44:12 +00:00
|
|
|
local function whiteBackground() return G_reader_settings:isTrue("screensaver_white_background") end
|
2019-03-14 19:58:45 +00:00
|
|
|
local function noBackground() return G_reader_settings:isTrue("screensaver_no_background") end
|
2018-01-21 18:44:12 +00:00
|
|
|
local function stretchImages() return G_reader_settings:isTrue("screensaver_stretch_images") end
|
2020-02-22 08:07:28 +00:00
|
|
|
local function messagePosition() return G_reader_settings:readSetting("screensaver_message_position") end
|
2020-06-06 17:23:16 +00:00
|
|
|
local function showMessage() return G_reader_settings:isTrue("screensaver_show_message") end
|
2017-12-17 17:27:24 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
{
|
|
|
|
text = _("Use last book's cover as screensaver"),
|
|
|
|
enabled_func = function() return lastFile() ~= nil end,
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverType() == "cover" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "cover")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Use book status as screensaver"),
|
|
|
|
enabled_func = function() return lastFile() ~= nil end,
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverType() == "bookstatus" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "bookstatus")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Use random image from folder as screensaver"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverType() == "random_image" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "random_image")
|
|
|
|
end
|
|
|
|
},
|
2019-09-16 13:27:49 +00:00
|
|
|
{
|
|
|
|
text = _("Use document cover as screensaver"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverType() == "document_cover" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "document_cover")
|
|
|
|
end
|
|
|
|
},
|
2018-07-23 08:37:24 +00:00
|
|
|
{
|
|
|
|
text = _("Use image as screensaver"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverType() == "image_file" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "image_file")
|
|
|
|
end
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
|
|
|
text = _("Use reading progress as screensaver"),
|
|
|
|
enabled_func = function() return Screensaver.getReaderProgress ~= nil and lastFile() ~= nil end,
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverType() == "readingprogress" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "readingprogress")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Leave screen as it is"),
|
|
|
|
checked_func = function()
|
Screensaver: change default & show messages on reboot and poweroff (#3572)
Use "message" as the default for screensaver (instead of "disable") (https://github.com/koreader/koreader/pull/3535#issuecomment-353337143)
On Kobo
Fix: display message on poweroff or reboot (https://github.com/koreader/koreader/pull/3535#issuecomment-352355865)
Allows for overwritting these default messages with the classic screensaver settings, by just prepending "poweroff_" or "reboot_" to them. (https://github.com/koreader/koreader/pull/3535#issuecomment-352498497)
So one can manually add to its settings.reader.lua:
```
"poweroff_screensaver_type" = "random_image" or "message", "cover", "bookstatus", "readingprogress", "disable",
"poweroff_screensaver_dir" = "path to same as screensaver_dir or alternate dir for poweroff image(s)",
"poweroff_screensaver_message" = "message to use instead of Powered off",
```
```
"reboot_screensaver_type" = "random_image" or "message", "cover", "bookstatus", "readingprogress", "disable",
"reboot_screensaver_dir" = "path to same as screensaver_dir or alternate dir for reboot image(s)",
"reboot_screensaver_message" = "message to use instead of Rebooting...",
```
2018-01-06 12:21:26 +00:00
|
|
|
if screensaverType() == "disable" then
|
2017-12-17 17:27:24 +00:00
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_type", "disable")
|
2020-06-06 17:23:16 +00:00
|
|
|
end,
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Add message to screensaver"),
|
|
|
|
checked_func = showMessage,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_show_message", not showMessage())
|
|
|
|
end,
|
|
|
|
separator = true,
|
2017-12-17 17:27:24 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Settings"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Screensaver folder"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2017-12-17 17:27:24 +00:00
|
|
|
callback = function()
|
|
|
|
Screensaver:chooseFolder()
|
|
|
|
end,
|
|
|
|
},
|
2018-07-23 08:37:24 +00:00
|
|
|
{
|
|
|
|
text = _("Screensaver image"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2018-07-23 08:37:24 +00:00
|
|
|
callback = function()
|
|
|
|
Screensaver:chooseFile()
|
|
|
|
end,
|
|
|
|
},
|
2019-09-16 13:27:49 +00:00
|
|
|
{
|
|
|
|
text = _("Document cover"),
|
|
|
|
keep_menu_open = true,
|
|
|
|
callback = function()
|
|
|
|
Screensaver:chooseFile(true)
|
|
|
|
end,
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
|
|
|
text = _("Screensaver message"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2017-12-17 17:27:24 +00:00
|
|
|
callback = function()
|
|
|
|
Screensaver:setMessage()
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
2018-01-21 18:44:12 +00:00
|
|
|
text = _("White background behind message and images"),
|
|
|
|
checked_func = whiteBackground,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_white_background", not whiteBackground())
|
2019-03-14 19:58:45 +00:00
|
|
|
G_reader_settings:flipFalse("screensaver_no_background")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Leave background as-is behind message and images"),
|
|
|
|
checked_func = noBackground,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_no_background", not noBackground())
|
|
|
|
G_reader_settings:flipFalse("screensaver_white_background")
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
2018-01-21 18:44:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Stretch covers and images to fit screen"),
|
|
|
|
checked_func = stretchImages,
|
2017-12-17 17:27:24 +00:00
|
|
|
callback = function()
|
2018-01-21 18:44:12 +00:00
|
|
|
G_reader_settings:saveSetting("screensaver_stretch_images", not stretchImages())
|
2017-12-17 17:27:24 +00:00
|
|
|
end,
|
|
|
|
separator = true,
|
|
|
|
},
|
2020-02-22 08:07:28 +00:00
|
|
|
{
|
|
|
|
text = _("Screensaver message position"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Top"),
|
|
|
|
checked_func = function()
|
|
|
|
return messagePosition() == "top"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_message_position", "top")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Middle"),
|
|
|
|
checked_func = function()
|
|
|
|
return messagePosition() == "middle" or messagePosition() == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_message_position", "middle")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Bottom"),
|
|
|
|
checked_func = function()
|
|
|
|
return messagePosition() == "bottom"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_message_position", "bottom")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2017-12-17 17:27:24 +00:00
|
|
|
{
|
|
|
|
text = _("Delay when exit from screensaver"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Disable"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverDelay() == nil or screensaverDelay() == "disable" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "disable")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("1 second"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverDelay() == "1" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "1")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("3 seconds"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverDelay() == "3" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "3")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("5 seconds"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverDelay() == "5" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "5")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Tap to exit screensaver"),
|
|
|
|
checked_func = function()
|
|
|
|
if screensaverDelay() == "tap" then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("screensaver_delay", "tap")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|