Some of my scripts for daily use on a linux desktop

Friday, May 14, 2010

Calendar box

Hello !

Here is a new calendar fully customizable, nothing special in it, just nices effects created with the couple Lua/Cairo. Also, I choose a "settings table" to pass parameters to the script, so if a parameter is missing, a default parameter is used. Only 4 parameters are mandatory.

You can download the script from Ubuntu forums here and you need conky 1.8.0 or higher.

Set up the conkyrc
You need theses two lines in your conkyrc :
own_window_transparent yes
own_window_argb_visual yes
If you want the calendar in your language system, you have to add $time in TEXT section
$time
and if you want to hide this time, use, for example :
use_xft yes
xftalpha 0
Set up the lua script
At the beggining of the script, there is a table called cal_settings which contains the parameters for one or more calendars :

--for one calendar
cal_settings={
{ x=12,
y=12,
font="Japan",
font_size=14
},
}

or

--for two calendars
cal_settings={
{ x=12,
y=12,
font="Japan",
font_size=14
},
{ x=120,
y=120,
font="Japan",
font_size=16
},
}


So, the 4 mandatory parameters are : x, y, font, font_size. With the first example, the output is classical :

The red numbers are for bank holidays (May is a good month for that in France !) and blue number is for today.
The bank holidays and reminders stuffs are stored in a text file called at the beginnning of the script :
calendar_file= "/home/wlourf/scripts/calendar-box/calendar.txt"

the format of this text file is
#format of in this text file
#MMDD;N;TEXT
#MMDD = month day
#N = 0 or 1 (1 to display colours of bank holidays)
#TEXT = Text to display

0501;1;May Day
0508;1;Armistice 1945
0513;1;Ascension
0524;1;Pentecost Monday
0612;0;Mom's Birthday


Now, the others parameters that can be put in the cal_settings table...
With this ones, numbers are displayed with two digits and numbers of others months are hidden :

x=36,
y=12,
font="Verdana",
font_size=20,
two_digits=true,
display_others_days=false,



Theses ones format the month and the days with two letters
 month_format="%B %Y",
days_number=2


For time formatting , see http://www.lua.org/pil/22.1.html, time can be displayed with "%B - %H:%M"

Month can be put around the calendar with l/r/b or t,
Days can be put on top or on bottom of the calendar with b or t
To display a month different from current month, use month_offset
 month_position="l",
month_offset=-1,
days_position="b",



numbers can be right/left or center aligned
 days_position="t",
two_digits=false,
alignment="r",



Now, just put some colors, they are set in tables inside the cal_settings table. Formats are:
-for boxes:
 {colour1, colour2, alpha1,alpha2,border1,border2,alpha border1,alpha border2}

-for texts:
 {colour1, colour2, alpha1,alpha2}

Colours use gradients, it's why there are two colors to set for each format.
Theses parameters set the color of boxes and texts
 alignment="c",
border=0,
colBox = {0xFF0000,0x0000FF,0,1,0x0000FF,0x00FFFF,0.5,0.5},
colBoxText ={0x000000,0x0000FF,1,0},


Others colours for text are for month, days (letters), today (number), bank holiday (number) , other month number, like this:

month_offset=0,
month_position="b",
colBox = {0xFF0000,0x0000FF,0,0.5,0x0000FF,0x00FFFF,0.5,0.5}, --box color
colBoxText ={0x000000,0x000000,1,0.5}, --color of numbers
colBoxTextTD = {0x0000FF,0x0000FF,1,1}, --color of today
colBoxTextBH = {0x00FF00,0x00FF00,1,1}, --color of bank holiday
display_others_days=true,
colBoxTextOM = {0xCCCCCC,0x0000FF,1,0}, --color of numbers for other month
colDaysText ={0xFF0000,0x000000,1,1}, --color of days (Monday ...)
colMonthText = {0xFF0000,0x000000,0,1}, --color of month


On the above image, the color for today's box was not defined, so the script use the inversed colors of a standard box. The others parameters for the boxes are:
 border=0.5,
colBox = {0xFF0000,0x0000FF,0,0,0x0000FF,0x00FFFF,0.5,0.5}, --color of standard box, alpha = 0 here
colDays = {0xFF00FF,0x0000FF,1,1,0x0000FF,0x00FF00,1,1}, --color of boxes "Days" (Monday ...)
colMonth = {0x00FF00,0x0000FF,1,1,0x0000FF,0x00FF00,1,1}, --color of box "Month"
colBoxTD = {0xFF0000,0xFF0000,0,1,0xFF00FF,0x00FF00,1,1}, --color of box "Today"
colBoxBH = {0xFF0000,0xFF0000,1,1,0xFF00FF,0x00FF00,1,1}, --color of box "Bank holiday"


Parameters to change the shape of the boxes :
 hpadding=5,  --horizontal space beetween border and text (default=2 pixels)
vpadding=5, --vertical space beetween border and text (default=2 pixels)
border=0.5, --border size (default=0 pixels)
gap=5, --space betwwen 2 boxes (default=2 pixels)
radius=5, --radius of corners (default=0 pixels)



Parameters to change the gradient effect :
 orientation ="ww", -- possibles values = nn, ne,ee,se,ss,sw,ww,nw



To have a radial gradient :
 orientation ="nw", -- possibles values = nn, ne,ee,se,ss,sw,ww,nw
gradient=0.25, -- default linear(=0) or radial gradient percentage (0-1) of box side



I also add a reminder box : this one displays text info from calendar.txt file, parameters are :
 display_info_box=true, --display info box (default=false)
colInfo = {0xFF0000,0x0000FF,0,1,0x0000FF,0x00FFFF,0.5,0.5}, --color info Box
colInfoText = {0x000000,0xFFFFFF,1,1}, --color text of info box
info_position="b", --position of info box, possibles values are t/b/l/r, (default=b)
display_empty_info_box=true, --if no info to display , display or not info the box


The info box can also display first line of a text file generated by a script. For example, this line in the conkyrc get the Saint of the day in file /tmp/info.txt - thanks chepioq ;-):
${execi 3600 wget http://fetedujour.fr/api/text  -O - -o /dev/null | awk '{print $6}' | sed 's/.$//' > /tmp/info.txt}

And this parameter in the lua script :
 file_info="/tmp/info.txt",

will read info in /tmp/info.txt instead of calendar.txt


That's all for this script !


Some updates
Openbox's shortcuts script :
Keyboard shortcuts without commands are no more displayed.
Long command lines are shortened in the dispay to fit the column width.
In keyboard section, when a command string hold the full path to the executable, it keeps only the name of the executable itself.
It's here

Pie Chart widget:
The parameters are now set in a table and I add the type_arc parameter, it can be set to "l" for linear or "r" for radial.
"r" gives the same result as before :

"l" gives that (a ring) :

It's here