Skip to content

Instantly share code, notes, and snippets.

@imaizume
Created June 3, 2020 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imaizume/2af510acaa7904d81479c35f6463fdc7 to your computer and use it in GitHub Desktop.
Save imaizume/2af510acaa7904d81479c35f6463fdc7 to your computer and use it in GitHub Desktop.
A simple Ruby script to open google meet URL from CLI. Thankfully inspied by miyagawa's perl script (https://gist.github.com/miyagawa/986e4034a09e6c822a832a4e283f331f)
#!/usr/bin/env ruby
require 'date'
require 'pp'
calendar = 'your-calendar@example.com'
regex = /^https?:\/\/meet\.google.com\/[\w-]+$/i
now = DateTime.now
ends = now + Rational(1, 24) # within 1h
cal = `gcalcli --refresh --calendar=#{calendar} agenda --details all --tsv --nodeclined #{now} #{ends}`
url_index = 5
title_index = 8
cal.split("\n").each do |line|
cells = line.split "\t"
title = cells[title_index]
url = cells[url_index]
if url =~ regex
pp "Next Event: #{title}"
pp "Opening #{url}"
system "open #{url}"
exit
end
end
pp "No event or Meet URL found."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment