npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gcal-to-org

v0.2.0

Published

A simple CLI tool for exporting Google calendar events to emacs org-mode.

Downloads

9

Readme

Export google calendar to org-mode

Overview

A simple little CLI tool to export your google calendar into org-mode.

Unlike the synchronization workflow described on the on the Worg website, gcal-to-org uses Google's API Client Library for Java. Since it authenticates using OAUTH, there is no need to make your calendar publicly available through a "hidden" url.

This tool is in the early stages and narrowly focused on my particular needs. However, it should be easy to adapt it to your use-case, and I would be happy to iterate on the design.

Installation

npm install -g gcal-to-org

Usage

First create a config.edn config file somwhere. Below is a minimal example for a single calendar. See config.example.edn for a fully commented example.

{:calendars [{:id "[email protected]"}]
 ;; Google API credentials (see below)
 :client-id "123456789-abcdedfhijklmopqrst0123.apps.googleusercontent.com"
 :client-secret "qDcAHZyjdEDikPtIaaElOyF9"}

Then run just run the CLI tool to print org-mode text to stdout.

gcal-to-org path/to/config.edn

On the first run, it will open an OAUTH window in your default browser and cache your OAUTH tokens to disk. On subsequent runs, it simply uses the cached credentials and behaves like any other CLI tool.

Obtaining Google API credentials

You need to register gcal-to-org as an application yourself to obtain a Client ID and Client secret.

Go to the Google API Manager and create a new project under any name.

Within that project, enable the "Calendar" API. There should be a searchbox where you can just enter those terms.

In the sidebar, select "Credentials" and then create a new "OAuth Client ID". The application type is "Other".

You’ll be prompted to create a OAuth consent screen first. Fill out that form however you like.

Finally you should have a Client ID and a Client secret. Provide these in the config below.

Emacs integration

Everyone's setup is different, but in case you are interested, here is how I call the tool from emacs.

;;; Write work agenda here
(defvar my-work-agenda-file "~/var/work.org")

;;; Add work agenda to default agenda files
(add-to-list 'org-agenda-files my-work-agenda-file)

(defun my-update-work-agenda-file ()
  "Create work agenda file by pulling from Google Calendar."
  (if (zerop (call-process "gcal-to-org" nil `(:file ,my-work-agenda-file) nil "/path/to/config.edn"))
      (let ((buf (find-buffer-visiting my-work-agenda-file)))
        ;; Revert work buffer if it exists
        (when buf
          (with-current-buffer buf
            (revert-buffer nil t)))
        (message "Successfully updated %s" my-work-agenda-file))
    (message "Failed to update %s" my-work-agenda-file)))

;;; Add command to call gcal-to-org from the agenda dispatch view. Bound to "w" key.
(add-to-list 'org-agenda-custom-commands
             '("w" "Update work agenda file"
               ;; This functions gets called with a match object that we discard.
               (lambda (_) (my-update-work-agenda-file)))
             t)