Trigger navigation events from Lovelace

Hello folk,
I would like to run a script every time I enter a particular view in the Lovelace front end, but I cannot figure out how to do it.
Any idea on if and how is it possible?

Thanks!

Let me revive this old thread as I struggle with the same thing now.

I want to be able to change theme (frontend.set_theme) when a different lovelace dashboard is selected. So I need a trigger checking navigation path. I know browser_mod has some capability in this regard, but that is the other way around - it can navigate as a result, and not trigger on it as far as I understand.

Does anyone have any idea on how to achieve what I need?