Page 1 of 47 12311 ... LastLast
Results 1 to 10 of 467

Thread: Conky Google Calendar Python Script

  1. #1
    Join Date
    Feb 2008
    Location
    52°38'41.6"N/1°19'43.6"E
    Beans
    Hidden!

    Conky Google Calendar Python Script

    ArchLinux : Package support is present in the AUR. All my packages can be seen here: http://aur.archlinux.org/packages.php?SeB=m&K=kaivalagi

    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: https://launchpad.net/~conky-companions/+archive/ppa. To use this ppa first delete the old ppa files using this:
    Code:
    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


    Intro

    Following on from my conkyForecast script, I've created another which may be useful to you conky users out there. conkyForecast.py can be found here -> http://ubuntuforums.org/showthread.php?p=5452132

    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:
    Code:
    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:

    Code:
    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: https://launchpad.net/~conky-compani.../ppa/+packages

    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 conkyGoogleCalendar.py is. The tar.gz file is available at the Conky Companions PPA site here: https://launchpad.net/~conky-compani.../ppa/+packages

    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):

    Code:
    conkyGoogleCalendar -h
    or

    Code:
    conkyGoogleCalendar --help
    The usage is as follows:

    Code:
    Usage: conkyGoogleCalendar [options]
    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
                            '2007-12-01'
      -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
                            filepath.
      --infologfile=FILE    If a filepath is set, the script appends info to the
                            filepath.
    Gotchas

    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:
    Code:
    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: https://www.google.com/accounts/UnlockCaptcha

    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:
    Code:
    override_utf8_locale yes
    Development History

    Development history going forwards can be seen here https://code.launchpad.net/~conky-companions/+junk/conkygooglecalendar
    All packages available from me can be found here: https://launchpad.net/~conky-companions/+archive/ppa
    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
    Location
    N of Bruce W of Kaivalagi
    Beans
    185
    Distro
    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
    hippyrandall.com | 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
    Bruce M. is offline Chocolate Ubuntu Mocha Blend
    Join Date
    Sep 2007
    Beans
    Hidden!

    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.
    Bruce

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

  4. #4
    Join Date
    Oct 2007
    Beans
    135

    Re: Conky Google Calendar Python Script

    Sounds cool. Could you post a screenshot?

  5. #5
    Join Date
    Feb 2008
    Location
    52°38'41.6"N/1°19'43.6"E
    Beans
    Hidden!

    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
    Location
    52°38'41.6"N/1°19'43.6"E
    Beans
    Hidden!

    Re: Conky Google Calendar Python Script

    UPDATE

    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)


    Cheers

  7. #7
    Join Date
    Feb 2008
    Location
    N of Bruce W of Kaivalagi
    Beans
    185
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Conky Google Calendar Python Script

    now I am going to have to start getting organized and actually putting stuff on my gcalendar...boll ox (forums edit out the correct spelling)


    Hippy
    hippyrandall.com | 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

  8. #8
    Join Date
    Feb 2008
    Location
    52°38'41.6"N/1°19'43.6"E
    Beans
    Hidden!

    Re: Conky Google Calendar Python Script

    Guess what.....UPDATE

    Done quite a bit more tonight, we now have details on who is attending the events by way of email addresses. This can also be turned off using a new --nowho option. I have also fixed up the template functionality to remove unwanted whitespace only lines from the output, for situations where not all the data is available for an event.

    Also done a general tidy up of the code, and put in some tweaks to make event listings generally more sensible, including having re-occuring events treated like multiple single events.

    What went onto the dev history:
    • 24/06/2008 Added who is attending (email addresses) to the output of each event, added a <who> parameter for the template, and added a --nowho option to hide the data (excludes template output)
    • 24/06/2008 Fixed up template output using regex, to remove unnecessary blank lines where no data exists


    Cheers,
    Mark

  9. #9
    Join Date
    Feb 2008
    Location
    N of Bruce W of Kaivalagi
    Beans
    185
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Conky Google Calendar Python Script

    You've been busy! Nice additions. I am in the process of adding events to my calendar to test some of this stuff out.
    Keep coming with the new ideas!

    Hippy
    hippyrandall.com | 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

  10. #10
    Join Date
    May 2007
    Location
    Washington
    Beans
    909

    Re: Conky Google Calendar Python Script

    Quite nice. Do you think it will be possible to align things left and right?

Page 1 of 47 12311 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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