{"id":235,"date":"2025-04-12T14:15:40","date_gmt":"2025-04-12T14:15:40","guid":{"rendered":"https:\/\/patryk.rzski.com\/?p=235"},"modified":"2025-05-16T08:53:53","modified_gmt":"2025-05-16T08:53:53","slug":"automatically-add-ics-files-to-google-calendar","status":"publish","type":"post","link":"https:\/\/patryk.rzski.com\/?p=235","title":{"rendered":"Automatically add ICS files to Google Calendar"},"content":{"rendered":"\n<p>If your preferred email client is not one of the popular choices, for example you use roundcube, Nextcloud or Snappy mail, you probably have come across a situation where email invitations to web meetings arrive as email attachments. What&#8217;s then most convenient is to be able to click on an attachment and have it automatically appear in Google&#8217;s calendar. This guide explains how to achieve this on a Linux desktop, as well as in Android.<\/p>\n\n\n\n<p>The attachment is a file with an ICS or iCal extension is a set of meeting&#8217;s metadata. It is formatted and known as one of the MIME type files. This allows desktops to assign a handling application whenever such file is to be opened. For Android, the operation is easy, since there&#8217;s a Google calendar app either preinstalled or easily installed, which can be associated with the file (use the tripple-dot button on the file, then &#8220;Open with&#8221; and select the calendar app).<\/p>\n\n\n\n<p>The challenge is a bit harder on the desktop, where there&#8217;s no Google app available. There usually are, depending on the choice of the desktop manager, calendar applications which could integrate with Google&#8217;s calendar, however that is not always the case. In such situations, there&#8217;s a good solution called <a href=\"https:\/\/github.com\/insanum\/gcalcli\">gcalcli.<\/a><\/p>\n\n\n\n<p>It can be easily installed in user mode with a few trivial steps (such as creating a python virtual environment). Since the Google Calendar is available through a RESTful API behind OAuth authentication, there is one prerequisite described in <a href=\"https:\/\/github.com\/insanum\/gcalcli\/blob\/HEAD\/docs\/api-auth.md\">this guide<\/a>. Following it allows gcalcli to securely call Google Calendar&#8217;s API to create events using the<strong> import <\/strong>command.<\/p>\n\n\n\n<p>Eventually all that&#8217;s left to do is to write an oneliner script which can be tied to the desktop&#8217;s ICS MIME type, which will then run gcalcli with the right arguments and parameters. Here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>patryk@ryba ~ % cat gcal-venv\/bin\/importer.sh \n#!\/bin\/zsh\n#\n\/home\/patryk\/gcal-venv\/bin\/gcalcli import --calendar='Patryk Rz.' \"${1}\"<\/code><\/pre>\n\n\n\n<p>Don&#8217;t forget to make <code>importer.sh<\/code> executable with chmod.<\/p>\n\n\n\n<p>I use XFCE as my desktop manager, therefore my ICS file association looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1002\" height=\"286\" src=\"https:\/\/patryk.rzski.com\/wp-content\/uploads\/2025\/05\/Screenshot_2025-05-07_14-15-17.png\" alt=\"\" class=\"wp-image-236\" srcset=\"https:\/\/patryk.rzski.com\/wp-content\/uploads\/2025\/05\/Screenshot_2025-05-07_14-15-17.png 1002w, https:\/\/patryk.rzski.com\/wp-content\/uploads\/2025\/05\/Screenshot_2025-05-07_14-15-17-300x86.png 300w, https:\/\/patryk.rzski.com\/wp-content\/uploads\/2025\/05\/Screenshot_2025-05-07_14-15-17-768x219.png 768w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/figure>\n\n\n\n<p>And that&#8217;s all. Clicking on any file with the .ics extension will have my desktop call the <code>importer.sh<\/code> script, which will invoke gcalcli from it&#8217;s <code>venv<\/code> with the right parameters. Gcalcli will then call Google&#8217;s API to create the event will all the details as the inviter intended. Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If your preferred email client is not one of the popular choices, for example you use roundcube, Nextcloud or Snappy mail, you probably have come across a situation where email invitations to web meetings arrive as email attachments. What&#8217;s then most convenient is to be able to click on an attachment and have it automatically [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=\/wp\/v2\/posts\/235"}],"collection":[{"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=235"}],"version-history":[{"count":2,"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions\/240"}],"wp:attachment":[{"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/patryk.rzski.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}