Quickly open Google Calendar Tab in Google Chrome from Alfred

| 2 min read

I have pinned tabs for Calendar and Gmail, and I wanted to quickly jump to them from anywhere using Alfred.

Another option could have been to use Alfred’s Web Search feature to open a new tab. That would be a simple version of what I wanted, but I was curious to see if it was possible to go to an existing tab.

Additionally, Alfred offers another option with an Automation Task accessible in the Workflow menu (Automation > Automation Task > Extra Automation Task > Web Browser> Chromium > Switch to Chromium Browser Tab Matching URL). I discovered that solution after implementing mine, but I decided to keep what I had because the Automation Task doesn’t properly handle having multiple Chrome windows opened, and I usually have several of them.

In the end, my solution is an Alfred Workflow I made that runs an AppleScript[1] when a keyword is entered in the Alfred command palette.

Alfred Workflow

The Keyword trigger configuration is simple: Take the keyword "calendar" with no argument. then make it look nice by adding a title, a subtext and Google Calendar icon.
Alfred Keyword window

Add an AppleScript action with the following script:

on alfred_script(q)
tell application "Google Chrome"
activate

-- Loop through all windows
repeat with windowIndex from 1 to count of windows
set theWindow to window windowIndex

-- Loop through all tabs in the current window
repeat with tabIndex from 1 to count of tabs of theWindow
set currentTab to tab tabIndex of theWindow
set tabURL to URL of currentTab

-- Check if the tab contains Google Calendar
if tabURL contains "calendar.google.com" then
-- Make this window active and switch to the calendar tab
set index of theWindow to 1
set active tab index of theWindow to tabIndex
return -- Exit the script once found
end if
end repeat
end repeat
end tell
end alfred_script

For an extra boost of productivity[2], make it so the calendar opens on the weekly view for today. For this, you can modify the script to ask Chrome to change the tab URL:

  set active tab index of theWindow to tabIndex
+ set URL of currentTab to "https://calendar.google.com/calendar/u/0/r/week"
return -- Exit the script once found

I also created a similar script for Gmail by using another Keyword trigger and using Gmail's url.

Now I can access my calendar and emails from anywhere!

Hey, let’s have a chat!.


  1. Actually, Claude made the AppleScript. I still don’t understand how this language works, and didn’t take the time to get it. ↩︎

  2. Lol ↩︎

Whenever you're ready, here is how I can help you: