Results 1 to 10 of 467

Thread: Conky Google Calendar Python Script

Hybrid View

  1. #1
    Join Date
    Feb 2008

    Conky Google Calendar Python Script

    ArchLinux : Package support is present in the AUR. All my packages can be seen here:

    Ubuntu/Debian : All the script packages have now been copied into the Conky Companions PPA. Any package updates will be provided by the team through this new ppa. The ppa can be found here: To use this ppa first delete the old ppa files using this:
    sudo rm /etc/apt/sources.list.d/m-buck* && sudo rm /etc/apt/sources.list.d/conkyhardcore*
    Then follow the modified first post instructions for the scripts


    Following on from my conkyForecast script, I've created another which may be useful to you conky users out there. can be found here ->

    I have put together this python script to output Google Calendar events from a users default calendar, for use in Conky. I know there are already other means to do this using the command line, however I wanted something I could modify a little more, and will no doubt do so as and when I or you come up with new ideas.

    Some key features
    • Utilises the Google Calendar API.
    • Supports the use of a template to define the layout of each event output
    • Supports regional datetime formats, by way of system locales
    • Optional event limit so you can reduce the total output in Conky if you have lot's of events, events should be returned earliest first (needs testing)

    There is a README with the install, I suggest you give it atleast a quick once over! It can be found in the installation folder, normally following the path of /usr/share/conky<scriptname>/

    Hope some of you find it useful

    Any suggestions, please speak up!

    Basic Install

    Method 1: Using apt

    1) Add the repository to your OS install:
    sudo add-apt-repository ppa:conky-companions/ppa
    * Note if you are running 9.10 or below then refer to the PPA link at the end of this post for help on installing from the ppa, good guidance can be found on the launchpad site

    2) Now that is done simply run the following to update your repo cache and install the script:

    sudo apt-get update && sudo apt-get install conkygooglecalendar
    Method 2: Using deb file

    Run the .deb file available at the Conky Companions PPA site here:

    Warning, this will not ensure you are kept up-to-date. Only method 1 will do that ;)

    Method 3: Using tar.gz file

    Extract all the contents of the tar.gz file to an appropriate folder, and edit the conkyGoogleCalendar script to point to the correct location where is. The tar.gz file is available at the Conky Companions PPA site here:

    Unless you are using a non-Debian based OS I don't suggest this. Users of Debian/Ubuntu flavour OS's should ideally use method 1.

    Again will will not receive updates using this method. ONLY method 1 can do this for you ;) ;)

    All further details on setup are orientated around the deb package based install, so may differ from what you choose your setup to be, if done using the tarball.

    Usage Help

    You can get the current help options at any time by running (change the path as necessary):

    conkyGoogleCalendar -h

    conkyGoogleCalendar --help
    The usage is as follows:

    Usage: conkyGoogleCalendar [options]
      -h, --help            show this help message and exit
      -u USERNAME, --username=USERNAME
                            Username for login into Google Calendar, this will
                            normally be your gmail account
      -p PASSWORD, --password=PASSWORD
                            Password to login with, if not set the username is
                            used to fetch a 'conky' password from the keyring
      -r TEXT, --requestCalendarNames=TEXT
                            Define a list of calendars to request event data for,
                            calendar names should be separated by semi-colons ";".
                            For example --requestCalendarNames="cal1;cal2;other
                            cal" If not set all calendar data will be returned.
      -d NUMBER, --daysahead=NUMBER
                            [default: 7] Define the number of days ahead you wish
                            to retrieve calendar entries for, starting from today.
      -s DATE, --startdate=DATE
                            Define the start date to retrieve calendar events. In
                            the form '2007-12-01'
      -e DATE, --enddate=DATE
                            Define the end date to retrieve calendar events, must
                            be supplied if --startdate supplied. In the form
      -a, --allevents       Retrieve all calendar events
      -w TEXT, --wordsearch=TEXT
                            Define the text to search calendar entries with.
      -l NUMBER, --limit=NUMBER
                            [default: 0] Define the maximum number of calendar
                            events to display, zero means no limit.
      -t FILE, --template=FILE
                            Template file determining the format for each event.
                            Use the following placeholders: [title], [starttime],
                            [endtime], [completetime], [duration], [location],
                            [description], [who]. Ensure only one placeholder per
                            line, as the whole line is removed if no data for that
                            placeholder exists.
      -f "DATEFORMAT", --dateformat="DATEFORMAT"
                            If used this overrides the default date formatting.
                            The values to use are standard formatting strings e.g.
                            Weekday=%a, Day=%d, Month=%m, Year=%y. For an output
                            like "Thu 15/10/2008" you would require
                            --dateformat="%a %d/%m/%y", to have no date you would
                            require --dateformat=""
      -F "TIMEFORMAT", --timeformat="TIMEFORMAT"
                            If used this overrides the default time formatting.
                            The values to use are standard formatting strings e.g.
                            Hours (12hr)=%l, Hours (24hr)=%H, Minutes=%M,
                            Seconds=%S, AM/PM=%P. For an output like "05:22 PM"
                            you would require --timeformat="%l:%M %P",
                            --timeformat="" is not supported, default locale
                            settings are used
      -i NUMBER, --indent=NUMBER
                            [default: 0] Define the number of spaces to indent the
                            output (excludes template based output)
      -m NUMBER, --maxwidth=NUMBER
                            [default: 40] Define the number of characters to
                            output per line
      -n, --nowho           Hides who is attending the events (excludes template
                            based output)
      -c NUMBER, --connectiontimeout=NUMBER
                            [default: 30] Define the number of seconds before a
                            connection timeout can occur.
      -v, --verbose         Request verbose output, no a good idea when running
                            through conky!
      -V, --version         Displays the version of the script.
      --errorlogfile=FILE   If a filepath is set, the script appends errors to the
      --infologfile=FILE    If a filepath is set, the script appends info to the

    Truncated Output
    Conky has a default limitation of 128 bytes for any text output from a variable (such as execi). If you are creating large templates with more characters than the default buffer size can handle, the output will get truncated. If this happens you can override the default behaviour by setting as new buffer size at the top of your conkyrc file, as follows:
    text_buffer_size 512
    Captcha Issue
    The Google calendar function can stop working for with a "GoogleCalendarEngine Initialisation:Unexpected error:Captcha Required" error message. This is something Google enforces and to overcome it simple authenticate yourself here:

    Locale and unicode support
    If you receive something similar to this error "ERROR: writeOutput:Unexpected error:'ascii' codec can't decode byte 0xc3 in position 14: ordinal not in range(128)" it is because the script can't handle your locale settings for output.
    To overcome this add the following above TEXT in your conkyrc:
    override_utf8_locale yes
    Development History

    Development history going forwards can be seen here
    All packages available from me can be found here:
    Attached Images Attached Images
    Last edited by kaivalagi; March 18th, 2011 at 03:51 PM. Reason: Updated, see dev history

  2. #2
    Join Date
    Feb 2008
    N of Bruce W of Kaivalagi
    Ubuntu 10.10 Maverick Meerkat

    Re: Conky Google Calendar Python Script

    more conky stuff to play with!!

    soon my whole desktop is going to be full of conky output
    keep up the good work kaivalagi

    Hippy | This is the first age that's paid much attention to the future, which is alittle ironic since we may not have one. -- Arthur Clarke

  3. #3
    Join Date
    Sep 2007

    Re: Conky Google Calendar Python Script

    Oh oh ... I don't use Google Calendar but may have to start.
    Gotta go check it out now.

    Good stuff kaivalagi, if this is half as good as your weather script it'll be very popular among the Google Calendar users.

    Have a good day.

    EDIT: I'm a user now.
    Last edited by Bruce M.; October 21st, 2008 at 03:05 AM.

  4. #4
    Join Date
    Oct 2007

    Re: Conky Google Calendar Python Script

    Sounds cool. Could you post a screenshot?

  5. #5
    Join Date
    Feb 2008

    Re: Conky Google Calendar Python Script

    Quote Originally Posted by pmaconi View Post
    Sounds cool. Could you post a screenshot?
    Screenshot added to the first post...

    Edit: Noticed the first problem, events were not listed in date order...the google api must provide the events in the order they were created...Added a compare function to data class and sorted lists, earliest starttime first. Updated the first post
    Last edited by kaivalagi; June 22nd, 2008 at 10:16 PM. Reason: Updated script to fix event display order

  6. #6
    Join Date
    Feb 2008

    Re: Conky Google Calendar Python Script


    Just a couple of things done.

    I have made sure that when using the --daysahead option to retrieve upcoming events, that no events are added that are from before the current datetime. Previously events from earlier the same day where also being output, this really isn't necessary as they're in the past.

    I have also added an --indent option which when used will indent by how ever many spaces are specified. This doesn't work with the template option as spaces can be applied there instead.

    • 23/06/2008 Modified to only display current events (--daysahead option) that start after now
    • 23/06/2008 Added --indent option to add spaces to the front of each line that is output (excludes template output)


Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts