SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#26 2012-05-11 19:19:57

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: display icalendar file events in conky - v2.5.1

ZlyChleba wrote:

My desktop with conky + your excellent script smile
evolutionconky.jpg

Thanks for posting a screenshot.

Last edited by arclance (2012-05-11 20:23:12)

Offline

Be excellent to each other!

#27 2012-05-11 22:09:45

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: display icalendar file events in conky - v2.5.1

That's one awesome script arclance.

Someday - maybe - in my next life - I'll be able to do that.

Last edited by Sector11 (2012-05-11 22:10:44)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#28 2012-05-12 02:53:38

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: display icalendar file events in conky - v2.5.1

Sector11 wrote:

That's one awesome script arclance.

Someday - maybe - in my next life - I'll be able to do that.

Thanks.
Here is a preview of what I am working on now.
conky_ical_2_three_calendars.png
Calendars for more than one month.

Offline

#29 2012-06-17 16:15:49

VastOne
#! Ranger
From: V-Ger
Registered: 2011-04-26
Posts: 10,165
Website

Re: display icalendar file events in conky - v2.5.1

Very nice How To arclance!   cool

Added to Quick References


VSIDO | Words That Build Or Destroy

I dev VSIDO

Offline

#30 2012-07-13 20:13:03

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: display icalendar file events in conky - v2.5.1

@VastOne
Thank you for adding it to the list.
You might also want to look at my new guide for building conky from source.

Progress Update
I have started migrating the display of the output of the script to use lua instead of ${execp}.

This uses slightly less cpu power both in the python script and in conky.

It also improves the alignment of calendar elements since they can be calculated exactly in a lua script and only guessed at in the python script.

The three calendar output proved to be too difficult to make usable in a conky other than my own when draw by ${execp}.
It would have required extensive user adjustment of the script to make it work and the lua migration eliminates this issue.

The lua three calendar version also uses far fewer lines of code making it much easier to maintain.

Using ${execp}          Using Lua
338 lines of python     86 lines of python
                        49 lines of lua
Total Lines: 338        Total Lines: 135

The appointment list and three calendar output have been migrated to lua display and currently being checked for bugs.

The lua scripts only support shaded text for now, the final version will also support non-shaded text.

I plan to make one calendar function that is able to output a user defined number of months starting at a user defined month relative to the current month.

I will only provide support for lua scripts displaying up to three months tiled horizontally.

More complicated tiling and a larger number of calendars will be possible but it it is up to the user to write lua scripts to display the data in that way.

For anyone interested in the code that I have so far I will post it below since it will not fit in this post.

Offline

#31 2012-07-13 20:15:56

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: display icalendar file events in conky - v2.5.1

I will post a link to the abandoned ${execp} code for three calendar output later.
It is larger than the post size limit here.

New Beta Code For Lua Display

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
"""
Name: conky_icalendar_2.py
Author: arclance
Date_Created:2012-01-10
Date_Updated:2012-07-13
    
Reads the evolution calendar(or another ical calendar) using calcurse and format the output for display in conky.
Does not work with recurring appointments yet (need to write appointment sorting function first).

Requires
    icalendar python package v3.0 or higher | http://pypi.python.org/pypi/icalendar/3.0.1b2#downloads
    time
    calendar
    ####subprocess

Changelog
v3.1 2012-07-13
    Remove old non lua code, the old three calendar code was not portable to other systems.

v3.0 2012-07-12
    begin adding output for dispaly with lua script
    update time_until to use epoch time it is more accurate and works with appointments that start and end on different days

v2.X.0 2012-05-11 to 2012-05-22
    allow for calendar to use font other than default font
    add countdown color change for appointments that have not ended yet
    made countdown colors easier to change
    2012-05-14
    added support for exceptions for WEEKLY recurring events (days in the reccurance pattern when an event does not occur)
    2012-05-22
    use calendar module instead of cal to get raw calendars
    added support for exceptions for DAILY recurring events (days in the reccurance pattern when an event does not occur)
    fix exception handling for events with only one exception
    added support for exceptions for YEARLY recurring events (days in the reccurance pattern when an event does not occur)
    2012-06-01
    fix highlighting of single digit days in new script
    
    Beta of three calendar output
        fix month offset adjustment (now works across multiple years)
        finish Month-Year header alignment for each month (will only work with a font with the same character width as DejaVu Sans Mono:size=10)
        2012-05-14
        fix alignment for multiple calendars

v2.6.0 2012-05-11 to 2012-05-12
    fix highlighting of current day if there is no appointment
    improve alignment of calendar columns
    remove extra color changes from calendar (small cpu use decrease for conky)
    
v2.5.2 2012-05-11
    improve handling of YEARLY recurring events (allow for leap years)

v2.5.1 2012-05-11
    fix for displaying non-ascii characters in conky (worked in terminal before this makes it work in conky)

v2.5 2012-05-10
    Add support for DAILY, WEEKLY, and YEARLY recurring events

v2.0 2012-05-09
    replace calcurse with icalendar python module
    rewrite appointment display
    fixed to12Hour (12 PM was showed as 12 AM | 12 AM would have been displayed as 00 AM)
    - 2012-05-10 -
    rewrite calendar display
        fixed entry duplication bug in appointmentDates
"""

import time
#from subprocess import Popen, PIPE
from icalendar.cal import Calendar, Event
from icalendar.prop import vDatetime, vDDDTypes, vDDDLists
import calendar

