TechTips • Get Random Image Every … Time

How to get a random image every … time?

Preview

TIPS • Random Image 260102-01

Preset Download

Example

How to Open in KLWP

1. Rename the downloaded preset file (the .zip file): remove the `.zip` suffix from the filename

2. Copy/move the renamed preset file to the `wallpapers` folder, under the installation folder of the KLWP

3. Run the KLWP editor and load the copied/moved preset

Explanation

How To

1. Put 1 or more image file(s) into a folder

  • Best practice: a folder in device’s internal storage

2. Create a new preset

3. Create a Text global variable

  • This variable will be used to contain the filepath to the image file

4. Create a Flow, set Flow’s settings as follows:

  • Trigger(s): Cron, Manual (optional), On load complete (optional)
  • Actions: File PickerSet Global Variable

5. Create an Image element, set the Bitmap option to Formula: $gv(_your_global_variable_)$

NOTES

Cron setting explanation

* * * * *
│ │ │ │ └▶ weekday: 0…6 or SUN…SAT
│ │ │ └──▶ month: 1…12
│ │ └────▶ day: 1…31
│ └──────▶ hour: 0…23
└────────▶ minute: 0…59

Examples

Run every minute:

* * * * *

Run every 10 minutes:

*/10 * * * *

Run every hour at the third minute:

3 * * * *

Run every Monday, at midnight:

0 0 * * 1 or 0 0 * * MON

I hope this would help.

:smiling_face::+1:

1 Like

Why use flow instead of just:

$tu(rndimg, 1, “/sdcard/Kustom/images/”)$

Hi there,

$tu(rndimg, …)$ doesn’t work for any folders outside the Kustom installation folder, it’s due to the changes of Android’s file access policy (IIRC since Android 11). That’s why we use Flow as an alternative way to access files.

I hope this would help.

:smiling_face::+1:

1 Like

Didn’t realize flow could do that. TBH, I do not know how to use flow, even though I use KLWP all the time. I have not been able to find a good tutorial on the multiple ways it can used. Brandon’s videos only show one or two ways and they are not extensive. Any resources you have used to learn it?

Hi there,

Well, basically a Flow runs based on one or more trigger(s) and it does one or more action(s) sequentially.

Like the Flow in my example in this post thread, it runs every minute (using the Cron trigger) doing these actions sequentially:

  1. Pick an image file randomly, from the selected folder
  2. Store the filepath of the picked image to a Text global variable

I hope this would help.

:smiling_face::+1: