derekantrican / GAS-ICS-Sync

A Google Apps Script for syncing ICS/ICAL files faster than the current Google Calendar speed
GNU General Public License v3.0
1.55k stars 197 forks source link

Support "COLOR" tag #93

Closed derekantrican closed 5 months ago

derekantrican commented 4 years ago

Support VEVENT's COLOR tag. Docs: https://icalendar.org/New-Properties-for-iCalendar-RFC-7986/5-9-color-property.html

*Note that COLOR is a name (eg COLOR:Banana or COLOR:turquoise). According to the docs:

The value is a case-insensitive color name taken from the CSS3 set of names, defined in Section 4.3 of [W3C.REC-css3-color-20110607].

jonas0b1011001 commented 4 years ago

Google Calendar only support 11 different colors, matching would have to be done manually.

derekantrican commented 4 years ago

Right. I think it will end up "not fully implemented" and have a couple short comings but I think it could still be useful to a lot of people

jonas0b1011001 commented 4 years ago

Definitely, do you know if outlook is using the ical property or a custom property?

derekantrican commented 4 years ago

Unfortunately it looks like Outlook might use "CATEGORIES". This is an official ICS property but not really meant for this use

image

image

jonas0b1011001 commented 4 years ago

So let's see what our possibilities are here.

  1. Event has a color property (i don't know any service/app that is using the property) Manually match color name to one of google's 11 colors.

  2. Event has a category property (e.g. outlook) Assign a color to each category, this could either be done by the user or randomly by the script.

  3. Event has non of the above properties (e.g. google calendars or basically all ics files available online) The only thing i could think of would be to assign a color to each synced calendar. So if i merge three ics files into one calendar i can still distinguish the source calendars by event color.

Did i miss anything?

derekantrican commented 4 years ago

Let's not do # 3. I don't want to randomly start assigning colors to people's events. We'll just have it use the target calendar's color like it does now.

I think # 1 is good (as best we can) and # 2 we should also do as best we can. I can try to come up with a list of possibilities for these. Similarly to above, I don't want to randomly assign colors. If we can't come up with a match (in this case: something that we've hardcoded) then let's not override the event's color and have it default to the target calendar's color

derekantrican commented 4 years ago

Note that while the icalendar.org link has documentation on a COLOR property, it is not part of the official standard

My bad. There's an updated standard: https://tools.ietf.org/html/rfc7986#section-5.9

CaTeNdrE commented 3 years ago

I understand you don't want to randomly assign colors to peoples calendars however being able to specify a custom color is of huge value. I manage multiple calendars for my children's sports and activities. They are typically shared by 3rd party apps and I came across your excellent work because of the number of times gCal wasn't updating for a number of days and I got caught. I would rather add the events to my kids main event calendars that are already shared rather than maintain additional calendars every time there is a new team, new season etc. The amount of calendar mgt I have to do is obscene: Adding new calendars to the kids accounts, sharing them with both parents, enabling syncing on each mobile phones and tablet for any newluy added calendars... rinse and repeat several times a year. Your scripts allow me to add the new calendar sync directly into my kids main event calendars that are already sync'ed. I am using the prefix to help identify the shared calendar source but without being able to control the color of the events on a source calendar-by-calendar basis it is very difficult to scan the calendar and quickly differentiate events. I tried to use 'colorizeBySourceCalendar' but I had no success (color always stayed as the color defined in the gCal account settings. Thanks for all your work. I think the prefix and the color options are extremely valuable.

jonas0b1011001 commented 3 years ago

I tried to use 'colorizeBySourceCalendar' but I had no success

Are you using the version referenced here or did you do manual changes?

CaTeNdrE commented 3 years ago

I tried to use 'colorizeBySourceCalendar' but I had no success

Are you using the version referenced here or did you do manual changes?

I diff'ed both and then made 'selective' changes to the Master. I think that finding the #144 version in the trash concerned me regarding other changes that came later designed to address other issues with the code. Reading your response (thank-you) I believe I should have tested #144 unchanged before posting here. I will do some additional testing and then circle back before I tie up any more of anyone's time.

jonas0b1011001 commented 3 years ago

I just realized that there are two versions linked in #144 and one of them is not working. Fixed it and moved it out of trash :)

You need to add

if (event.hasProperty('color'))
    newEvent.colorId = event.getFirstPropertyValue('color');

to function createEvent, rest is unchanged.

acrylicus commented 2 years ago

I am trying to get this to work but cant make heads or tails of this thread.

Is this something that is still supported?

jonas0b1011001 commented 2 years ago

Is this something that is still supported?

Definitely, the latest code from this repo supports it. You'll have to manually replace the files you already have with the ones from github as the update was made after the 5.6 release.

acrylicus commented 2 years ago

Definitely, the latest code from this repo supports it.

Interesting - I only started using this about 2 weeks ago. I have colored items in my Outlook calendar but they are all green in my Google calendar

As per: https://imgur.com/a/utPvXGY

Am I doing something stupid? :)

derekantrican commented 2 years ago

Per what Jonas said:

You'll have to manually replace the files you already have with the ones from github as the update was made after the 5.6 release.

The files in this repo may have more up-to-date code than the public script at https://script.google.com/d/1BOk8MDLbLaHh6SwG1M1tsgNXjkcC-79LE0QoipRuTDxbO3fMVvqoROQD/edit?newcopy=true . So you will have to follow the steps at https://github.com/derekantrican/GAS-ICS-Sync/wiki/Setting-up-the-script-manually (starting around step 5). You will also have to add your calendar & settings back.

Think of it like testing a "beta" version

acrylicus commented 2 years ago

The files in this repo may have more up-to-date code than the public script at https://script.google.com/d/1BOk8MDLbLaHh6SwG1M1tsgNXjkcC-79LE0QoipRuTDxbO3fMVvqoROQD/edit?newcopy=true .

I've rebuilt using this - and I've added:

if (event.hasProperty('color'))
    newEvent.colorId = event.getFirstPropertyValue('color');

to createEvent in handler.gs

However, when logging newEvent.colorId with Logger the output is just null.

The outlook event looks like this - as far as I can see this is the only way to add a color to an event https://imgur.com/a/1sm0oHh

derekantrican commented 2 years ago

Note what I said above for Outlook:

Unfortunately it looks like Outlook might use "CATEGORIES". This is an official ICS property but not really meant for this use

So Outlook doesn't directly use color and you'll have to change things like hasProperty('color') to hasProperty('categories'), then get the color from there

acrylicus commented 2 years ago

FYI after some poking around I discovered that for some reason my ICS feed doesn't include CATEGORIES - even though they are definitely set.

So my workaround is just to use the event name to manually set a color:

  if (newEvent.summary == "Lunch"){
    newEvent.colorId = "4";
  }

  if (newEvent.summary == "Focus time"){
    newEvent.colorId = "2";
  }

Using IDs from here: https://lukeboyle.com/blog/posts/google-calendar-api-color-id

derekantrican commented 2 years ago

Sounds great - at some point or another, I imagine you'd have to add some custom workaround. Glad you've got something that works for you

workjoeea commented 1 year ago

hello. I hope this post is in the correct place. Thank you for this script. It seems to work perfectly as designed. I could use help/advice, though. Is it possible to include and/or exclude certain Outlook categories from the export/sync into Google? It looks like somewhere in this chat string folks figure out how to draw/gather the Outlook category from the ICS...but what I can't sort out is where to insert that code. Forgive me, as I'm not really a programmer. Any assistance is much appreciated.