#### user defined variables ####
daysToDisplay = 3 # number of days to display appointments for
icalendarPath = '~/.local/share/evolution/calendar/system/calendar.ics' # location of ics format calendar file, default is the loctaion for evolution but files from other programs should work but are untested
#calendarFont = "DejaVu Sans Mono:size=10" # must be a monospace font (character width must be the same as DejaVu Sans Mono:size=10 for three calendar output to work correctly)
usingDefaultFont = True # if the calendar font is the same as the default font in your .conkyrc set this to True for cpu power savings
#defaultColor = "${color}"
defaultColor_Lua = "{color0_R,color0_G,color0_B,color0_A}"
#color0 = "${color0}"
color0_Lua = "{color1_R,color1_G,color1_B,color1_A}"
usingShading = True # Set to True if using draw_shades yes
#defaultShadeColor = "${shadecolor 8B0000}"
defaultShadeColor_Lua = "{color3_R,color3_G,color3_B,color3_A}"
#secondaryShadeColor = "${shadecolor 000000}"
secondaryShadeColor_Lua = "{0,0,0,1}"
conkyWidth = 619 # width of conky in pixels | use with a fixed width conky
##### Countdown Colors
#currentApptColor = "A500FF"
currentApptColor_Lua = "{" + str(float(165)/float(255)) + ",0,1,1}"
#_30minToApptColor = "EE0000"
_30minToApptColor_Lua = "{color6_R,color6_G,color6_B,color6_A}"
#_90minToApptColor = "FF8000"
_90minToApptColor_Lua = "{color7_R,color7_G,color7_B,color7_A}"
#_150minToApptColor = "EEEE00"
_150minToApptColor_Lua = "{color8_R,color8_G,color8_B,color8_A}"
#_240minToApptColor = "006400"
_240minToApptColor_Lua = "{0," + str(float(100)/float(255)) + ",0,1}"
#####
#### end user defined variables ####

def to12Hour(inputTime):
    Hour = int(inputTime.split(":")[0])
    Minute = int(inputTime.split(":")[1])
    if Hour >= 12: # check for 24 hour format
        if Hour > 12:
            Hour = (Hour - 12) # make 12 hour format
        #endif
        _12HourTime = str(Hour).rjust(2, "0") + ':' + str(Minute).rjust(2, "0") + ' PM' # make sunset time string
    else:
        if Hour == 0:
            Hour = 12
        #endif
        _12HourTime = str(Hour).rjust(2, "0") + ':' + str(Minute).rjust(2, "0") + ' AM' # make sunset time string
    #endif
    return _12HourTime
#enddef    

def timeUntil_Epoch_Lua(secondsFromTimeZero, secondsFromTimeZero_End, dayHappens):
    secondsSinceTimeZero = time.time()    # calculate seconds since the start of today
    if secondsSinceTimeZero > secondsFromTimeZero: # event has already ocurred
        secondsLeft = - secondsFromTimeZero + secondsSinceTimeZero # calculate seconds until the event
        hoursLeft = secondsLeft / 3600 # get hours left
        minutesLeft = (secondsLeft % 3600) / 60 # get minutes left
        hoursLeft = int(hoursLeft)
        minutesLeft = int(minutesLeft)
        if secondsSinceTimeZero < secondsFromTimeZero_End: # Change Color Of Countdown if event has not ended yet
            if usingShading == True:
                timeLeft = '{"-' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + currentApptColor_Lua + ',' + secondaryShadeColor_Lua + '}'
            else:
                timeLeft = "${color " + currentApptColor + "}-" + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") # make timeLeft string
                timeLeft = '{"-' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + currentApptColor_Lua + ',""}'
            #endif
        else:
            timeLeft = '{"-' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + defaultColor_Lua + ',' + defaultShadeColor_Lua + '}'
        #endif
    else:
        secondsLeft = secondsFromTimeZero - secondsSinceTimeZero # calculate seconds until the event
        hoursLeft = secondsLeft / 3600 # get hours left
        minutesLeft = (secondsLeft % 3600) / 60 # get minutes left
        hoursLeft = int(hoursLeft)
        minutesLeft = int(minutesLeft)
        if secondsLeft <= (3600*0.5):
            if usingShading == True:
                timeLeft = '{"' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + _30minToApptColor_Lua + ',' + secondaryShadeColor_Lua + '}'
            else:
                timeLeft = '{"' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + _30minToApptColor_Lua + ',""}'
            #endif
        elif secondsLeft <= (3600*1.5):
            timeLeft = '{"' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + _90minToApptColor_Lua + ',' + defaultShadeColor_Lua + '}'
        elif secondsLeft <= (3600*2.5):
            timeLeft = '{"' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + _150minToApptColor_Lua + ',' + defaultShadeColor_Lua + '}'
        elif secondsLeft <= (3600*4):
            if usingShading == True:
                timeLeft = '{"' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + _240minToApptColor_Lua + ',' + secondaryShadeColor_Lua + '}'
            else:
                timeLeft = '{"' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + _240minToApptColor_Lua + ',""}'        
            #endif
        else:    
            timeLeft = '{"' + str(hoursLeft).rjust(2, "0") + ":" + str(minutesLeft).rjust(2, "0") + '",' + defaultColor_Lua + ',' + defaultShadeColor_Lua + '}'
        #endif
    #endif
    return timeLeft
#enddef

##############################

