Feature request: select a specific sleep screen image on-device instead of random
Summary
With Sleep Screen = Custom and multiple BMPs in /sleep/, the image shown is always
picked at random. There is no way to choose a specific one from the device — the only
workaround is to delete every other file from the directory.
It would be useful to select a specific sleep image on-device, keeping random as the default so nothing changes for existing users.
Current behaviour
src/states/SleepState.cpp:174-224 collects every valid BMP in /sleep/ and then picks
one at random:
const auto numFiles = files.size();
if (numFiles > 0) {
const auto randomFileIndex = random(numFiles); // :210
const auto filename = "/sleep/" + files[randomFileIndex];
...
}
The Sleep Screen setting only selects the mode (Dark / Light / Custom / Cover / Keep
Page), so "Custom" implicitly means "random from /sleep/".
The web server's Sleep tab can upload and delete images, but not select one, and it needs
WiFi. docs/webserver.md:176 documents the random behaviour as intended.
Proposal
Add a second setting, e.g. Sleep Image, shown when the mode is Custom:
Random(default — current behaviour, no migration needed)- one entry per
.bmpfound in/sleep/
Persist the chosen filename in Settings. In renderCustomSleepScreen(), use it when it
is non-empty and the file still exists, otherwise fall back to the existing random pick —
that keeps deleted or renamed files from breaking the sleep screen.
The file enumeration and BMP-header validation that a picker needs already exist in
renderCustomSleepScreen() (SleepState.cpp:181-206), so the listing logic could be
factored out and shared rather than written twice.
Why on-device
Curating the images is a WiFi/desktop task and the web UI is the right place for it. But choosing which one is currently showing is a quick, frequent action — matching the sleep screen to a mood or a context — and going through WiFi plus a browser for it is a lot of friction. It is also the one sleep-screen operation that works when no network is available.
Notes
Happy to open a PR for this if the direction sounds right — please say whether you would
prefer the setting hidden unless /sleep/ contains more than one file, or always visible
in the Custom mode.
Context: Xteink X4 on v1.26.2.
@DanielHons Added in 1.37.0