[screensaver] Ignore sleep screen cover conditionally#13068
Conversation
| genMenuItem(_("Show book status on sleep screen"), "screensaver_type", "bookstatus", hasLastFile), | ||
| genMenuItem(_("Leave screen as-is"), "screensaver_type", "disable", nil, true), | ||
| { | ||
| text = _("Book cover visibility rules"), |
There was a problem hiding this comment.
May be stay simple like every where else - and consistent with "Do not show this book cover...":
Do not show book cover >
Do not show book cover on finished books
Do not show book cover in file browser
(Or "Ignore" instead of "Do not show" which was my first idea when reading "Hide..." - we're not really hiding it.)
(Feels a bit excessive options, we rarely stay on a finished book or in File browser - except may be as a way to explicitely not wanting to let the device with a cover, just switching to FM before suspend.)
There was a problem hiding this comment.
the part about closing from FM is something I have wanted for a bit, since I read in different devices and usually use a different one for every new book. the other bit is taken from #11080. I'm not sure about the Ignore book cover rules though
Frenzie
left a comment
There was a problem hiding this comment.
Looks fine, I left some comments relating to the strings because I think they could be a lot shorter.
| genMenuItem(_("Show book status on sleep screen"), "screensaver_type", "bookstatus", hasLastFile), | ||
| genMenuItem(_("Leave screen as-is"), "screensaver_type", "disable", nil, true), | ||
| { | ||
| text = _("Ignore book cover rules"), |
There was a problem hiding this comment.
Maybe something like
Show book cover:
- always
- not when finished
- not in file browser
Show book cover
- always
- only when reading
- only when in document
| genMenuItem(_("Leave screen as-is"), "screensaver_type", "disable", nil, true), | ||
| { | ||
| text = _("Ignore book cover"), | ||
| help_text = _("Choose to programatically not show book covers when locking the device from the file browser or after finishing a book."), |
There was a problem hiding this comment.
Choose to programatically not show feels a bit too verbose, we have "programmatically" nowhere else, which is not surprising for a program which does it all programmatically :)
Decide to show or not book covers ... or something more straigthfoward.
There was a problem hiding this comment.
Maybe something like
Choose when to show book covers on the lock screen.
There was a problem hiding this comment.
How about this: ;)
Forsooth, by digital alchemy’s might,
Cloak book facades from prying sight;
When device locked or tale complete,
Let covers vanish, discreet and neat.
There was a problem hiding this comment.
A distinct lack of spacing. But yes, "choose to programmatically not show" must go, I was just too distracted by the regular text. :-)
There was a problem hiding this comment.
fixed, the spacing ;)
| doc_settings:makeTrue("exclude_screensaver_finished_or_on_hold") | ||
| if self.show_message then | ||
| self.show_message = false | ||
| end | ||
| else | ||
| doc_settings:makeFalse("exclude_screensaver_finished_or_on_hold") |
There was a problem hiding this comment.
What is this stored in doc_settings ?
doc_settings:isTrue("exclude_screensaver") is in it because it's a per-book decision.
Your check can just be dynamic in here, it does not need to store anything anywhere, doesn't it?
There was a problem hiding this comment.
I suppose not. but finished is also a per book decision.
| text = _("Ignore book cover"), | ||
| help_text = _("Choose when to ignore showing book covers on the sleep screen."), | ||
| enabled_func = function() | ||
| return G_reader_settings:readSetting("screensaver_type") == "cover" |
There was a problem hiding this comment.
Not familiar with all the screensaver modes, but you wrote "both the cover and sleep screen message": does the message in question only shows when screensaver_type=="cover" ? or are there some other modes which display some info about the book as a message over a black screen or random image - and does this setting apply then?
There was a problem hiding this comment.
does the message in question only shows when screensaver_type=="cover" ?
nope, but with all due respect to those who don't use the book cover. They are all, wrong ;). This PR exclusively acts on book covers, everyone else stay the same. the sleep screen message can be plastered on top of anything.
| return G_reader_settings:readSetting("screensaver_type") == "cover" | ||
| end, | ||
| checked_func = function() | ||
| return G_reader_settings:isTrue("screensaver_exclude_finished_books") or G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") |
There was a problem hiding this comment.
Missing screensaver_exclude_on_hold_books ?
There was a problem hiding this comment.
yeah, apparently in rushing to do the on hold before leaving, standards were lowered.
| local exclude_finished_books = G_reader_settings:isTrue("screensaver_exclude_finished_books") | ||
| local exclude_on_hold_books = G_reader_settings:isTrue("screensaver_exclude_on_hold_books") | ||
| local exclude_screensaver_fm = G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") | ||
| local book_summary = doc_settings:readSetting("summary") | ||
| local book_finished_or_on_hold = book_summary and (book_summary.status == "complete" or book_summary.status == "abandoned") | ||
| local exclude_screensaver_finished_or_on_hold = false | ||
| if (exclude_finished_books or exclude_on_hold_books) and book_finished_or_on_hold then | ||
| exclude_screensaver_finished_or_on_hold = true | ||
| if self.show_message then | ||
| self.show_message = false | ||
| end | ||
| end | ||
| if ui then -- ReaderUI instance | ||
| excluded = doc_settings:isTrue("exclude_screensaver") or exclude_screensaver_finished_or_on_hold | ||
| else -- FileManager instance | ||
| excluded = doc_settings:isTrue("exclude_screensaver") or exclude_screensaver_finished_or_on_hold or exclude_screensaver_fm | ||
| if self.show_message and exclude_screensaver_fm then | ||
| self.show_message = false | ||
| end |
There was a problem hiding this comment.
All this logic is tedious to read - and because of that I think there is a bug (see other comment).
You should write it simpler and more logical
excluded = doc_settings:isTrue("exclude_screensaver")
if not excluded then
if not ui and G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") then
excluded = true
else if ui then
if G_reader_settings:isTrue("screensaver_exclude_finished_books") or G_reader_settings:isTrue("screensaver_exclude_on_hold_books") then
-- do your summary cuisine and checks and set exclude = true
end
end
end
if excluded then
self.show_message = false
end| local book_finished_or_on_hold = book_summary and (book_summary.status == "complete" or book_summary.status == "abandoned") | ||
| local exclude_screensaver_finished_or_on_hold = false | ||
| if (exclude_finished_books or exclude_on_hold_books) and book_finished_or_on_hold then | ||
| exclude_screensaver_finished_or_on_hold = true |
There was a problem hiding this comment.
Looks like if I have G_reader_settings:isTrue("screensaver_exclude_on_hold_books") and the book is finished
or G_reader_settings:isTrue("screensaver_exclude_finished_books") and the book is on hold,
you will exclude that book cover.
| return G_reader_settings:isTrue("screensaver_exclude_finished_books") | ||
| or G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") | ||
| or G_reader_settings:isTrue("screensaver_exclude_on_hold_books") |
There was a problem hiding this comment.
Please re-order them so hide_cover_in_filemanager doesn't end in the middle of the other more-related 2 (put fm first, so the exclude_ ones are visually aligned).
| if not excluded then | ||
| if not ui and G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") then | ||
| excluded = true | ||
| elseif G_reader_settings:isTrue("screensaver_exclude_finished_books") and book_finished then | ||
| excluded = true | ||
| elseif G_reader_settings:isTrue("screensaver_exclude_on_hold_books") and book_on_hold then | ||
| excluded = true | ||
| end | ||
| if excluded then | ||
| self.show_message = false | ||
| end | ||
| else | ||
| -- doc_settings:isTrue("exclude_screensaver") does not get rid of the message, so honor it, when not in any of the other cases | ||
| if self.show_message then | ||
| if not ui and G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") then | ||
| self.show_message = false | ||
| elseif G_reader_settings:isTrue("screensaver_exclude_finished_books") and book_finished then | ||
| self.show_message = false | ||
| elseif G_reader_settings:isTrue("screensaver_exclude_on_hold_books") and book_on_hold then | ||
| self.show_message = false | ||
| end | ||
| end | ||
| end -- if not excluded |
There was a problem hiding this comment.
Looks like these 2 big similar branches can be merged ? (more checks even if already excluded, but it avoids duplicating the whole thing):
local book_on_hold = book_summary and book_summary.status == "abandoned"
if not ui and G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") then
excluded = true
elseif G_reader_settings:isTrue("screensaver_exclude_finished_books") and book_finished then
excluded = true
elseif G_reader_settings:isTrue("screensaver_exclude_on_hold_books") and book_on_hold then
excluded = true
end
if excluded then
self.show_message = false
end| local exclude_finished_books = G_reader_settings:isTrue("screensaver_exclude_finished_books") and book_finished | ||
| local exclude_on_hold_books = G_reader_settings:isTrue("screensaver_exclude_on_hold_books") and book_on_hold | ||
| local exclude_books_in_fm = not ui and G_reader_settings:isTrue("screensaver_hide_cover_in_filemanager") | ||
|
|
||
| if not excluded then |
There was a problem hiding this comment.
These local variables are badly named:
exclude_finished_books = G_reader_settings:isTrue("screensaver_exclude_finished_books") and book_finished
The G_reader_setting things is plural, but and book_finished have it apply on the current book, so the local var can't be plural.
The blank line is not needed, as the whole section is about the same thing.
And I'm sure you can do shorter than adding 20 lines and you don't need that many branches.
| if not excluded and should_exclude_book then | ||
| excluded = true | ||
| self.show_message = false | ||
| elseif self.show_message and excluded and should_exclude_book then | ||
| -- doc_settings:isTrue("exclude_screensaver") does not get rid of the message, check if we should hide it, otherwise we honor it | ||
| self.show_message = false |
There was a problem hiding this comment.
Good for what's above that.
For these 2 branches, it looks to me they are just logically equivalent to one and clearer:
if should_exclude_book then
excluded = true
self.show_message = false -- get rid of the message
endThere was a problem hiding this comment.
I know - but it warms the heart to hear it. I hate you too :)

what's new
This pull request introduces a new feature to allow users to hide sleep screen covers conditionally
frontend/ui/elements/screensaver_menu.lua: Added a new menu item "Ignore book cover" with sub-options to exclude book covers from the screensaver under specific conditions, such as for books on hold, finished books, and when in the file browser.frontend/ui/screensaver.lua: Modified theScreensaver:setupfunction to check new settings for excluding book covers from the screensaver based on the book's status (finished or on hold) and the current UI context (file browser).screenshots
hide cover off / hide cover on
This change is