Complete Computing Environment: Google Calendar

Table of Contents

Getting Org-mode scheduled events from Google Calendar

org-gcal1 lets you pull Google Calendar data in to and out of Org-mode. I used org-caldav for the longest time, but this seems like it is more featureful and reliable than that, so we're going to try this for a while. Make sure you follow the directions, it relies on creating a Google developer account and supplying a client id and client secret which you can use to OAuth with.

(provide 'cce-gcal)
(install-pkgs '(org-gcal))

I only use my work calendars right now for this, and I keep the values in the Customize system to keep them out of Git.

(setq org-gcal-auto-archive t)
(setq org-gcal-down-days 30)
(setq org-gcal-up-days 30)

org-gcal uses the calendar's timezone by default, this makes sure those end up in UTC.

(defun cce/clean-up-gcal-timestamps ()
  (dolist (cal-cons org-gcal-file-alist)
    (let ((filename (cdr cal-cons)))
      (shell-command (format "python ~/org/dateswap.py --from Etc/GMT+8 --to UTC --file %s"
                             filename))
      (with-current-buffer (find-file-noselect filename t)
        (revert-buffer t t)
        (beginning-of-buffer)
        (insert "#+FILETAGS: WORK\n")
        (cce/gcal-fix-bad-events)
        (save-buffer)))))

(defun cce/gcal-fix-bad-events ()
  (when (re-search-forward "[a-zA-Z0-9 ]+\\*" nil t)
    (backward-char 1)
    (insert "\n")
    (cce/gcal-fix-bad-events)))

Getting Org-mode scheduled events from Facebook and Meetup

(defun cce/fetch-private-calendars ()
  (interactive)
  (save-window-excursion
    (async-shell-command "awk -f ~/org/ical2org.awk <(curl 'https://www.meetup.com/events/ical/24617342/0d2109febf8f285d24ba16010e1b98b0ac8ee611/going') > meetup.org" (get-buffer-create " *meetup fetch*")))
  (save-window-excursion
    (async-shell-command "awk -f ~/org/ical2org.awk <(curl 'https://www.facebook.com/ical/u.php?uid=804783855&key=AQBArB1uPDGFMIyP') > fb.org" (get-buffer-create " *fb fetch*"))))

Footnotes:

Author: Ryan Rix

Created: 2017-10-03 Tue 10:06

Validate XHTML 1.0