- Copy the below code
- Go to Google App Script
- Click "New Project"
- Name it Calendar Colors
- Paste the code from
Code.gs
in the file with the same name - Click run if it's working appropriately
- Go to Triggers and set it to trigger every hour
Created
May 27, 2024 08:33
-
-
Save samuelbeek/e89403892caecb5e3da7ee61addd0653 to your computer and use it in GitHub Desktop.
Calendar Colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ColorEvents() { | |
var today = new Date(); | |
var nextweek = new Date(); | |
nextweek.setDate(nextweek.getDate() + 14); | |
var calendars = CalendarApp.getAllOwnedCalendars(); | |
for (var i=0; i<calendars.length; i++) { | |
var calendar = calendars[i]; | |
var events = calendar.getEvents(today, nextweek); | |
for (var j=0; j<events.length; j++) { | |
var e = events[j]; | |
var title = e.getTitle().toLowerCase(); | |
var desc = e.getDescription().toLowerCase(); | |
// make 1-1s indigo | |
if ((title.includes("x") || title.includes("/") || title.includes("1-1") || title.includes("<>")) | |
&& !(title.includes("company") || title.includes("sync") || title.includes("veed") )) { | |
e.setColor('9'); // '9' corresponds to Indigo | |
} | |
// make to do tasks starting with [] green | |
if (title[0] == "[") { | |
e.setColor(CalendarApp.EventColor.GREEN); | |
} | |
// make tasks starting with ! red | |
if (title[0] == "!") { | |
e.setColor(CalendarApp.EventColor.RED); | |
} | |
// make breaks starting with # orange | |
if (title[0] == '#') { | |
e.setColor(CalendarApp.EventColor.ORANGE); | |
} | |
// make interviews pale green | |
if(desc.indexOf("candidate")>-1) { | |
e.setColor(CalendarApp.EventColor.PALE_GREEN); | |
} | |
// make user interview sections purple | |
if(desc.indexOf("user interviews")>-1) { | |
e.setColor(CalendarApp.EventColor.MAUVE); | |
} | |
// make calendly invites yellow | |
if(desc.indexOf("calendly")>-1) { | |
e.setColor(CalendarApp.EventColor.YELLOW); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment