Need some help with a visibility formula & Calendar events

Hello, going crazy trying to figure out why this isn’t working. I am trying to have an icon appear when there is any kind of calendar event for the current day, and I want it to not be visible if there is nothing on my calendar for that day. also, if I can have it ignore events that have expired for that day, that would be great. I have tried all kinds of formulas like:

$if(ci(ecount, a0d) + ci(acount, a0d) > 0, ALWAYS, REMOVE)$

$if(ci(count, a0d) > 0, ALWAYS, REMOVE)$

Maybe a few others, but i just cant seem to get this to work. I think i have things right in teh formulas, but obviously not. Any help is appreaciated! Thanks

Hi there,

Your code snippet looks good, but your could try this one as well, who knows it gives a different result:

$if(
ci(ecount,a0d)>0 | ci(acount,a0d)>0,
ALWAYS, REMOVE
)$

I tried the above coffee snippet and it works normal on my phone.

Also, check the timezone used in the preset.

I hope this would help.

:smiling_face::+1:

1 Like

Thanks, i think your code is working because it returned an ALWAYS value in KWGT and its new years day so theres something on my calendar, but the icon still isnt showing. Im thinking maybe i have the widget structure wrong? I start with an overlap group. Inside that i have an icon, text and another overlap group. Inside that overlap group i have the icon that i want to appear and disappear. This is where i am clicking LAYER and adding the formula.

Do i have something wrong? Thanks again

Please check the following. Create a text element and enter this formula:

$ci(ecount, a0d) + ci(acount, a0d)$

Tell me what value it show

- If it returns 0, then check whether KWGT has permission to access and read your calendar events.

- If it returns more than 0, then create a normal layer and place any shape,image inside it.

In that layer’s Opacity field, enter this formula $if((ci(ecount, a0d) + ci(acount, a0d)) > 0, 100, 0)$ . Please let me know the result.

1 Like

Hi there,

If you don’t mind sharing your KWGT preset with me, I would like to help you investigating the issue fav find any solutions to that.

:folded_hands::smiling_face:

1 Like

Hi there,

Have you checked this setting?

Settings ➞ General Settings ➞ Calendar to show ➞ tick any calendars you want to show

:smiling_face::+1:

1 Like

Hey, thanks. I tried your test formula, and it returned a value of 1 inside kwgt, but on the actual widget it disappeared. Since it worked in theory I put your final code in the icons layer opacity field. Once again, the icon showed up inside kwgt, but on the home screen widget, it disappeared. Now, up until this point I have not put any formula in opacity, just in visibility. So I probably have something screwed up somewhere, it’s just weird that it worked in the preview. But anyway, Ive cleared out all of my formulas, and I will share my kwgt here, in case you have time to look at it. It’s a calendar widget, the icon I’m talking about is a little starburst above the date for events. Thanks again

Edit: sorry since im a new user I can’t upload anything yet, here’s a link to the widget:

https://tmpfiles.org/dl/18041404/pixcal08_.kwgt

Hi, check my response to Max, I’m doing something wrong I’m sure. I can’t upload anything since I’m a new user but here is the kwgt, thanks for the help:

https://tmpfiles.org/dl/18041404/pixcal08_.kwgt

Your widget is fine. If you had mentioned earlier that it works inside KWGT but disappears on the actual home screen, I would have suggested a completely different approach.

Try placing the formula either in the visibility field (as you did before) or in the opacity field (as I suggested). After that, save the widget, close KWGT, clear KWGT’s cache, and optionally reboot your phone.

Then open KWGT again, save once more, and check if the icon appears on the home screen. And let me know if the issue remains after that.

(For mods. This is the answer that solved the issue)

1 Like

Ok great, I did everything you said including a reboot, put it in opacity, and the icon appears on homescreen. My calendar is clear tomorrow so I’ll see if it disappears tomorrow.

One more question, does your code cover any and all events? Like all day ones along with timed ones? And, ok now I might be getting greedy, but when the icon appears for a notification, how hard would it be to put text inside of the icon showing how many events I have for today? Thanks again for all the help and patience

This code will show official holidays and your own events that you add to the calendar as an event, regardless of whether they are all‑day or timed.

As for showing the total number of today’s events inside the icon, just put this formula into a text element:

$ci(ecount, a0d) + ci(acount, a0d)$

That’s all. :+1:

1 Like

Thank you for being so helpful, that worked perfectly. But I’m sorry, I keep thinking of questions. If you don’t mind. For the calendar alerts, both the icon and the text, is there a way for it to capture Google calendar tasks as well as events? It doesn’t seem to be grabbing the tasks.

And the other 2 questions I had, which I don’t think are possible, but while I’m here … 1, I just switched from a nothing phone, their calendar widget was cool, you could swipe up on it and it would list that days calendar items. Is anything like that possible with kwgt? And 2, this is sort of general, but without using tasker, is there a way in kwgt to make an icon perform a trigger, such as turning on or off VPN for example?

Endless thanks. For years I’ve asked my questions on the kwgt reddit with not much luck. I’ve had more help here in a day than a decade there.

Thanks. About tasks no, Google doesn’t expose them through the same API as calendar events, so KWGT can’t read them.
About VPN you can launch the VPN app or an intent if it supports one, but actually toggling it on/off isn’t really possible without Tasker.
And about the swipe KWGT doesn’t support swipe gestures, only taps.

By the way, I’ve posted a lot of my components on Reddit — maybe some of them will be useful for you.:+1:

1 Like

Thanks! I’ll definitely check them out