Skip to content

[screensaver] Add option to cycle through folder images#13094

Merged
Frenzie merged 21 commits into
koreader:masterfrom
Commodore64user:alpha-order
Jan 21, 2025
Merged

[screensaver] Add option to cycle through folder images#13094
Frenzie merged 21 commits into
koreader:masterfrom
Commodore64user:alpha-order

Conversation

@Commodore64user
Copy link
Copy Markdown
Member

@Commodore64user Commodore64user commented Jan 18, 2025

what's new

  • frontend/ui/elements/screensaver_menu.lua: Added a new menu item to toggle the display of images in alphabetical order.

  • frontend/ui/screensaver.lua: Modified the _getRandomImage function to support the new alphabetical order option by sorting files and cycling through them. Wasn't sure whether to create a brand new one or just adapt this one, alas the latter was chosen.

screenshots


This change is Reviewable

Comment thread frontend/apps/filemanager/filemanagerutil.lua Outdated
Comment thread frontend/ui/screensaver.lua Outdated
if G_reader_settings:isTrue("screensaver_cycle_images_alphabetically") then
local files = filemanagerutil.getFiles(dir, match_func)
if not files then return end
table.sort(files) -- Sort files alphabetically (numbers go: 1, 10, 11, 2, 20, 21, ...)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose a user expects natural sorting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair assessment, will make it so

Comment thread frontend/ui/screensaver.lua Outdated
@mergen3107
Copy link
Copy Markdown
Contributor

Thank you!!

@Commodore64user
Copy link
Copy Markdown
Member Author

You might also like #13068 @mergen3107

@mergen3107
Copy link
Copy Markdown
Contributor

Maybe, but I don't like book covers as screensavers in general :D

@Commodore64user
Copy link
Copy Markdown
Member Author

Well you are obviously wrong ;)

