Skip to content

Instantly share code, notes, and snippets.

@guiniol
Last active October 15, 2015 17:45
Show Gist options
  • Save guiniol/37f3bd149e0e4f0b7071 to your computer and use it in GitHub Desktop.
Save guiniol/37f3bd149e0e4f0b7071 to your computer and use it in GitHub Desktop.
Sup publish hook to send ics invites to google calendar
# This hook uses gcalcli to register events with google calendar. You need to configure gcalcli separately for it to work
# Non-calendar attachments are opened using `xdg-open`
require 'shellwords'
case chunk.content_type
when "text/calendar", "application/ics"
r = IO.popen("/usr/bin/gcalcli --nocolor --reminder=10 --detail_url=short --calendar='<your calendar>' import #{Shellwords.escape filename}",
:err => [:child, :out])
flash r.gets
else
pid = Process.spawn("xdg-open", Shellwords.escape(filename),
:out => '/dev/null',
:err => '/dev/null')
Process.detach pid
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment