What's new? | Help | Directory | Sign in
Google
gcalcli
Command Line Interface to Google Calendar
  
  
  
  
    
Search
for
Updated Oct 15, 2007 by insanum
Labels: Featured
HowTo  
How to use gcalcli...

Login Information

You can provide gcalcli with your Google Calendar login information either by editing the top of the script itself, using the --user and --pw arguments, or using the config file. In any case make sure you protect the information.

HTTP Proxy Support

gcalcli will automatically work with an HTTP Proxy simply by setting up some environment variables:

   http_proxy
   https_proxy
   proxy-username
   proxy-password

Note that these environment variables must be lowercase and beware the usage of the dashes vs underscores.

Config File

gcalcli is able to read default configuration information from a config file. This file is location at '~/.gcalclirc' and must be formatted as follows:

   [gcalcli]
   <config-item>: <value>
   <config-item>: <value>
   ...

The available config items are the same as those that can be specified on the command line. Note that any value specified on the command line overrides the config file.

   user: <username>
   pw: <password>
   cals: <type>
   details: <true|false>
   ignore-started: <true|false>
   width: <width>
   cal-owner-color: <color>
   cal-editor-color: <color>
   cal-contributor-color: <color>
   cal-read-color: <color>
   cal-freebusy-color: <color>
   date-color: <color>
   border-color: <color>

'gcalcli' event popup reminders using cron

Run gcalcli using cron and generate xmessage-like popups for reminders.
   % crontab -e
Then add the following line:
   */10 * * * * gcalcli remind

'gcalcli' agenda on your root desktop

Put your agenda on your desktop using Conky. Add the following to your .conkyrc:
   ${execi 300 gcalcli --nc agenda}
To also get a graphical calendar that shows the next three weeks add:
   ${execi 300 gcalcli --nc --cals=owner calw 3}

'gcalcli' agenda integration with 'screen'

Put your next event in your 'screen' hardstatus line. First add a cron job that will dump you agenda to a text file:
   % crontab -e
Then add the following line:
   */5 * * * * gcalcli --nc --ignore-started agenda "`date`" > /tmp/gcalcli_agenda.txt
Next create a simple shell script that will extract the first agenda line. Let's call this script 'screen_agenda':
   #!/bin/bash
   head -2 /tmp/gcalcli_agenda.txt | tail -1
Next configure screen's hardstatus line to gather data from a backtick command. Of course your hardstatus line is most likely very different than this (Mine is!):
   backtick 1 60 60 screen_agenda
   hardstatus "[ %1` ]"

'gcalcli' Usage

Usage:

gcalcli [options] command [command args]

 Options:

  --help                   this usage text

  --config <file>          config file to read (default is '~/.gcalclirc')

  --user <username>        google username

  --pw <password>          password

  --cals=[all,             'calendars' to work with (default is all calendars)
          default,         - default (your default main calendar)
          owner,           - owner (your owned calendars)
          editor,          - editor (editable calendar)
          contributor,     - contributor (non-owner but able to edit)
          read,            - read (read only calendars)
          freebusy]        - freebusy (only free/busy info visible)

  --cal=<name>             'calendar' to work with (default is all calendars)
                           - you can specify a calendar by name or by using a
                             regular expression to match multiple calendars
                           - you can use multiple '--cal' arguments on the
                             command line

  --details                show all event details (i.e. length, location,
                           reminders, contents)

  --ignore-started         ignore old or already started events
                           - when used with the 'agenda' command, ignore events
                             that have already started and are in-progress with
                             respect to the specified [start] time
                           - when used with the 'search' command, ignore events
                             that have already occurred and only show future
                             events

  --width                  the number of characters to use for each column in
                           the 'cal' command output (default is 10)

  --nc                     don't use colors

  --cal-owner-color        specify the colors used for the calendars and dates
  --cal-editor-color       each of these argument requires a <color> argument
  --cal-contributor-color  which must be one of [ default, black, brightblack,
  --cal-read-color         red, brightred, green, brightgreen, yellow,
  --cal-freebusy-color     brightyellow, blue, brightblue, magenta,
  --date-color             brightmagenta, cyan, brightcyan, white,
  --border-color           brightwhite ]

 Commands:

  list                     list all calendars

  search <text>            search for events
                           - only matches whole words

  agenda [start] [end]     get an agenda for a time period
                           - start time default is 12am today
                           - end time default is 5 days from start
                           - example time strings:
                              '9/24/2007'
                              'Sep 24 2007 3:30pm'
                              '2007-09-24T15:30'
                              '2007-09-24T15:30-8:00'
                              '20070924T15'
                              '8am'

  calw <weeks> [start]     get a week based agenda in a nice calendar format
                           - weeks is the number of weeks to display
                           - start time default is beginning of this week
                           - note that all events for the week(s) are displayed

  calm [start]             get a month agenda in a nice calendar format
                           - start time default is the beginning of this month
                           - note that all events for the month are displayed
                             and only one month will be displayed

  quick <text>             quick add an event to default calendar
                           - example:
                              'Dinner with Eric 7pm tomorrow'
                              '5pm 10/31 Trick or Treat'

  remind <mins> <command>  execute command if event occurs within <mins>
                           minutes time ('%s' in <command> is replaced with
                           event start time and title text)
                           - <minutes> default is 10
                           - default command:
                              'gxmessage -display :0 -center \
                                         -title "Ding, Ding, Ding!" %s'

Comment by zigford, Oct 02, 2007

On Mac OS X, I also had to install the "elementtree" python module I used 1.2.6 (http://effbot.org/media/downloads/elementtree-1.2.6-20050316.tar.gz)

Comment by leraule, Oct 02, 2007

I want to use this program but pleas explain with details how to install it and make it work, im a noob at command prompt!

Comment by Quazie, Oct 02, 2007

How can I get this to work with geektools?

Comment by zigford, Oct 03, 2007

Download the python modules required, extract them and then run the following command for each module: python setup.py install

Comment by ross.campbell, Oct 09, 2007

It appears that gcalcli doesn't work through a proxy. I set HTTP_PROXY, http_proxy , and get a failed to authenticate error

Comment by insanum, Oct 10, 2007

I don't know why the proxy stuff doesn't work for you. I've tested http proxy against my corporate firewall/proxyserver and against 'tinyproxy' running on a server I have on the net. Setting the appropriate environment variables worked.

Note that the http proxy stuff is within the python gdata library. If you continue to have problems you should contact the developers at: http://code.google.com/p/gdata-python-client/

Comment by Nitro82282, Oct 21, 2007

It would be nice if the user could select the first week day. I'm Italian, and like most european countries we start counting weekdays from Monday.

Comment by drlelong, Oct 23, 2007

I keep getting the following error:

Error: Failed to authenticate with Google Calendar!

I've entered my Google username and password in the .gcalclirc file. Is there any way to see a more verbose error message?

Comment by apersonary, Oct 25, 2007

I can get gcalcli to work in a terminal, but when I copy and paste the command above to my conkyrc file it doesn't work.

Comment by nianderson, Oct 31, 2007

I can not seem to get gcalcli working. gcalcli --user nianderson --pw password list Traceback (most recent call last):

File "/home/cmdln/bin/gcalcli", line 1114, in ?
DoooooItHippieMonster?()
File "/home/cmdln/bin/gcalcli", line 1025, in DoooooItHippieMonster?
borderColor=borderColor)
File "/home/cmdln/bin/gcalcli", line 303, in init
self.allCals = self.gcal.GetAllCalendarsFeed?()
AttributeError?: 'CalendarService?' object has no attribute 'GetAllCalendarsFeed?'

Comment by nianderson, Oct 31, 2007

nm i had an old version of gdata python module. updating does the trick

Comment by liquidSmoke, Nov 23, 2007

is there any chance this app can be precompiled to a .exe file and just run it using command line switches? I really dont want to download what seems like 3-4 different things and try to figure out how to set it all up.

Comment by abhishekrsingh, Nov 27, 2007

Feature request: how do I add event to a non default calendar?

Comment by jbarbero, Nov 28, 2007

Even examples to use in screen! I love you, this fits my workflow so well!

Comment by PatrickBlume, Dec 01, 2007

When using the "quick" option I can only add dates today. The time is interpreted correctly, but the date ist just added to the date description. Example:

python gcalcli quick '8pm 12/04/2007 HSK'

will produce a date TODAY like: Sun Dec 02 8:00pm 12/04/2007 HSK

why is that? How can I get that right? Cheers, Paddy

Comment by abhishekrsingh, Dec 12, 2007

PatrickBlume?, try using "HSK 12/4 at 8 pm"

Comment by invernizzi.l, Dec 17, 2007

Thank you for this magnificent program.

Comment by nelhage, Feb 01, 2008

I get a

Error: Failed to authenticate with Google Calendar!'

As well. I've configured my .gcalclirc. Any suggestions?

Comment by nelhage, Feb 01, 2008

Hmm. Some digging revealed I was getting a `CaptchaRequired?' exception. Going to https://www.google.com/accounts/DisplayUnlockCaptcha and submitting that form fixed it.

Comment by kwojas, Feb 04, 2008

I get this error message (with any command basically):

$ gcalcli calm
Traceback (most recent call last):
  File "/home/wojas/bin/gcalcli", line 1114, in ?
    DoooooItHippieMonster()
  File "/home/wojas/bin/gcalcli", line 1025, in DoooooItHippieMonster
    borderColor=borderColor)
  File "/home/wojas/bin/gcalcli", line 303, in __init__
    self.allCals = self.gcal.GetAllCalendarsFeed()
  File "build/bdist.linux-i686/egg/gdata/calendar/service.py", line 77, in GetAllCalendarsFeed
  File "build/bdist.linux-i686/egg/gdata/service.py", line 512, in Get
  File "build/bdist.linux-i686/egg/gdata/service.py", line 493, in Get
  File "/usr/lib/python2.4/site-packages/PIL/__init__.py", line 381, in GDataFeedFromString

  File "/usr/lib/python2.4/site-packages/PIL/__init__.py", line 94, in CreateClassFromXMLString

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 9475: ordinal not in range(128)
Comment by f...@intoxicatedmind.net, Feb 21, 2008

Storing my password in clear text in the config scares me - isn't there a way to use a (md5/sha1/younameit) hash?

Comment by bread.short, Mar 25, 2008

2 ross.campbell : try set evn.variable https_proxy, like this: export https_proxy="http://192.168.0.1:8081"

Comment by bread.short, Mar 25, 2008

And question: how to set quick reminder for other days, not only for today?

Comment by mikko.kenttala, Apr 08, 2008

I had almost same probelm with kwojas. I changed my calendar name to blah and it start to work. Old name include letter "รค" so I quess it's some sort of character encoding problem.

Comment by walshbj, Apr 18, 2008

What are people doing to secure their password using gcalcli on the Internet? Is it sent in the clear? Also, how do you secure it in the rc file on your computer?

Comment by bma+goo...@subvert.org.uk, Apr 25, 2008

As far as encrypting a password goes: there's no way to decrypt it that won't be trivially decryptable, unless you want to provide a password every time you log in - in which case, why bother storing the password at all.

If the machine you're on is reasonably secure, 600 permissions should be fine.

Comment by insanum, May 21, 2008

You can't use md5/sha1/younameit to store your password because those are one way algorithms. There would be no way to get your original password from that text. I store it the config file and ensure the permissions are 600. This is common as many other programs do the same thing (i.e. mutt, msmtp, get/fetchmail come to mind). I've heard a request to add support for gnome-keyring... quick answer, no way.

Comment by penelope.leach, Jun 26, 2008

is this caching the data somewhere in something like .ics? it would be nice to be able to specify how often to actually go fetch the data from google's servers, rather than doing it every time (especially on a laptop when I'm working offline!)

also being able to fetch from google and dump to ics would be useful for things like syncing with a phone, although I see there's a separate project for doing that (http://www.gcalsync.com/)

Comment by jaron.hendrix, Jun 26, 2008

How can I get rid of all the control characters showing up in the output? (Visa user)

They make the output completely unusable.

Example: ESC?[0m;37m+------------+--------------+ That's what the first line of a "calm" calendar looks like both in the console, and in a textfile opened in Notepad++. I tried swapping between different n*x formats, mac format, windows, etc, different encodings for viewing the file itself, but it had no impact.

Comment by jaron.hendrix, Jun 26, 2008

Edit to the above: Vista user

Comment by h3L93.ph1l1pp, Jun 26, 2008

I also have the "UnicodeDecodeError??" as some people above had. Unfortunately, I don't even have an umlaut in my calendar's name, only a space. I've changed that, created a brand new calendar to test and still the same unicode error. I have also applied the patch in the issues database, but to no avail.

Any hints? Running gcalcli with python 2.5 on OSX.

Comment by daz-goo...@zzzurn.com, Jun 27, 2008

@ Jaron.hendrix: Add the switch "--nc" which is for "no colors". The ESC?[3 is for terminal color codes.

Darryl

Comment by maxiangjiang, Jun 29, 2008

cool

Comment by mjhoffmann, Jul 22 (3 days ago)

I had trouble to get the quick add function to work, when I found that google only makes this available if you change the language on the calendar to English. Otherwise it only interpretes the time and adds it within the next 24h.

Comment by courtney.gibbons, Jul 23 (2 days ago)

I keep running into the error:

Error: failed to parse start time

Any help?


Sign in to add a comment