class eventList:
    
    def __init__(self):
        self._listOfEvents = []
        self._daysToDisplay = daysToDisplay
        self._currentTime = time.time()
        self._currentDate = time.strftime('%Y-%m-%d' ,time.localtime(float(self._currentTime)))
        self._currentDateSplit = self._currentDate.split("-")
        self._currentDateSplit[2] = self._currentDateSplit[2].lstrip("0")
        self._currentWeekday = time.strftime('%a' ,time.localtime(float(self._currentTime)))
        self._checkDates = [self._currentDate]
        for i in xrange(self._daysToDisplay - 1):
            self._checkDates.append(time.strftime('%Y-%m-%d' ,time.localtime(float(self._currentTime + float((i + 1)*3600*24)))))
        #endfor
        #### Appointments ####
        self._hrOffset = "${voffset -8}"
        self._dayHeaderOffset = "${voffset -5}"
        self._eventOffset = "${voffset -2}"
        #### Calendar ####
        self._tophrOffset = "${voffset -8}"
        self._monthYearAlignment = "${alignc}${voffset -6}"
        self._monthYearOffset = "${voffset -6}"
        self._bodyAlignment = "${alignc}${voffset -2}"
        self._bodySpaceing = 5
        self._threeCalWidth = 558
    #enddef
    
    def appendSingleEvent(self, newEvent):
        self._listOfEvents.append(newEvent)
    #enddef
    
    def appendReccuringEvent_Weekly(self, startDate, startTime, endDate, endTime, recurDays, recurEndDate, recurCount, typeWeekly, listExceptions, summary): # eventList.appendReccuringEvent_Weekly(eventStartDate, eventStartTime, eventEndDate, eventEndTime, eventRecurDays, eventRecurEndDate, eventSummary)
        # UNTIL=20120518;BYDAY=SA,SU,MO,TU,WE,TH,FR
        #print str(recurEndDate)
        #print type(recurDays[0])
        for i in xrange(len(recurDays)):
            recurDays[i] = str(recurDays[i]).strip().replace("SA","Sat").replace("SU","Sun").replace("MO","Mon").replace("TU","Tue").replace("WE","Wed").replace("TH","Thu").replace("FR","Fri")
        #endfor
        #print str(recurDays)
        if typeWeekly == 1:
            #print len(str(recurEndDate))
            if len(str(recurEndDate)) < 19:
                recurEndDate_Seconds = time.mktime(time.strptime(str(recurEndDate), "%Y-%m-%d"))
            else:
                recurEndDate_Seconds = time.mktime(time.strptime(str(recurEndDate), "%Y-%m-%d %H:%M:%S"))
            #endif
            if recurEndDate_Seconds > self._currentTime: # only calculate recurring events if the reccurance has not ended yet
                #print str(recurEndDate_Seconds)
                numDays = 0
                timeStartSeconds = dateInSeconds(startDate, startTime)
                timeEndSeconds = dateInSeconds(endDate, endTime)
                checkDateSeconds = float(timeStartSeconds + float(numDays*3600*24))
                dayOfWeek = time.strftime('%a' ,time.localtime(checkDateSeconds))
                while checkDateSeconds < recurEndDate_Seconds:
                    #break
                    #print dayOfWeek
                    if (dayOfWeek in recurDays) and (checkDateSeconds not in listExceptions):
                        checkStartDate = time.strftime('%Y-%m-%d',time.localtime(checkDateSeconds))
                        checkEndDate = time.strftime('%Y-%m-%d',time.localtime(float(timeEndSeconds + float(numDays*3600*24))))
                        self._listOfEvents.append([checkDateSeconds, checkStartDate, startTime, checkEndDate, endTime, summary, "WEEKLY"])
                    #endif
                    numDays = numDays + 1
                    checkDateSeconds = float(timeStartSeconds + float(numDays*3600*24))
                    dayOfWeek = time.strftime('%a' ,time.localtime(checkDateSeconds))
                #endwhile
                #pass
            #endif
        elif typeWeekly == 2:
            #print recurCount[0]
            numOccurances = 0
            numDays = 0
            timeStartSeconds = dateInSeconds(startDate, startTime)
            timeEndSeconds = dateInSeconds(endDate, endTime)
            while numOccurances < recurCount[0]:
                #break
                checkDateSeconds = float(timeStartSeconds + float(numDays*3600*24))
                dayOfWeek = time.strftime('%a' ,time.localtime(checkDateSeconds))
                #print dayOfWeek
                if (dayOfWeek in recurDays) and (checkDateSeconds not in listExceptions):
                    checkStartDate = time.strftime('%Y-%m-%d',time.localtime(checkDateSeconds))
                    checkEndDate = time.strftime('%Y-%m-%d',time.localtime(float(timeEndSeconds + float(numDays*3600*24))))
                    self._listOfEvents.append([checkDateSeconds, checkStartDate, startTime, checkEndDate, endTime, summary, "WEEKLY"])
                    numOccurances = numOccurances + 1
                #endif
                numDays = numDays + 1
            #endwhile
        #endif
    #enddef
    
    def appendReccuringEvent_Daily(self, startDate, startTime, endDate, endTime, recurEndDate, recurCount, recurInterval, typeDaily, listExceptions, summary):
        if typeDaily == 1:
            #break
            timeStartSeconds = dateInSeconds(startDate, startTime)
            timeEndSeconds = dateInSeconds(endDate, endTime)
            #print (recurCount[0]*recurInterval[0])
            for i in xrange(0, int(recurCount[0]*recurInterval[0]), recurInterval[0]):
                #break
                #print i
                checkDateSeconds = float(timeStartSeconds + float(i*3600*24))
                checkStartDate = time.strftime('%Y-%m-%d',time.localtime(checkDateSeconds))
                #print checkStartDate
                checkEndDate = time.strftime('%Y-%m-%d',time.localtime(float(timeEndSeconds + float(i*3600*24))))
                if checkDateSeconds not in listExceptions:
                    self._listOfEvents.append([checkDateSeconds, checkStartDate, startTime, checkEndDate, endTime, summary, "DAILY"])
                #endif
            #endfor
        elif typeDaily == 2:
            #break
            timeStartSeconds = dateInSeconds(startDate, startTime)
            timeEndSeconds = dateInSeconds(endDate, endTime)
            for i in xrange(recurCount[0]):
                #break
                checkDateSeconds = float(timeStartSeconds + float(i*3600*24))
                checkStartDate = time.strftime('%Y-%m-%d',time.localtime(checkDateSeconds))
                checkEndDate = time.strftime('%Y-%m-%d',time.localtime(float(timeEndSeconds + float(i*3600*24))))
                if checkDateSeconds not in listExceptions:
                    self._listOfEvents.append([checkDateSeconds, checkStartDate, startTime, checkEndDate, endTime, summary, "DAILY"])
                #endif
            #endfor
        #endif
    #enddef
    
    def appendReccuringEvent_Monthly(self):
        pass
    #enddef
    
    def appendReccuringEvent_Yearly(self, startDate, startTime, endDate, endTime, recurCount, typeYearly, listExceptions, summary):
        if typeYearly == 1:
            startDateSplit = startDate.split("-")
            endDateSplit = endDate.split("-")
            for i in xrange(recurCount[0]):
                #break
                checkStartDate = str(int(startDateSplit[0]) + i) + "-" + startDateSplit[1] + "-" + startDateSplit[2]
                checkEndDate = str(int(endDateSplit[0]) + i) + "-" + endDateSplit[1] + "-" + endDateSplit[2]
                timeStartSeconds = dateInSeconds(checkStartDate, startTime)
                if timeStartSeconds not in listExceptions:
                    self._listOfEvents.append([timeStartSeconds, checkStartDate, startTime, checkEndDate, endTime, summary, "YEARLY"])
                #endif
            #endfor
        #endif
    #enddef
    
    def sortList(self):
        self._sortedList = sorted(self._listOfEvents, key=lambda epoch: int(epoch[0]))
    #enddef
    
    def returnList(self):
        return self._listOfEvents
    #enddef
    
    def returnSortedList(self):
        return self._sortedList
    #enddef
    
    def conkyApts_Lua(self):
        previousDate = ""
        outputString = u"{ " # set outputString to empty String
        firstAppointment = True
        ##print "conkyApts Test"
        for l in xrange(len(self._sortedList)):
            for i in xrange(len(self._checkDates)):
                checkDateString = self._checkDates[i]
                if (str(self._sortedList[l][1]).strip() == checkDateString):
                    ##print "date match"
                    if i == 0: # today
                        if previousDate != self._sortedList[l][1]:
                            dayName = time.strftime('%A' ,time.localtime(float(self._currentTime + float(3600*24*i)))) # get the weekday name
                            #outputString = outputString + self._hrOffset + color0 + "${hr}\n" + self._dayHeaderOffset + defaultColor + "Today (" + dayName + ") " + color0 + "- " + defaultColor + "" + checkDateString #
                            outputString = outputString + '{ {"Today (' + dayName + ')","' + checkDateString + '"}'
                            previousDate = checkDateString
                            firstAppointment = False
                        #endif
                        startTime = self._sortedList[l][2]
                        endTime = self._sortedList[l][4]
                        eventName = self._sortedList[l][5]
                        #outputString = outputString + "\n" + self._eventOffset + "" + color0 + "" + to12Hour(startTime) + " " + defaultColor + "-> " + color0 + "" + to12Hour(endTime) + " |" + defaultColor + "" + timeUntil(startTime, endTime, i) + " " + color0 + "| " + defaultColor + "" + eventName.replace("$","$$") #
                        outputString = outputString + ' , {"' + to12Hour(startTime) + '","' + to12Hour(endTime) + '",' + timeUntil_Epoch_Lua(self._sortedList[l][0], dateInSeconds(self._sortedList[l][3], endTime), i) + ',"' + eventName.replace("$","$$") + '"}'
                    elif i == 1: # tommorow
                        if previousDate != self._sortedList[l][1]:
                            dayName = time.strftime('%A' ,time.localtime(float(self._currentTime + float(3600*24*i)))) # get the weekday name
                            if firstAppointment == True:
                                outputString = outputString + '{ {"Tommorow (' + dayName + ')","' + checkDateString + '"}'
                                firstAppointment = False
                            else:
                                outputString = outputString + ' } , { {"Tommorow (' + dayName + ')","' + checkDateString + '"}'
                            #endif
                            #outputString = outputString + "\n" + self._hrOffset + color0 + "${hr}\n" + self._dayHeaderOffset + defaultColor + "Tommorow (" + dayName + ") " + color0 + "- " + defaultColor + "" + checkDateString #
                            previousDate = checkDateString
                        #endif
                        startTime = self._sortedList[l][2]
                        endTime = self._sortedList[l][4]
                        eventName = self._sortedList[l][5]
                        #outputString = outputString + "\n" + self._eventOffset + "" + color0 + "" + to12Hour(startTime) + " " + defaultColor + "-> " + color0 + "" + to12Hour(endTime) + " |" + defaultColor + "" + timeUntil(startTime, endTime, i) + " " + color0 + "| " + defaultColor + "" + eventName.replace("$","$$") #
                        outputString = outputString + ' , {"' + to12Hour(startTime) + '","' + to12Hour(endTime) + '",' + timeUntil_Epoch_Lua(self._sortedList[l][0], dateInSeconds(self._sortedList[l][3], endTime), i) + ',"' + eventName.replace("$","$$") + '"}'
                    else:
                        if previousDate != self._sortedList[l][1]:
                            dayName = time.strftime('%A' ,time.localtime(float(self._currentTime + float(3600*24*i)))) # get the weekday name
                            #outputString = outputString + "\n" +self._hrOffset + color0 + "${hr}\n" + self._dayHeaderOffset + defaultColor + "" + dayName + " " + color0 + "- " + defaultColor + "" + checkDateString #
                            if firstAppointment == True:
                                outputString = outputString + '{ {"' + dayName + '","' + checkDateString + '"}'
                                firstAppointment = False
                            else:
                                outputString = outputString + ' } , { {"' + dayName + '","' + checkDateString + '"}'
                            #endif
                            previousDate = checkDateString
                        #endif
                        startTime = self._sortedList[l][2]
                        endTime = self._sortedList[l][4]
                        eventName = self._sortedList[l][5]
                        #outputString = outputString + "\n" + self._eventOffset + "" + color0 + "" + to12Hour(startTime) + " " + defaultColor + "-> " + color0 + "" + to12Hour(endTime) + " |" + defaultColor + "" + timeUntil(startTime, endTime, i) + " " + color0 + "| " + defaultColor + "" + eventName.replace("$","$$") #
                        outputString = outputString + ' , {"' + to12Hour(startTime) + '","' + to12Hour(endTime) + '",' + timeUntil_Epoch_Lua(self._sortedList[l][0], dateInSeconds(self._sortedList[l][3], endTime), i) + ',"' + eventName.replace("$","$$") + '"}'
                    #endif    
                #endif    
            #endfor
        #endfor
        if outputString != "{ ":
            return outputString + ' } }'
        else:
            #return self._hrOffset + color0 + "${hr}\n" + self._dayHeaderOffset + defaultColor + "No Events"
            return outputString + '{"No Events"} }'
        #endif
    #enddef
    
    def conkyCalendar_threeMonth_Lua(self, monthOffset):
        calendarList = []
        #lastDateList = []
        appointmentDateList = []
        rawLengthList = []
        isCurrentMonth = []
        numYear = int(self._currentDateSplit[0])
        numMonth = (int(self._currentDateSplit[1]) + monthOffset)
        if numMonth < 1:
            numMonth = 12 - (numMonth + 1)
            numYear = numYear - 1
        elif numMonth > 12:
            numMonth = numMonth - 12
            numYear = numYear + 1
        #endif
        calendar.setfirstweekday(6)
        for i in xrange(3):
            if i != 0 and numMonth == 12:
                numYear = numYear + 1
                numMonth = 1
            elif i != 0:
                numMonth = numMonth + 1
            #endif
            if (numMonth == int(self._currentDateSplit[1])) and (numYear == int(self._currentDateSplit[0])):
                isCurrentMonth.append(True)
            else:
                isCurrentMonth.append(False)
            #endif
            stdout = calendar.month(numYear, numMonth)
            rawcalendar = stdout.strip().strip().split("\n")
            lastDateMonth = rawcalendar[len(rawcalendar) - 1].strip().split(" ")
            #print lastDateMonth
            lastDateMonth = lastDateMonth[len(lastDateMonth) - 1]
            #lastDateList.append(lastDateMonth)
            calendarList.append(rawcalendar)
            appointmentDates = []
            for l in xrange(len(self._sortedList)):
                for j in xrange(1, (int(lastDateMonth) + 1)):
                    checkDateString = str(numYear) + "-" + str(numMonth).rjust(2, "0") + "-" + str(j).rjust(2, "0")
                    if self._sortedList[l][1] == checkDateString and (str(j) not in appointmentDates):
                        appointmentDates.append(str(j))
                    #endif
                #endfor
            #endfor
            appointmentDateList.append(appointmentDates)
        #endfor
        """
        currentYear = self._currentDateSplit[0]
        currentMonth = self._currentDateSplit[1]
        currentDay = self._currentDateSplit[2]
        """
        #print self._currentDateSplit[2]
        #print str(appointmentDates)
        #print str(self._currentDateSplit[2])
        calendarTable = [[],[],[]]
        for i in xrange(3):
            for m in xrange(len(calendarList[i])):
                if m == 0:
                    calendarTable[i].append(calendarList[i][m].strip())
                elif m == 1:
                    calendarTable[i].append(calendarList[i][m].strip())
                elif len(calendarList[i][m].strip()) != 0:
                    #calendarList[i][m] = calendarList[i][m].strip()
                    #currentLineSplit = calendarList[i][m].strip().split(" ")
                    calendarTable[i].append([])
                    for k in xrange(7):
                        nextDate = calendarList[i][m][(k*3):((k*3) + 2)]
                        if nextDate.strip(" ") in appointmentDateList[i]:
                            if (isCurrentMonth[i] == True) and (str(self._currentDateSplit[2]) in appointmentDateList[i]) and (nextDate.strip(" ") == str(self._currentDateSplit[2])):
                                calendarTable[i][m].append([('"' + nextDate + '"'),"Bold",_30minToApptColor_Lua,secondaryShadeColor_Lua])
                            else:
                                calendarTable[i][m].append([('"' + nextDate + '"'),"Normal",color0_Lua,defaultShadeColor_Lua])
                            #endif
                        else:
                            if (isCurrentMonth[i] == True) and (str(self._currentDateSplit[2]) not in appointmentDateList[i]) and (nextDate.strip(" ") == str(self._currentDateSplit[2])):
                                calendarTable[i][m].append([('"' + nextDate + '"'),"Bold",_240minToApptColor_Lua,secondaryShadeColor_Lua])
                            else:
                                calendarTable[i][m].append([('"' + nextDate + '"'),"Normal",defaultColor_Lua,defaultShadeColor_Lua])
                            #endif
                        #endif
                    #endfor
                #endif
            #endfor
        #endfor
        return str(calendarTable).replace("[","{").replace("]","}").replace("'{","{").replace("}'","}").replace("'\"","'").replace("\"'","'")
    #enddef
    
#endclass
    
def dateInSeconds(startDate, startTime):
    timeStruct = time.strptime((startDate + " " + startTime), "%Y-%m-%d %H:%M:%S")
    return time.mktime(timeStruct)
#enddef

def parseTest():
    rawCalendar_ = open(icalendarPath, "rb") # open calendar for reading
    evoCalendar = rawCalendar_.read()
    rawCalendar_.close()
    ####
    #print "importing"
    parsCalendar = Calendar.from_ical(evoCalendar)
    #print "walking"
    eventHolder = eventList()
    for component in parsCalendar.walk('VEVENT'):
        #print component
        #print component.canonical_order
        #print component.name
        eventSummary = component['SUMMARY']
        #print str(compSummary)
        compDTStart = component['DTSTART'].to_ical()
        #print compDTStart
        if compDTStart.find("T") != (-1):
            [eventStartDate, eventStartTime] = str(vDatetime.from_ical(compDTStart)).split(" ")
        else:
            #print "no start time"
            #print str(compDTStart)
            eventStartDate = compDTStart[0:4] + "-" + compDTStart[4:6] + "-" + compDTStart[6:8]
            eventStartTime = "00:00:00"
        #endif
        eventStartSeconds = dateInSeconds(eventStartDate, eventStartTime)
        #print str(eventStartSeconds)
        compDTEnd = component['DTEND'].to_ical()
        if compDTEnd.find("T") != (-1):
            [eventEndDate, eventEndTime] = str(vDatetime.from_ical(compDTEnd)).split(" ")
        else:
            #print "no end time"
            #print str(compDTEnd)
            eventEndDate = compDTEnd[0:4] + "-" + compDTEnd[4:6] + "-" + compDTEnd[6:8]
            eventEndTime = "23:59:59"
        #endif
        try:
            compRRule = component['RRULE']
            #print eventSummary
            #print str(compRRule)
            eventRecurFreq = compRRule['FREQ']
            #print str(eventRecurFreq)
        except Exception, e:
            #print "RRule Error = " + str(e)
            compRRule = "N/A"
        #endtry
        weeklyType = 0
        dailyType = 0
        yearlyType = 0
        if compRRule == "N/A": # Single appointments
            eventHolder.appendSingleEvent([eventStartSeconds, eventStartDate, eventStartTime, eventEndDate, eventEndTime, eventSummary, compRRule])
        elif eventRecurFreq[0] == "WEEKLY": # Weekly reccuring appointments ## RRULE:FREQ=WEEKLY;UNTIL=20111209T040000;BYDAY=MO,WE,FR;COUNT=4
            #print str(eventRecurFreq[0])
            try:
                eventRecurDays = compRRule['BYDAY']
            except Exception, e:
                print "Error Unknown WEEKLY Recurring Appointment Type: " + str(e)
                break
            #endtry
            try: # check for WEEKLY events defined by enddate
                eventRecurEndDate = compRRule['UNTIL'][0]
                weeklyType = 1
                eventRecurCount = "N/A"
            except Exception, e:
                pass
            #endtry
            try: # check for WEEKLY events defined by number of occurances
                eventRecurCount = compRRule['COUNT']
                weeklyType = 2
                eventRecurEndDate = "N/A"
            except Exception, e:
                pass
            #endtry
            try: # Find dates that do not have ocurrances (holidays, canceled classes, ect.)
                eventExceptions = component['EXDATE']
                exceptionsList = []
                try:
                    for i in xrange(len(eventExceptions)):
                        exceptionDateRaw = eventExceptions[i].to_ical()
                        #print str(exceptionDateRaw)
                        if exceptionDateRaw.find("T") != (-1):
                            #print "test"
                            [exceptionDate, exceptionTime] = str(vDatetime.from_ical(exceptionDateRaw)).split(" ")
                        else:
                            exceptionDate = exceptionDateRaw[0:4] + "-" + exceptionDateRaw[4:6] + "-" + exceptionDateRaw[6:8]
                            exceptionTime = eventStartTime
                        #endif
                        exceptionsList.append(dateInSeconds(exceptionDate, exceptionTime))
                    #endfor
                except Exception, e: # only one exception (not put in list)
                    exceptionDateRaw = eventExceptions.to_ical()
                    #print str(exceptionDateRaw)
                    if exceptionDateRaw.find("T") != (-1):
                        #print "test"
                        [exceptionDate, exceptionTime] = str(vDatetime.from_ical(exceptionDateRaw)).split(" ")
                    else:
                        exceptionDate = exceptionDateRaw[0:4] + "-" + exceptionDateRaw[4:6] + "-" + exceptionDateRaw[6:8]
                        exceptionTime = eventStartTime
                    #endif
                    exceptionsList.append(dateInSeconds(exceptionDate, exceptionTime))
                #endtry
            except Exception, e:
                #print str(e)
                pass
            #endtry
            if weeklyType != 0:
                eventHolder.appendReccuringEvent_Weekly(eventStartDate, eventStartTime, eventEndDate, eventEndTime, eventRecurDays, eventRecurEndDate, eventRecurCount, weeklyType, exceptionsList, eventSummary)
            #endif
        elif eventRecurFreq[0] == 'DAILY': # Daily reccruing appointments ## RRULE;X-EVOLUTION-ENDDATE=20120525T233000Z:FREQ=DAILY;COUNT=8;INTERVAL=2;
            #print eventSummary
            #print str(compRRule)
            try: # check for DAILY events that occur at a interval of every other day or greater
                eventRecurInterval = compRRule['INTERVAL']
                eventRecurCount = compRRule['COUNT']
                eventRecurEndDate = "N/A"
                dailyType = 1
            except Exception, e:
                #print str(e)
                pass
            #endtry
            if dailyType != 1:
                try: # check for DAILY
                    eventRecurCount = compRRule['COUNT']
                    dailyType = 2
                    eventRecurEndDate = "N/A"
                    eventRecurInterval = 1
                except Exception, e:
                    print "Error Unknown DAILY Recurring Appointment Type: " + str(e) 
                    #pass
                #endtry
            #endif
            try: # Find dates that do not have ocurrances (holidays, canceled classes, ect.)
                eventExceptions = component['EXDATE']
                exceptionsList = []
                try:
                    for i in xrange(len(eventExceptions)):
                        exceptionDateRaw = eventExceptions[i].to_ical()
                        #print str(exceptionDateRaw)
                        if exceptionDateRaw.find("T") != (-1):
                            #print "test"
                            [exceptionDate, exceptionTime] = str(vDatetime.from_ical(exceptionDateRaw)).split(" ")
                        else:
                            exceptionDate = exceptionDateRaw[0:4] + "-" + exceptionDateRaw[4:6] + "-" + exceptionDateRaw[6:8]
                            exceptionTime = eventStartTime
                        #endif
                        exceptionsList.append(dateInSeconds(exceptionDate, exceptionTime))
                    #endfor
                except Exception, e: # only one exception (not put in list)
                    exceptionDateRaw = eventExceptions.to_ical()
                    #print str(exceptionDateRaw)
                    if exceptionDateRaw.find("T") != (-1):
                        #print "test"
                        [exceptionDate, exceptionTime] = str(vDatetime.from_ical(exceptionDateRaw)).split(" ")
                    else:
                        exceptionDate = exceptionDateRaw[0:4] + "-" + exceptionDateRaw[4:6] + "-" + exceptionDateRaw[6:8]
                        exceptionTime = eventStartTime
                    #endif
                    exceptionsList.append(dateInSeconds(exceptionDate, exceptionTime))
                #endtry
            except Exception, e:
                #print str(e)
                pass
            #endtry
            if dailyType != 0:
                eventHolder.appendReccuringEvent_Daily(eventStartDate, eventStartTime, eventEndDate, eventEndTime, eventRecurEndDate, eventRecurCount, eventRecurInterval, dailyType, exceptionsList, eventSummary)
            #endif
            pass # for now
        elif eventRecurFreq[0] == 'MONTHLY':
            pass # this is the most complicated type and I don't use it, it can wait till later
        elif eventRecurFreq[0] == 'YEARLY': #RRULE;X-EVOLUTION-ENDDATE=20140511T000000Z:FREQ=YEARLY;COUNT=3;WKST=SA
            try: # check for YEARLY
                eventRecurCount = compRRule['COUNT']
                yearlyType = 1
            except Exception, e:
                #print str(e)
                print "Error Unknown YEARLY Recurring Appointment Type: " + str(e)
                #pass
            #endtry
            try: # Find dates that do not have ocurrances (holidays, canceled classes, ect.)
                eventExceptions = component['EXDATE']
                exceptionsList = []
                try:
                    for i in xrange(len(eventExceptions)):
                        exceptionDateRaw = eventExceptions[i].to_ical()
                        #print str(exceptionDateRaw)
                        if exceptionDateRaw.find("T") != (-1):
                            #print "test"
                            [exceptionDate, exceptionTime] = str(vDatetime.from_ical(exceptionDateRaw)).split(" ")
                        else:
                            exceptionDate = exceptionDateRaw[0:4] + "-" + exceptionDateRaw[4:6] + "-" + exceptionDateRaw[6:8]
                            exceptionTime = eventStartTime
                        #endif
                        exceptionsList.append(dateInSeconds(exceptionDate, exceptionTime))
                    #endfor
                except Exception, e: # only one exception (not put in list)
                    exceptionDateRaw = eventExceptions.to_ical()
                    #print str(exceptionDateRaw)
                    if exceptionDateRaw.find("T") != (-1):
                        #print "test"
                        [exceptionDate, exceptionTime] = str(vDatetime.from_ical(exceptionDateRaw)).split(" ")
                    else:
                        exceptionDate = exceptionDateRaw[0:4] + "-" + exceptionDateRaw[4:6] + "-" + exceptionDateRaw[6:8]
                        exceptionTime = eventStartTime
                    #endif
                    exceptionsList.append(dateInSeconds(exceptionDate, exceptionTime))
                #endtry
            except Exception, e:
                #print str(e)
                pass
            #endtry
            if yearlyType != 0:
                eventHolder.appendReccuringEvent_Yearly(eventStartDate, eventStartTime, eventEndDate, eventEndTime, eventRecurCount, yearlyType, exceptionsList, eventSummary)
            #endif
        else:
            print "Error Unknown Recurring Appointment Type: " + str(eventRecurFreq)
            #pass
        #endif
    #endfor
    """
    unsortedList = eventHolder.returnList()
    for i in xrange(len(unsortedList)):
    #    print str(unsortedList[i])
    #endfor
    """
    eventHolder.sortList()
    sortedList = eventHolder.returnSortedList()
    #print ""
    #for i in xrange(len(sortedList)):
    #    print str(sortedList[i])
    #endfor
    finalOutput = u"return { "
    finalOutput += eventHolder.conkyApts_Lua() 
    finalOutput += " , " + eventHolder.conkyCalendar_threeMonth_Lua(0) + " }"
    print str(finalOutput).encode('utf-8')
