![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
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
IMPORTANT NEWS All the script packages have now been copied into the Conky Hardcore PPA. Any package updates will be provided by the team through this new ppa. The ppa can be found here: https://launchpad.net/~conkyhardcore/+archive/ppa To use this ppa first delete the old ppa files using this: Code:
sudo rm /etc/apt/sources.list.d/m-buck* __________________________________________________ __________________________________________________ ______________________________ 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
There is a README with the install and attached here, I suggest you give it atleast a quick once over! Hope some of you find it useful Any suggestions, please speak up! Basic Install Method 1: Using apt 1) Create the necessary list file for access to the repository by running one of these. Karmic Koala: Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-karmic.list -O /etc/apt/sources.list.d/conkyhardcore-karmic.list Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-jaunty.list -O /etc/apt/sources.list.d/conkyhardcore-jaunty.list Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-intrepid.list -O /etc/apt/sources.list.d/conkyhardcore-intrepid.list Code:
sudo wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-hardy.list -O /etc/apt/sources.list.d/conkyhardcore-hardy.list Code:
wget -q http://www.kaivalagi.com/ubuntu/ppa/conkyhardcore-key.gpg -O- | sudo apt-key add - Code:
sudo apt-get update && sudo apt-get install conkygooglecalendar Download and run the attached .deb file 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 attached tar.gz file to an appropriate folder, and edit the conkyEmail script to point to the correct location where conkyEmail.py is. 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:
python ~/.scripts/conkyGoogleCalendar.py -h Code:
python ~/.scripts/conkyGoogleCalendar.py --help 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 for login
-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], [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: 10] 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.
The important thing to note now is that the script is called using this in Conky: Code:
{execi 1800 conkyGoogleCalendar ...options...}
Code:
{execi 1800 python /path/to/file/conkyGoogleCalendar.py ...options...}
Notes On Script Config Values The conkyGoogleCalendar.py script has one config value worthy of a mention. As descriptions can be long there is a limit to the amount output to conky, this is set by the following, which can be increased/reduced if so desired. Code:
MAX_WIDTH = 47 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 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/~m-buck/+...googlecalendar All packages available from me can be found here: https://launchpad.net/~conkyhardcore/+archive/ppa I have also created a new website, for now it is relatively sparse, but it does details my conky scripts to a certain degree. You can find it here: http://www.kaivalagi.com
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA Last edited by kaivalagi; 4 Weeks Ago at 06:09 AM.. Reason: Updated, see dev history |
|
|
|
|
|
#2 |
|
Gee! These Aren't Roasted!
![]() |
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 | Stargate Wars | HP Laptop 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 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Sep 2007
Location: 34°35'S - 58°21'W
My beans are 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 20th, 2008 at 10:05 PM.. |
|
|
|
|
|
#4 |
|
A Carafe of Ubuntu
![]() Join Date: Oct 2007
Beans: 134
|
Re: Conky Google Calendar Python Script
Sounds cool. Could you post a screenshot?
|
|
|
|
|
|
#5 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
Re: Conky Google Calendar Python Script
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
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA Last edited by kaivalagi; June 22nd, 2008 at 05:16 PM.. Reason: Updated script to fix event display order |
|
|
|
|
|
#6 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
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.
Cheers
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA |
|
|
|
|
|
#7 |
|
Gee! These Aren't Roasted!
![]() |
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 | Stargate Wars | HP Laptop 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 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Feb 2008
Location: 52°38'41.6"N/1°19'43.6"E
Beans: 1,916
|
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:
Cheers, Mark
__________________
Switched to Arch
Apps:gtk-desktop-info Conky:Conky Guide|My Conky Scripts Sites:Kaivalagi.com|AUR| PPA |
|
|
|
|
|
#9 |
|
Gee! These Aren't Roasted!
![]() |
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 | Stargate Wars | HP Laptop 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 |
|
100% Pure Ubuntu
![]() |
Re: Conky Google Calendar Python Script
Quite nice. Do you think it will be possible to align things left and right?
|
|
|
|
| Bookmarks |
| Tags |
| calendar, conky, gdata, google, python |
| Thread Tools | |
| Display Modes | |
|
|