How to use both timer and button switch in 2 overlay groups?

I have 2 overlay groups which I want to be able to switch from one to the other with a switch, but also to have a timer to auto switch every 10 seconds. I can use them separately, but I don’t know how to combine them(if possible). For using a button to switch I’ve created a list global with 2 items and at each overlay I use this formula $if(gb(pages)=now, always, never))$.

Now, for the auto switching I created 2 global texts(timer and timer2) with the formulas: timer-> $(tu(seq, 1/6, 0,1)=0, never, always)$

timer2 → $(tu(seq, 1/6, 0,1)=1, never, always)$

How to combine those two(timers and switch button), I can have the timer to change the overlays every 10 seconds, but to also can to switch them with the button?

To combine auto-timer and manual touch without conflicts, use Flows with a ‘safety check’.

  1. Global Vars: pages (List 0,1) and lastclk (Text).

  2. Manual Button (Touch): Set pages to toggle AND set lastclk to $df(S)$.

  3. Flow Trigger: Formula $tu(seq, 1/6, 0, 1)$ on Output Change.

  4. Flow Action: Use formula: $if(df(S) - gv(lastclk) > 9, if(gv(pages)=0, 1, 0), gv(pages))$

​This prevents the timer from flipping the page if you just clicked it manually a few seconds ago. It’s the most reliable ‘smart’ loop for KLWP.

I haven’t use flows ever, because I don’t realy understand how work and what functionality add. I tried your suggestion but I’m stuck at the 3rd step. I don’t have Output Change on Flow Trigger. I don’t have KWLP, I’m using KWGT pro, and I forgot to mention it on my first post.

Where is “Output Change”? Go to Flow → Trigger → Formula. To the right of the formula box( see screen).

The Catch: You can set this up in KWGT, and it will work perfectly inside the editor. However, on your home screen, it will fail.

Why: Android limits widget updates to save battery (usually once per minute max). This is why I recommended KLWP — only live wallpapers can handle 10-second loops reliably.

I don’t have this. In formula I have only the textbox to write the formula and the Cancel/Save buttons.

ezgif-87c29e36499dce0f

If you prefer to build it directly in KWGT, that’s also possible.

Instead of using a 10‑second interval, you can simply switch to a 1‑minute interval and let the system clock handle the trigger.

- Trigger: formula → $df(mm)$

- Mode: On output change

- Effect: every time the minute changes, the flow triggers and flips your page automatically.

1 Like

Ok, I finally found it! The “formula” list item of the flow trigger is covered from my device’s bottom bar with the buttons for back/homescreen/recent apps. For this I couldn’t see it. Now I can proceed.

So, now I have:

  • 2 globals, one list with name pages and 0,1 as list items, and one text with no content
  • 1 button in which the touch is Toggle Global Switch → pages → next value(I don’t have toogle there, only the pages’ s list items and the previous and next values.
  • 1 flow in which the trigger is the formula with the timer, and the Action is $if(df(S) - gv(lastclk) > 9, if(gv(pages)=0, 1, 0), gv(pages))$

I see from your images that you have also another action “Set Global Var” which I suppose I need to also add it and use the global text variable I defined.

If all the above is correct, how now I use them on the overlay groups?

You are almost there!

​The Flow Action:
​In your Flow, Action 1 (Formula) calculates the value.
​You MUST add Action 2: Set Global Var.
​In Action 2, select your global pages as text. This tells the Flow to actually save the result of the formula into your variable.
​The “Manual” Button (Very Important):
​Your button touch needs two actions now.
​Action 1: Toggle Global Switch → pages.
​Action 2: Set Global Var → lastclk with the formula $df(S)$.(You can make this button invisible and place it directly on top of your layers.)
​Without this, the timer won’t know you clicked the button manually.
​How to use it on Overlay Groups:
Simply go to the Layer tab of your Overlay Groups, find Visible, and use this formula:
​For Group 1: $if(gv(pages)=0, ALWAYS, REMOVE)$
​For Group 2: $if(gv(pages)=1, ALWAYS, REMOVE)$

It’s done but it doesn’t work. I can change the overlays with the Toggle button, but the timer doesn’t seems to work even in the editor. I don’t see any difference from the images except the action formula. On your first answer was

$if(df(S) - gv(lastclk) > 9, if(gv(pages)=0, 1, 0), gv(pages))$ (I’m using this),

in image is if(gv(pages)=0,1,0)$

which I don’t think that is all the formula.

I made a sample file for you to test. Check the link/attachment.

To make it work every 10 seconds on your home screen like it does for me, you need to enable a hidden setting (Warning: this will drain more battery):

Open KWGT Settings.

Go to Advanced Options.

Find Update Mode and set it to “Fast (will always update on seconds tick)”.

How the sample works:

The Flow: It now has two actions. The first calculates the page, and the second saves it to your pages global.

The Trigger: I set it to a faster formula so you can see it working immediately.

The Button: It updates the lastclk variable so the timer doesn’t conflict with your manual clicks.

Try this file with the Fast Update setting enabled, and you will finally see the auto-swap working on your home screen!

10_sec_fast_test.kwgt (94.8 KB)

1 Like

Thanks, this file works, and the problem is that I was using the formula from your first answer in flow action and not this: $if(gv(pages)=0,1,0)$.

Now it works on editor, but doesn’t on the homescreen. Your file works on homescreen also, but not every time, mostl. Maybe because has less elements than mine. Also mine isn’t directly in homescreen. I’m using total launcher which support windows, so the widget is inside a window which opens by a button.

As I said from the beginning, Kustom doesn’t have a native ‘timer’ feature, so we have to use these workarounds with Flows and Formulas.

The reason it’s inconsistent for you is that KWGT is a widget, and Android system limits how often it can ‘wake up’ to run these scripts, especially inside launcher windows. My sample shows that the logic works, but the platform (KWGT) struggles to keep up.

This is exactly why I recommended KLWP from the start. In KLWP, this setup will run much smoother and more reliably because live wallpapers have a higher priority for the system than widgets. I just wanted to show you how you can ‘cheat’ the system in KWGT if you really have to.

1 Like

Yes, I know but I wanted to try because the timer without flow worked fine and without delays. So, I wanted to try it just to see if it works, maybe with encreased interval. Anyway thank you.

MaxP is spot on about the 10-second limitation in KWGT - Android definitely kills those frequent updates to save battery. If you’re stuck with KWGT, one ‘cheat’ is to change your timer to 1 minute instead of 10 seconds. It’s not as snappy, but it actually works reliably on the home screen. For the manual override, using a simple List Global and having the button set the list value works best, but you just have to accept the auto-switch will be a bit slower!

1 Like