#enddef

#########

#timeStart = time.time()
parseTest()
#print "time end = " + str(time.time() - timeStart) + "s"

Lua Code To Display Output of Script

if tonumber(conky_parse('${updates}')) < 2 then
    --#### Colors ####
    color0_R,color0_G,color0_B,color0_A = (204/255),(153/255),0,1 -- Yellow #CC9900
    color1_R,color1_G,color1_B,color1_A = (238/255),(118/255),0,1 -- Orange #EE7600
    color2_R,color2_G,color2_B,color2_A = (139/255),0,0,1 -- Red #8B0000
    color3_R,color3_G,color3_B,color3_A = (139/255),0,0,1 -- Shade Color #8B0000
    --## gradient colors
    color4_R,color4_G,color4_B = 1,(204/255),0 -- Dark Yellow #FFCC00
    color5_R,color5_G,color5_B = (204/255),0,0 -- Other Red #CC0000
    --## hddtemp colors
    color6_R,color6_G,color6_B,color6_A = (238/255),0,0,1 -- hddtemp red #EE0000
    color7_R,color7_G,color7_B,color7_A = 1,(128/255),0,1 -- hddtemp orange #FF8000
    color8_R,color8_G,color8_B,color8_A = (238/255),(238/255),0,1 -- hddtemp yellow #EEEE00
    --#### End Colors ####
    --#### Font ####
    font = "DejaVu Sans Mono"
    fSize = 13
    iCalendar_data = nil
