Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2010/01/22

gcalcli - command-line interface to Google Calendars

The coolest of all things about Google Calendar is how you can just put anything into the field and it'll interpret it. Most calendar programs have involved configurations, which are available if you need to fine-tune your gCal events, but being able to type in "LUG meeting 7pm in ECE" and having it know what you mean? That's good.

But it means having Google Calendar open. Which, honestly, I don't often do. With alerts, I have Evolution keeping track, I have some code that checks my calendar and sends me IMs to warn me, and there's what Google does automatically with SMS and email. If I have to go, I don't need Google Calendar open to remind me. So, like with Twitter and other things I've coded, what I need is a way to use Google Calendar without really using Google Calendar.

And gcalcli is that. It's a snazzy command line interface to Google. For Ubuntu folks, installation is as easy as sudo apt-get install gcalcli, and it shouldn't be much harder for the rest of you. All you need to do is type:

gcalcli quick '7pm Pick up Windows7 at Best Buy '

And there it is.

But I can't leave it there.


I've come to liking this kind of form for more social and less structured commands

program Long line of words that is a sentence, not an array of commands


So, I have a wrapper for the quick function here.


#!/usr/bin/perl

use strict ;
use warnings ;
use 5.010 ;
use subs qw{ set_status } ;

my $args = join ' ', @ARGV ;
if ( $args eq '' ) {
while ( ) {
$args .= $_;
}
}
create_event( $args ) ;

exit ;

########## ########## ########## ########## ########## ########## ##########
sub create_event {
my ( $msg ) = @_ ;
qx{/usr/bin/gcalcli quick '$msg' } ;
say $msg ;
}
########## ########## ########## ########## ########## ########## ##########


The thing I like most about this is how I don't have to worry about handling passwords. It's in the .gcalcli config itself. More on other uses later.

2 comments:

  1. That wrapper script can be reduced to 2 lines:

    #!/bin/bash
    gcalcli quick "$@"

    ReplyDelete
  2. Not quite. But would've been nice if it had worked.

    jacoby@oz:~$ cat foo.sh ; ./foo.sh Mow the dang yard 5:30pm-8:30pm
    #!/bin/bash
    echo "$@" ;
    /usr/bin/gcalcli quick "$@" ;
    Mow the dang yard 5:30pm-8:30pm

    Error: invalid event text

    Usage:
    ....

    ReplyDelete