Updating a menu only when not active

I have a menubar app that consists of a dynamically created menu. I currently have it update when I click on the menubar icon, but that leads to a small delay when opening as it has to recreate the list that instance.

I would like for the menu to update every 15 seconds or so (on idle), but only update when the menu is not active.

I tried using ‘on idle’, but it still updates even when the menu is active. Is there anything that can be done to make the menu update on idle, but not while the menu is open?

Thank you

The idle in on idle has nothing to do with whether the app is idle.

Unless the delay is horrendous, I’d stick with what you’re doing. Any solution is likely to be complicated.