end --# if tonumber(conky_parse('${updates}')) < 2 then

function conky_main()
    if conky_window == nil then return end
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local cr = cairo_create(cs)
    local updates=tonumber(conky_parse('${updates}'))
    if updates > 5 then
    if math.mod((updates - 6), 30) == 0 then
            print(updates..": Test")
            local iCalendar_call = io.popen("python /media/Linux_Data/bin/Conky/System_Conky/conky_iCalendar_2_lua.py")
            local iCalendar_output = iCalendar_call:read("*a")
            iCalendar_call:close()
            iCalendar_call = nil
            local iCalendar_function = assert(loadstring(iCalendar_output))
            iCalendar_data = iCalendar_function()
        end --# if math.mod((updates - 6), 30) == 0 then
        if type(iCalendar_data) == "table" then
            if #iCalendar_data[1] > 1 then
                for i = 1, #iCalendar_data[1] do
                    for j = 1, #iCalendar_data[1][i] do
                        if j == 1 then
                            blx = 2
                            bly = bly + 12
                            cr = draw_shaded_text(cr, iCalendar_data[1][i][j][1], blx, bly, {color0_R,color0_G,color0_B,color0_A}, {color3_R,color3_G,color3_B,color3_A})
                            cairo_text_extents(cr, iCalendar_data[1][i][j][1].." ", extents)
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            cr = draw_shaded_text(cr, '-', blx, bly, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                            cairo_text_extents(cr, '- ', extents)
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            cr = draw_shaded_text(cr, iCalendar_data[1][i][j][2], blx, bly, {color0_R,color0_G,color0_B,color0_A}, {color3_R,color3_G,color3_B,color3_A})
                        else
                            blx = 2
                            bly = bly + 12
                            cr = draw_shaded_text(cr, iCalendar_data[1][i][j][1], blx, bly, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                            cairo_text_extents(cr, iCalendar_data[1][i][j][1].." ", extents)
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            cr = draw_shaded_text(cr, '->', blx, bly, {color0_R,color0_G,color0_B,color0_A}, {color3_R,color3_G,color3_B,color3_A})
                            cairo_text_extents(cr, '-> ', extents)
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            if iCalendar_data[1][i][j][3][1]:sub(1,1) == "-" then
                                cr = draw_shaded_text(cr, iCalendar_data[1][i][j][2].." |", blx, bly, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                                cairo_text_extents(cr, iCalendar_data[1][i][j][2].." |", extents)
                            else
                                cr = draw_shaded_text(cr, iCalendar_data[1][i][j][2].." |", blx, bly, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                                cairo_text_extents(cr, iCalendar_data[1][i][j][2].." | ", extents)
                            end --#
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            cr = draw_shaded_text(cr, iCalendar_data[1][i][j][3][1], blx, bly, iCalendar_data[1][i][j][3][2], iCalendar_data[1][i][j][3][3])
                            cairo_text_extents(cr, iCalendar_data[1][i][j][3][1].." ", extents)
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            cr = draw_shaded_text(cr, '|', blx, bly, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                            cairo_text_extents(cr, '| ', extents)
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            cr = draw_shaded_text(cr, iCalendar_data[1][i][j][4], blx, bly, {color0_R,color0_G,color0_B,color0_A}, {color3_R,color3_G,color3_B,color3_A})
                        end --# if j == 1 then
                    end --# for j = 1, #iCalendar_data[1][i] do
                    cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL)
                    bly = bly + 4
                    cr = draw_horizontal_divider(cr, 1, bly, conky_window.width, bly, 1, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                end --# for i = 1, #iCalendar_data[1] do
            else
                blx = 2
                bly = bly + 12
                cr = draw_shaded_text(cr, iCalendar_data[1][1][1], blx, bly, {color0_R,color0_G,color0_B,color0_A}, {color3_R,color3_G,color3_B,color3_A})
                bly = bly + 4
                cr = draw_horizontal_divider(cr, 1, bly, conky_window.width, bly, 1, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
            end --# if #iCalendar_data[1] > 1 then
            cairo_text_extents(cr, iCalendar_data[2][1][2], extents)
            local calendarWidth = extents.x_advance
            local middleCalStart = (conkyWidth - calendarWidth)/2 --# center line 1 in window
            local leftCalStart = (middleCalStart - calendarWidth)/2
            local rightCalStart = (middleCalStart + calendarWidth + leftCalStart)
            local startArray = {leftCalStart, middleCalStart, rightCalStart}
            bly2 = bly
            for i = 1, 3 do
                bly = bly2
                for j = 1, #iCalendar_data[2][i] do
                    blx = 0
                    
                    if j == 1 then
                        bly = bly + 12
                        cairo_text_extents(cr, iCalendar_data[2][i][1], extents)
                        blx = (startArray[i] + ((calendarWidth - extents.x_advance)/2))
                        cr = draw_shaded_text(cr, iCalendar_data[2][i][1], blx, bly, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                    elseif j == 2 then
                        bly = bly + 12
                        cr = draw_shaded_text(cr, iCalendar_data[2][i][2], startArray[i], bly, {color1_R,color1_G,color1_B,color1_A}, {color3_R,color3_G,color3_B,color3_A})
                    else
                        blx = startArray[i]
                        bly = bly + 12
                        for k = 1, # iCalendar_data[2][i][j] do
                            if iCalendar_data[2][i][j][k][2] == "Bold" then
                                cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD)
                            end --# if iCalendar_data[2][i][j][2] == "Bold" then
                            cr = draw_shaded_text(cr, iCalendar_data[2][i][j][k][1], blx, bly, iCalendar_data[2][i][j][k][3], iCalendar_data[2][i][j][k][4])
                            cairo_text_extents(cr, iCalendar_data[2][i][j][k][1]..' ', extents)
                            string_x_advance = extents.x_advance
                            blx = blx + string_x_advance
                            if iCalendar_data[2][i][j][k][2] == "Bold" then
                                cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL)
                            end --# if iCalendar_data[2][i][j][2] == "Bold" then
                        end --# for k = 1, # iCalendar_data[2][i][j] do
                    end --# if j = 1 then
                end --# for j = 1, #iCalendar_data[2][i] do
            end --# for i = 1, 3 do
        end --# if type(iCalendar_data) == "table" then
    end-- if updates > 5
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr = nil
    cs = nil
    local gcollect = collectgarbage ("collect")
    return ""
end --# function conky_main()

function draw_shaded_text(CR, text, xpos, ypos, COLOR, shade_color)
    cairo_set_source_rgba (CR,shade_color[1],shade_color[2],shade_color[3],shade_color[4]) --# set shade color
    cairo_move_to (CR,(xpos + 1),(ypos + 1))
    cairo_show_text (CR,text)
    cairo_stroke (CR)
    cairo_set_source_rgba (CR,COLOR[1],COLOR[2],COLOR[3],COLOR[4]) --# set font color
    cairo_move_to (CR,xpos,ypos)
    cairo_show_text (CR,text)
    cairo_stroke (CR)
    return CR
end --# function draw_shaded_text()

function draw_horizontal_divider(CR, xpos, ypos, xend, yend, lineWidth, COLOR, shade_color)
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE) --# don't antialias outline it is too thin and gets blurred
    cairo_set_line_width (CR,lineWidth)
    --# draw shade
    cairo_set_source_rgba (CR,shade_color[1],shade_color[2],shade_color[3],shade_color[4]) --# set shade color
    cairo_move_to (CR, (xpos + 1), (ypos + 1))
    cairo_line_to (CR,(xend + 1), (yend + 1))
    cairo_stroke (CR)
    --# draw line
    cairo_set_source_rgba (CR,COLOR[1],COLOR[2],COLOR[3],COLOR[4]) --# set color
    cairo_move_to (CR, xpos, ypos)
    cairo_line_to (CR, xend, yend)
    cairo_stroke (CR)
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT)
    return CR
end --# function draw_horizontal_divider(cr, )

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo