Created
June 3, 2020 12:49
-
-
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)
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
#!/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