Update global variable only on certain condition, else keep its old value

Hey everyone! Happy Holiday season!

I have a global variable called albumart, and I'm trying to have it show spotify's album art. That part is easy. However, I don't want it to show any other player's album art, and I want it - if spotify is closed, or I'm playing on another player - to show the last spotify album art that was playing, essentially saving its last value.

I tried something like this $if(mi(cover)~=spotify,mi(cover),gv(albumart))$ but that got an error, I'm guessing since the variable is calling itself. I just want a way to only update the value when the album art thats currently being read is from spotify, or else just keep whatever value it had.

Any help on how to do this would be greatly appreciated!

If the error is specifically due to it trying to reference itself, you could probably try to duplicate the variable. So have one variable "albumart" and one "oldalbumart", and update them appropriately.

Just guessing, but that's my first impulse on how to attack it.

I thought about this too, but you can't really avoid the circular dependency, and it does give the error.

album1 = $if(mi(cover)~=spotify,mi(cover),gv(album2))$

album2 = $if(mi(cover)~=spotify,mi(cover),gb(album2))$

Unless there's a way to assign a value to album2 within the formula of album1, but i dont know that there is. Something like this:


oh, hmm. Yeah that's tricky.

Worst case you can offload the logic to tasker which should be able to handle that just fine at least.

(oops, didn't continue the thread. Oh well)

Yeah that's an option that's true. I think that involves too many workarounds for my liking though. I'll probably just end up putting a default backup image that sits there. Thanks so much for your help anyway

Very understandable, kwgt can get clunky enough as it is on it's own >.>

No worries, have a nice day~