Comment thread frontend/ui/screensaver.lua Outdated
index = 1
end
local file = files[index]
index = (index % #files) + 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be just index = index + 1 after line 103, and saving default 0 in line 103.
I.e. saving the last shown image index instead of the next image index.

@hius07
Copy link
Copy Markdown
Member

hius07 commented Jan 18, 2025

genMenuItem(_("Show random image from folder on sleep screen"), "screensaver_type", "random_image"),

So, if the new option enabled, it's not a random image anymore.

genMenuItem(_("Show custom image or cover on sleep screen"), "screensaver_type", "document_cover"),
genMenuItem(_("Show random image from folder on sleep screen"), "screensaver_type", "random_image"),
genMenuItem(G_reader_settings:isTrue("screensaver_cycle_images_alphabetically") and _("Show cycled images from folder on sleep screen")
or _("Show random image from folder on sleep screen"), "screensaver_type", "random_image"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a generic wording, not changeable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't work anyway... i am actually okay with original but we'll see what others say

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What doesn't work? Say about what?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that "G-sett and or" didn't work, anyway hius thinks we should change the string because it might not be a random image anymore, i am not bothered by it.

Comment thread frontend/ui/screensaver.lua Outdated
return filemanagerutil.getRandomFile(dir, match_func)
-- If the user has set the option to cycle images alphabetically, we sort the files instead of picking a random one.
if G_reader_settings:isTrue("screensaver_cycle_images_alphabetically") then
local start_time = os.clock()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overengineering, not needed.

Copy link
Copy Markdown
Member Author

@Commodore64user Commodore64user Jan 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i disagree this time, i am confident that someone is going to put 3000 images into a folder (with crazy names like dfhkoemd457628.png) and then complain about how slow it is to lock the screen.

edit: i briefly considered the idea of capping the number of files we would cycle through, but who am i to say 100 images (or whatever) is enough?

edit 2: if we capped it at 128 images we could always lie about being some sort of algorithm limitation ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but who am i to say 100 images (or whatever) is enough?

And who are you to say 0.5 seconds is too much ?
A shorter logger.info always showing will be fine for the rare people using this feature.
logger.info("Screensaver: finding and sorting", #files, "files took ", time.to_s(time.since(start_time)), " seconds")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estimated Performance on Kindle Devices

sorting 128 files with random and complex names, using our sort function,( according to AI)

Kindle 3 (532 MHz CPU):

Worst-case estimate: 0.5 to 1 second for sorting 128 files
The lower clock speed will significantly impact the performance of complex string operations.

Kindle 4 (800 MHz CPU):

Worst-case estimate: 0.3 to 0.6 seconds for sorting 128 files
The higher clock speed will help, but the complex string operations will still be relatively slow.

Kindle Voyage (Single-core 1 GHz processor):

Estimated worst-case time: 0.3 to 0.5 seconds

Kindle Paperwhite 5 (Quad-core 1 GHz processor):

Estimated worst-case time: 0.1 to 0.2 seconds

These estimates are significantly higher than the previous ones due to:

The complexity of the conversion function
Extensive use of pattern matching and string manipulation
Potential memory constraints affecting cache performance

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd tell the AI there's a chance I/O is more significant than CPU (at least on the newer devices).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not talking about the performance, just about you deciding to logger.warn() or not at all at a threashold of 0.5s.
Let the user know with a logger.info about how it takes for how many books, so he can... think about that early.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, i was composing that message before i had even read your 0.5s challenge... my question and the point of asking AI that is, should we in some way intervene in potential terrible decision making by users?

regarding the 0.5 sec, it was taken out of a hat and it was also what i deemed reasonable to wait, alas we can just simply use logger.info indeed.

using I/O all the calculations jump to seconds (as in 1 sec +)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do a lot of searching here and there and do not measure.
FileChooser shows folders with hundreds of files, sorts them, and we do not measure and do not warn.
Useless overengineering.

Comment thread frontend/ui/screensaver.lua Outdated
Comment on lines +104 to +107
local elapsed_time = os.clock() - start_time
if elapsed_time > 0.5 then -- threshold in seconds
logger.warn("Screensaver: finding and sorting", #files, "files alphabetically took ", elapsed_time, " seconds")
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use os.clock(), we made every time thingy consistent to use our time.lua module.
So, here, you should do as in:

start_time = time.now()
self.document:render()
logger.dbg(string.format(" rendering took %.3f seconds", time.to_s(time.since(start_time))))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am crashing with time.now

./luajit: frontend/device/kindle/device.lua:650: loop or previous error loading module 'ui/screensaver'
stack traceback:
	[C]: in function 'require'
	frontend/device/kindle/device.lua:650: in function 'intoScreenSaver'
	frontend/device/kindle/device.lua:766: in function 'handler'
	frontend/ui/uimanager.lua:1421: in function 'handleInputEvent'
	frontend/ui/uimanager.lua:1523: in function 'handleInput'
	frontend/ui/uimanager.lua:1567: in function 'run'
	./reader.lua:280: in main chunk
	[C]: at 0x00013e81
lipc-wait-event exited normally with status: 0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, i had an incorrect path for time

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO  Screensaver: finding and sorting 23 files took  0.034673  seconds 
INFO  Screensaver: finding and sorting 23 files took  0.03208  seconds 

@Commodore64user
Copy link
Copy Markdown
Member Author

Commodore64user commented Jan 19, 2025

Do we show a checkered sleep screen image under any circumstances? When trying to implement how to limit the number of files, the first thing i thought was to run a loop that would stop at 128 (that didn't work) but what it did do, was show a checkered sleep screen, not the fallback K. And no, i don't have a checkered image on that folder.

Comment thread frontend/ui/screensaver.lua Outdated
end, false)
if #files == 0 then return end
-- Slippery slope detected! Ensure the number of files does not exceed 128 to prevent performance issues.
if #files > 128 then -- this seems like a reasonable [arbitrary] limit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to bench you should do the two parts separately.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean fetching and sorting?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you don't measure you don't know what it is that's actually taking time.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sorting, that is what takes 90% of the time. I am not too concerned about the fetching really, is the sorting i am more worried about. Would you really want them separately? I don’t mind having them combined but if you insist...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well no, but in the future please try to lead with "I measured it and it only took 10% of the time". ;-)

Comment thread frontend/ui/screensaver.lua Outdated
files = {table.unpack(files, 1, 128)}
end
-- we have files, sort them in natural order, i.e z2 < z11 < z20
local sort = require("frontend/sort")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local sort = require("frontend/sort")
local sort = require("sort")

See bb93c44

Comment thread frontend/ui/screensaver.lua Outdated
-- Slippery slope detected! Ensure the number of files does not exceed 128 to prevent performance issues.
if #files > 128 then -- this seems like a reasonable [arbitrary] limit
logger.warn("Screensaver: found", #files, "files, dropping", #files - 128)
files = {table.unpack(files, 1, 128)}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is necessary, but presumably it'd be a lot faster to skip insertion in the first place.

        local files = {}
        local num_files = 0
        util.findFiles(dir, function(file)
            if num_files > 512 then return end
            table.insert(files, file)
            num_files += 1
        end, false)

Copy link
Copy Markdown
Member Author

@Commodore64user Commodore64user Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don’t think findFiles likes the returns. i.e you will get the checkered screen of death. i.e v2 it won’t work

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the problem is that += 1 isn't Lua, for which apologies but only half. It's pseudocode to communicate an idea, not something to copy paste and expect it to work out of the box.

Copy link
Copy Markdown
Member Author

@Commodore64user Commodore64user Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not what i meant, i tried something like that last night with num = num + 1 and it would not work. Checkered screen of death.

Edit: i am going to look like an absolute "genius" if when i get home, try your suggestion and it works, even though i know it won't

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will definitely work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's what i was trying last night when i got the checkered screen of death, but see edit above.

Copy link
Copy Markdown
Member Author

@Commodore64user Commodore64user Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

congratulation!!! you were right. not sure what it was that I was doing differently but I am happy it works though.

so yeah lets just politely assume that this conversation never took place.

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Jan 19, 2025

Do we show a checkered sleep screen image under any circumstances?

I don't believe so.

@Frenzie Frenzie added this to the 2025.01 milestone Jan 19, 2025
@Commodore64user
Copy link
Copy Markdown
Member Author

Commodore64user commented Jan 19, 2025

for documentation purposes: here are the results on a K4

01/19/25-23:22:24 INFO  Screensaver: found and sorted 128 files in 0.274828 seconds 
logs
01/19/25-23:22:24 INFO  Screensaver: found {
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-5.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-6.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-7.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-8.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-9.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-10.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-11.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-13.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-14.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-15.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-16.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-17.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-18.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-19.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-20.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-21.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-22.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-23.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-101.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-12.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-2.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-3.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-4.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-102.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-103.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-104.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-105.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-106.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-107.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-108.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-109.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-110.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-111.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-112.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-113.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-114.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-115.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-116.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-117.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-118.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-119.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-120.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-121.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-122.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-123.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1001.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1002.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1003.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1004.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1005.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1006.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1007.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1008.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1009.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1010.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1011.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1012.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1013.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1014.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1015.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1016.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1017.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1018.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1019.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1020.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1021.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1022.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1023.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1004SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1006SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1008SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1010SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1012SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1014SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1016SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1018SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1020SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1022SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HereSleepScreen-1.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-103heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-104heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-106SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-107SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-109SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-110SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-112SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-113SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-115SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-116SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-118SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-119SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-121SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-122SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1001SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-102heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-103SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-104SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-105SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-106heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-107heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-108SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-110heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-111heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-111SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-113heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-114heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-116heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-117heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-117SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-119heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-120heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-122heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-123heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-123SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-101SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-102SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-105heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-108heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-109heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-112heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-114SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-115heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-118heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-120SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-121heslkjfreteaartasvetg.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1002SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1003SleepScreen.jpg",
"/mnt/us/linkss/backups/my600x800/HerethisIsaTest-1005SleepScreen.jpg"
} --[[table: 0x43952a30]] 0.21382 seconds 128 
01/19/25-23:22:24 INFO  Screensaver: found and sorted 128 files in 0.274828 seconds 

and apparently, these results suddenly contradict the idea that sorting would always take longer than fetching, in this case fetching time was 0.21382 sec out of a total of 0.274828 sec, which means the sorting for this particular example took 0.061008 sec.

edit: and yet subsequent runs invert the whole matter again, on a second lock we get 0.083314 seconds fetching and 0.145634 seconds sorting, for a total of 0.228948 seconds.

Comment thread frontend/ui/screensaver.lua Outdated
Comment on lines +116 to +118
local file = files[index]
G_reader_settings:saveSetting("screensaver_cycle_index", index)
return file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep things logically together, so saveSeeting(index) once you're done, no need to pick file before it and store it as a local.

        G_reader_settings:saveSetting("screensaver_cycle_index", index)
        return files[index]

Comment on lines +165 to +166
text = _("Show images in alphabetical order"),
help_text = _("When enabled, images will be shown in alphabetical order rather than in random order."),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We display a single cover image, so it's not really "Show images in alpha order".
Pick image ?
May be you should mention the only benefit of this option: each image will be picked, no duplicate one before we iterate the whole set, something like that.

Comment thread frontend/ui/elements/screensaver_menu.lua Outdated
Comment thread frontend/ui/elements/screensaver_menu.lua Outdated
@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Jan 20, 2025

Do we show a checkered sleep screen image under any circumstances?

I was wrong btw, we do: 6ea292e

Comment thread frontend/ui/elements/screensaver_menu.lua Outdated
@Commodore64user Commodore64user changed the title [screensaver] Add alphabetical order option to folder images [screensaver] Add option to cycle through folder images Jan 21, 2025
Comment thread frontend/ui/elements/screensaver_menu.lua Outdated
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
@Frenzie Frenzie merged commit 54add8e into koreader:master Jan 21, 2025
@Commodore64user Commodore64user deleted the alpha-order branch January 21, 2025 16:58
@NiLuJe
Copy link
Copy Markdown
Member

NiLuJe commented Jan 21, 2025

Do we show a checkered sleep screen image under any circumstances? When trying to implement how to limit the number of files, the first thing i thought was to run a loop that would stop at 128 (that didn't work) but what it did do, was show a checkered sleep screen, not the fallback K. And no, i don't have a checkered image on that folder.

RenderImage does when whatever was asked of it failed to render/decode.

@Commodore64user
Copy link
Copy Markdown
Member Author

RenderImage does when whatever was asked of it failed to render/decode.

The checkered grid of death wasn’t too far off my assumption, then. ;)

@NiLuJe
Copy link
Copy Markdown
Member

NiLuJe commented Jan 21, 2025

Yup, that was indeed the intent ;).

@mergen3107
Copy link
Copy Markdown
Contributor

The checkered grid of death wasn’t too far off my assumption, then. ;)

Ever thought of writing books? :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: select screensaver images from a folder - non-randomly

6 participants