You are not logged in.
DrakarNoir wrote:I used arclance's draw_bg.ua to make "donut" shaped backgrounds. I wanted to do this because I wish to display this clock in conjunction with my music conky (see scrot below). However, when the music conky loads first it is not visible behind the clock. My question then is...is this not a true "donut"? If no, is a true "donut" possible or am I missing something?
scrot:
It is a true donut.
Nothing is drawn in the center of the ring and it won't cover anything else from the same conky up.If your music conky is a separate conky (has a different .conkyrc) and you are not using a compositor (compton, compiz, etc.) that is normal since conky will only show the desktop underneath it not another window.
If your music conky and clock conky are combined I would need to see all the code for it to figure out why that happens.
arclance,
These are two separate conkyrc files. I use xfce and the built-in compositor so I do not understand why there is no transparency.
"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.” ~Ronald Reagan
Offline
arclance wrote:DrakarNoir wrote:I used arclance's draw_bg.ua to make "donut" shaped backgrounds. I wanted to do this because I wish to display this clock in conjunction with my music conky (see scrot below). However, when the music conky loads first it is not visible behind the clock. My question then is...is this not a true "donut"? If no, is a true "donut" possible or am I missing something?
scrot:
It is a true donut.
Nothing is drawn in the center of the ring and it won't cover anything else from the same conky up.If your music conky is a separate conky (has a different .conkyrc) and you are not using a compositor (compton, compiz, etc.) that is normal since conky will only show the desktop underneath it not another window.
If your music conky and clock conky are combined I would need to see all the code for it to figure out why that happens.
arclance,
These are two separate conkyrc files. I use xfce and the built-in compositor so I do not understand why there is no transparency.
I don't know for sure since I don't use a compositor so I have not had a chance to see if there are any problems with conky transparency when using a compositor.
I can make a couple of guesses about what might be causing it though.
1. If you are not using "own_window_argb_value" to set the transparency value of the conky you will not get the full transparency effect of your compositor.
2. The draw_bg.lua script is making a separate cairo surface from the clock script and I don't know how your compositor will react to that situation, it may not work correctly.
Offline
I used arclance's draw_bg.ua to make "donut" shaped backgrounds. I wanted to do this because I wish to display this clock in conjunction with my music conky (see scrot below). However, when the music conky loads first it is not visible behind the clock. My question then is...is this not a true "donut"? If no, is a true "donut" possible or am I missing something?
scrot:
It's possible to run more than one LUA script in a conky ...
Run the clock 'lua_draw_hook_pre' and the music as 'lua_draw_hook_post'
If I am right the circle LUA can be loaded above TEXT and the line to run it is directly after TEXT the same way draw-bk.lua can be run.
They should all work together similar to this - 4 lua scripts one conky::
lua_load /media/5/Conky/LUA/draw-bg.lua
#lua_draw_hook_pre draw_bg 20 0 0 0 0 0x000000 0.5
#lua_draw_hook_post draw_bg 20 0 0 0 0 0x000000 0.5
#
# TEXT
# ${lua conky_draw_bg 20 0 0 0 0 0x000000 0.3}
##
#
################### chronograph-mrpeachy #######################################
#lua_load /media/5/Conky/LUA/chronograph-mrpeachy.lua
lua_load /media/5/Conky/LUA/chronograph-mrpeachy_24.lua
lua_draw_hook_post main
#lua_draw_hook_pre main
### v9000 Weather ############################################################
lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
#lua_draw_hook_post weather
lua_load /media/5/Conky/LUA/crono_mrp.template.lua
############################################################ v9000 Weather ###
### mount.lua ################################################################
lua_load /media/5/Conky/LUA/mounted.lua
TEXT
${lua get_mounted_data 3}${lua conky_draw_bg 20 0 0 0 0 0x000000 0.5}
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
1. If you are not using "own_window_argb_value" to set the transparency value of the conky you will not get the full transparency effect of your compositor.
Yup...that was the answer. Had it commented out in the conkyrc.
It's possible to run more than one LUA script in a conky ...
Thanks for the reminder Sector11. The problem is that the music conky is VastOnes music conky and it is way too complicated for me to figure out how to combine it with the chrono (which is ideally what I want to do). Perhaps that will be my next "months and months long" project
"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.” ~Ronald Reagan
Offline
My current desktop with the following conkys:
top left: v9000 weather, interactive
top center: ring meters (work in progress)
top right: chrono and VastOne's music conky
bottom center: Verse of the Day
Any one see anything ya want just ask! None of these are mine, they are "borrowed" and bodged by me thus the credit goes out to the original creators and to all the people who helped along the way!
"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.” ~Ronald Reagan
Offline
Sector11 wrote:It's possible to run more than one LUA script in a conky ...
Thanks for the reminder Sector11. The problem is that the music conky is VastOnes music conky and it is way too complicated for me to figure out how to combine it with the chrono (which is ideally what I want to do). Perhaps that will be my next "months and months long" project
So how are you showing the music in the centre of the chronograph now?
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
Chrono Mr Peachy modified a little:
ChronoPeachy
Offline
Chrono Mr Peachy modified a little:
ChronoPeachy
Nice.
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
ragamatrix wrote:Chrono Mr Peachy modified a little:
ChronoPeachyNice.
Thanks; I'm testing it doesn't work so nice...I got some errors I think because there are to much lua script may be ?
Offline
Sector11 wrote:ragamatrix wrote:Chrono Mr Peachy modified a little:
ChronoPeachyNice.
Thanks; I'm testing it doesn't work so nice...I got some errors I think because there are to much lua script may be ?
No I don't think so, there is probably a problem in the code you've added.
If it is the rings around the outside why not use it as a separate LUA?
Something like:
lua_load /media/5/Conky/LUA/draw-bg.lua
lua_load /media/5/Conky/LUA/chronograph-mrpeachy_24.lua
lua_draw_hook_post main
lua_load ~/PATH_TO/rings.lua
lua_draw_hook_pre 'what the function is'
lua_load /media/5/Conky/LUA/mounted.lua
TEXT
${lua get_mounted_data 3}${lua conky_draw_bg 20 0 0 0 0 0x000000 0.5
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
Ok thank you; it's worked only one time; i don't know how to make it work again.
What I did in my conky..may be crazy things or bad...
conky:
# To use #! in a conky use: ${exec echo '#!'}
# OB_topconky
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints below,skip_taskbar,skip_pager,sticky
own_window_title mayan-time
own_window_class mayan-time
background yes
border_inner_margin 0
border_width 0
default_outline_color black
default_shade_color black
double_buffer yes
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
no_buffers yes
override_utf8_locale yes
pad_percents 2
short_units yes
stippled_borders 0
text_buffer_size 1028
uppercase no
use_spacer right
use_xft yes
xftfont White Rabbit:size=8
xftalpha 1.0
# Colors
default_color DCDCDC #Gainsboro
color0 FFFFF0 #Ivory
color1 FFA07A #LightSalmon
color2 FF8C00 #Darkorange
color3 7FFF00 #Chartreuse
color4 778899 #LightSlateGrey
color5 FFDEAD #NavajoWhite
color6 00BFFF #DeepSkyBlue
color7 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #Red
imlib_cache_size 0
update_interval 1
gap_x 0 # left &right
gap_y 0 # up & down
minimum_size 300 300 # width, height
alignment mm
# -- Déclaration template -- #
template0 ${image ~/.conky/conky38/script/images/\1 -p \2 -s \3} # -- images fond -- #
template1 ${lua Meteo_\1 \2 \3 \4 \5 \6} # -- gestion météo --#
template2 ${lua_parse Meteo_\1 \2 \3 \4 60 \5} # -- icônes météo -- \2=répertoire icônes \3=position \4=taille \5=jour (pour les prévisions) #
template3 ${lua Lune_\1}
template4 ${lua_parse Images_\1 \2 \3 60 \4 \5 \6 \7 \8 \9} # -- Appelle image -- \2=position \3=taille \4=jour (pour les prévisions) #
lua_load ~/.conky/conky38/script/meteo.lua
lua_load ~/.conky/conky38/script/images_meteo.lua
lua_startup_hook init ~/.conky/conky38/script/meteo.cfg
# -- Lua load -- #
lua_load ~/développement/breitling.lua
lua_draw_hook_pre main
lua_load ~/développement/rings/rings2.lua
lua_draw_hook_post main_rings
lua_load ~/développement/draw_bg.lua
TEXT
##${lua conky_draw_bg 38 161 162 76 76 0x000000 0.7}
${lua conky_draw_bg 122 30 28 244 244 0x000000 0.5}
${time %t}
#### Lancement du script récupérant les données météo
#${template1 Maj}
${template1 horsligne}
${template2 huitHeures_IconeM ~/.conky/conky38/meteo/icones 90,110 114x75 4}${font DejaVu:style=Bold:size=6}${voffset 60}${goto 143}${color OrangeRed}${template1 huitHeures_Heure 4}h${voffset 15}${goto 146}${font Arial Rounded MT:size=7}${if_match ${template1 huitHeures_Temp 4}<0}${color lightblue}${blink ${template1 huitHeures_Temp 4}°}${else}${color white}${template1 huitHeures_Temp 4}°${endif}
Offline
Ok thank you; it's worked only one time; i don't know how to make it work again.
What I did in my conky..may be crazy things or bad...
conky:# To use #! in a conky use: ${exec echo '#!'} # OB_topconky own_window yes own_window_type override own_window_transparent yes own_window_hints below,skip_taskbar,skip_pager,sticky own_window_title mayan-time own_window_class mayan-time background yes border_inner_margin 0 border_width 0 default_outline_color black default_shade_color black double_buffer yes draw_borders no draw_graph_borders no draw_outline no draw_shades no no_buffers yes override_utf8_locale yes pad_percents 2 short_units yes stippled_borders 0 text_buffer_size 1028 uppercase no use_spacer right use_xft yes xftfont White Rabbit:size=8 xftalpha 1.0 # Colors default_color DCDCDC #Gainsboro color0 FFFFF0 #Ivory color1 FFA07A #LightSalmon color2 FF8C00 #Darkorange color3 7FFF00 #Chartreuse color4 778899 #LightSlateGrey color5 FFDEAD #NavajoWhite color6 00BFFF #DeepSkyBlue color7 48D1CC #MediumTurquoise color8 FFFF00 #Yellow color9 FF0000 #Red imlib_cache_size 0 update_interval 1 gap_x 0 # left &right gap_y 0 # up & down minimum_size 300 300 # width, height alignment mm # -- Déclaration template -- # template0 ${image ~/.conky/conky38/script/images/\1 -p \2 -s \3} # -- images fond -- # template1 ${lua Meteo_\1 \2 \3 \4 \5 \6} # -- gestion météo --# template2 ${lua_parse Meteo_\1 \2 \3 \4 60 \5} # -- icônes météo -- \2=répertoire icônes \3=position \4=taille \5=jour (pour les prévisions) # template3 ${lua Lune_\1} template4 ${lua_parse Images_\1 \2 \3 60 \4 \5 \6 \7 \8 \9} # -- Appelle image -- \2=position \3=taille \4=jour (pour les prévisions) # lua_load ~/.conky/conky38/script/meteo.lua lua_load ~/.conky/conky38/script/images_meteo.lua lua_startup_hook init ~/.conky/conky38/script/meteo.cfg # -- Lua load -- # lua_load ~/développement/breitling.lua lua_draw_hook_pre main lua_load ~/développement/rings/rings2.lua lua_draw_hook_post main_rings lua_load ~/développement/draw_bg.lua TEXT ##${lua conky_draw_bg 38 161 162 76 76 0x000000 0.7} ${lua conky_draw_bg 122 30 28 244 244 0x000000 0.5} ${time %t} #### Lancement du script récupérant les données météo #${template1 Maj} ${template1 horsligne} ${template2 huitHeures_IconeM ~/.conky/conky38/meteo/icones 90,110 114x75 4}${font DejaVu:style=Bold:size=6}${voffset 60}${goto 143}${color OrangeRed}${template1 huitHeures_Heure 4}h${voffset 15}${goto 146}${font Arial Rounded MT:size=7}${if_match ${template1 huitHeures_Temp 4}<0}${color lightblue}${blink ${template1 huitHeures_Temp 4}°}${else}${color white}${template1 huitHeures_Temp 4}°${endif}
In fact it's working correctly, it was because I did something wrong with the "chrono_MrPeachy" script.
Sorry... :8
Last edited by ragamatrix (2012-12-17 15:23:37)
Offline
I'm testing the circle writing too from Mr Peachy again !
circletextConky
Last edited by ragamatrix (2012-12-17 15:57:21)
Offline
^can you post the circlewriting script you are using, i may have an updated version
Offline
Here is my latest cronograph hack with the lua moon from a previous post, still a work in progress, but got to go to bed now ~
(hope the image isn't too big, wasn't sure what is the protocol for posting image here)
Last edited by damaru (2012-12-17 22:41:28)
ponnuki studio
ponnuki.net
Offline
So how are you showing the music in the centre of the chronograph now?
The problem is that the music conky is VastOnes music conky and it is way too complicated for me to figure out how to combine it with the chrono (which is ideally what I want to do). Perhaps that will be my next "months and months long" project
Oops. Poorly worded on my part (been doing that a lot lately), my appologies!
That was the necessity of having a true "donut" in the chrono conky! I am runningVastOne's music conky conky which I have sized down to fit into the hole in the center of the chrono.
My ultimate intention is to combine the two into one script with the layout that is provided by the two as they currently appear. However, the music script as well as the chrono script are way to involved for me to understand what is going on. SO the combining of the two will probably be a very long and painful process!
Last edited by DrakarNoir (2012-12-17 23:20:45)
"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.” ~Ronald Reagan
Offline
Finally had some time to conky around (is that a thing?)......... heres a sneak peak....... will try to finish and get config posted tonight
Conky | SMXI HowTo | Super Grub | VastOnes GMB HowTo | VSIDO
Offline
^ Very nice lwfitz!
Thanks buddy!
Conky | SMXI HowTo | Super Grub | VastOnes GMB HowTo | VSIDO
Offline
^can you post the circlewriting script you are using, i may have an updated version
wOwhh It's a 2010 script !
Yes, ok, you mean that I will have to restart from the begining...?
Here it is (sorry it's messy because I was just testing...)
texte_courbe.lua:
--[[circlewriting by mrpeachy (2010)]]
require 'cairo'
function addzero100(num)
if tonumber(num) < 10 then
return "00" .. num
elseif tonumber(num) <100 then
return "0" .. num
else
return num
end
end
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end
function circlewriting(cr, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha, start, finish, var1)
local inum=string.len(text)
range=finish
deg=(finish-start)/(inum-1)
degrads=1*(math.pi/180)
local textcut=string.gsub(text, ".", "%1@@@")
texttable=string.split(textcut, "@@@")
for i = 1,inum do
ival=i
interval=(degrads*(start+(deg*(i-1))))+var1
interval2=degrads*(start+(deg*(i-1)))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, tred, tgreen, tblue, talpha);
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval2)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval2)
end
end
function circlewritingdown(cr, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha, start, finish, var1)
local inum=string.len(text)
deg=(start-finish)/(inum-1)
degrads=1*(math.pi/180)
local textcut=string.gsub(text, ".", "%1@@@")
texttable=string.split(textcut, "@@@")
for i = 1,inum do
ival=i
interval=(degrads*(start-(deg*(i-1))))+var1
interval2=degrads*(start-(deg*(i-1)))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, tred, tgreen, tblue, talpha);
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval2+(180*math.pi/180))
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval2-(180*math.pi/180))
end
end
function conky_draw_text()
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num > 5 then
if conky_window==nil then return end
local w=conky_window.width
local h=conky_window.height
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
cr=cairo_create(cs)
--#circlewriting variable##1STLINE
long=tonumber(conky_parse('${top cpu 1}%'))
--#text must be in quotes
text=(conky_parse('${top cpu 1}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=15
radius=80
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=30
finish=80
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2STLINE
long=tonumber(conky_parse('${top name 1}'))
text=(conky_parse('CPU: ${top name 1}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=15
radius=80
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=-50
finish=70
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2STLINE222
long=tonumber(conky_parse('${top name 2}'))
text=(conky_parse('CPU:${top name 2}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=10
radius=68
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=-50
finish=70
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2STLINE222CPU33333####
long=tonumber(conky_parse('${top name 3}'))
text=(conky_parse('CPU:${top name 3}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=9
radius=56
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=-50
finish=70
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2STLINE222CPU4444####
long=tonumber(conky_parse('${top name 4}'))
text=(conky_parse('CPU:${top name 4}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=8
radius=44
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=-50
finish=70
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2STLINE22222####
long=tonumber(conky_parse('${top cpu 2}%'))
--#text must be in quotes
text=(conky_parse('${top cpu 2}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=10
radius=68
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=30
finish=80
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2STLINE33333####
long=tonumber(conky_parse('${top cpu 3}%'))
--#text must be in quotes
text=(conky_parse('${top cpu 3}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=9
radius=56
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=30
finish=80
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2STLINE44444####
long=tonumber(conky_parse('${top cpu 4}%'))
--#text must be in quotes
text=(conky_parse('${top cpu 4}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=8
radius=44
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=30
finish=80
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2""STLINE
long=tonumber(conky_parse('${top_mem name 1}'))
text=(conky_parse('MEM: ${top_mem name 1}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=15
radius=80
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=100
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2""STLINE22222222####
long=tonumber(conky_parse('${top_mem name 2}'))
text=(conky_parse('MEM: ${top_mem name 2}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=10
radius=68
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=100
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2""STLINE33333333####
long=tonumber(conky_parse('${top_mem name 3}'))
text=(conky_parse('MEM: ${top_mem name 3}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=9
radius=56
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=100
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable##2""STLINE444444444####
long=tonumber(conky_parse('${top_mem name 4}'))
text=(conky_parse('MEM: ${top_mem name 4}'))
--#text must be in quotes
--#font name must be in quotes
font="White Rabbit"
fontsize=8
radius=44
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=100
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable3LINE
long=tonumber(conky_parse('${top_mem mem 1}%'))
--#text must be in quotes
text=(conky_parse('${top_mem mem 1}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=15
radius=80
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=180
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable3LINE2222222###
long=tonumber(conky_parse('${top_mem mem 2}%'))
--#text must be in quotes
text=(conky_parse('${top_mem mem 2}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=10
radius=68
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=180
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable3LINE33333333###
long=tonumber(conky_parse('${top_mem mem 3}%'))
--#text must be in quotes
text=(conky_parse('${top_mem mem 3}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=9
radius=56
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=180
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable3LINE4444444###
long=tonumber(conky_parse('${top_mem mem 4}%'))
--#text must be in quotes
text=(conky_parse('${top_mem mem 4}%'))
--#font name must be in quotes
font="White Rabbit"
fontsize=8
radius=44
positionx=150
positiony=150
colorred=255
colorgreen=0
colorblue=0
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=180
finish=220
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variable4LINEcpu1+2
long=tonumber(conky_parse('${cpu cpu0}%'))
--#text must be in quotes
text=(conky_parse('Cpu 1+2: ${cpu cpu0} %'))
--#font name must be in quotes
font="White Rabbit"
fontsize=15
radius=80
positionx=150
positiony=150
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
start=235
finish=295
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewritingdown variables
--mem=tonumber(conky_parse('${cpu}'))
--#text must be in quotes
--text=("CPU " .. (addzero100(cpu)) .. "%")
--#font name must be in quotes
--font="White Rabbit"
--fontsize=18
--radius=90
--positionx=230
--positiony=270
--colorred=1
--colorgreen=1
--colorblue=1
--coloralpha=1
--#to set start and finish values for circlewritingdown, if the text will cross 0 degrees then you must calculate for 0-finish degrees
--#eg if you want to go from 90 to 270, then you will input 90 to -90. Start has to be greater than finish
--start=300
--finish=180
--letterposition=0
--circlewritingdown(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewritingdown variable
--hdd=tonumber(conky_parse('${fs_used_perc /}'))
--#text must be in quotes
--text=("FILESYS " .. (addzero100(hdd)) .. "%")
--#font name must be in quotes
--font="White Rabbit"
--fontsize=18
--radius=80
--positionx=260
--positiony=280
--colorred=1
--colorgreen=1
--colorblue=1
--coloralpha=1
--#to set start and finish values for circlewritingdown, if the text will cross 0 degrees then you must calculate for 0-finish degrees
--#eg if you want to go from 90 to 270, then you will input 90 to -90. Start has to be greater than finish
--start=180
--finish=0
--letterposition=0.06
--circlewritingdown(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--#circlewriting variables
--swap=tonumber(conky_parse('${swapperc}'))
--#text must be in quotes
--text=("SWAP " .. (addzero100(swap)) .. "% ")
--#font name must be in quotes
--font="White Rabbit"
--fontsize=18
--radius=60
--positionx=105
--positiony=130
--colorred=1
--colorgreen=1
--colorblue=1
--coloralpha=1
--#to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--#eg if you want to go from 270 to 90, then you will input 270 to 450. Finish has to be greater than start.
--start=200
--finish=340
--letterposition=0
--circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
end
end
I modified a little to be able to display easyly the "conky_parse" or data sorry my English...
Last edited by ragamatrix (2012-12-18 08:19:37)
Offline
Ok heres the configs if anyone is interested:
conky_chrono
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour white
own_window_class Conky
own_window_title Chronograph TEST
double_buffer yes
### ARGB can be used for real transparency
### NOTE that a composite manager is required for real transparency.
### This option will not work as desired (in most cases) in conjunction with
### own_window_type normal
#own_window_argb_visual yes
### When ARGB visuals are enabled, this use this to modify the alpha value
### Use: own_window_type normal
### Use: own_window_transparent no
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
#own_window_argb_value 5
minimum_size 275 675 ## width, height
maximum_width 275 ## width
gap_x 10
gap_y 40
# tl, tm, tr
# ml, mm, mr
# bl, bm, br
alignment tl
#alignment top_middle
# Use Xft (anti-aliased font and stuff)
use_xft yes
#xftfont CorporateMonoExtraBold:size=9
xftfont monofur:bold:size=14
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
draw_shades no
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
color1 000000 ## Black
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders yes #no
#default_graph_size 15 40
background yes
use_spacer none
text_buffer_size 256
no_buffers yes
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
format_human_readable yes
short_units yes
update_interval 1
imlib_cache_size 0
# Maximum size of user text buffer, i.e. layout below TEXT line in config file
# (default is 16384 bytes)
# max_user_text 16384
# Desired output unit of all objects displaying a temperature. Parameters are
# either "fahrenheit" or "celsius". The default unit is degree Celsius.
temperature_unit Fahrenheit
####### Load Lua #########
lua_load ~/Conky/s11_clock.lua
lua_draw_hook_post main
lua_load ~/Conky/rings.lua
lua_draw_hook_pre main_rings
############################## End LUA ###
TEXT
${voffset 12}${goto 127}${font BlackChancery:bold:size=15}${color1}${platform f71882fg.656 temp 1}${font BlackChancery:bold:size=15}F
${voffset -8}${goto 95}${font BlackChancery:bold:size=25}${color1}1${goto 181}2
${voffset -11}${goto 115}${font BlackChancery:bold:size=15}${color1}CPU
${voffset -4}${goto 93}${font BlackChancery:bold:size=25}${color1}3${goto 179}4
${voffset -10}${goto 127}${font BlackChancery:bold:size=20}${color1}${cpu cpu0}%
${voffset 20}${goto 110}${font BlackChancery:bold:size=15}${color1}RAM
${voffset -7}${goto 90}${font BlackChancery:bold:size=12}${mem}${goto 140}/ ${memmax}${voffset 7}
${goto 110}${font BlackChancery:bold:size=15}${color1}SWAP
${voffset -7}${goto 90}${font BlackChancery:bold:size=12}${swap}${goto 140}/ ${swapmax}
conky_rings_storage
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour white
own_window_class Conky
own_window_title Chronograph TEST
double_buffer yes
### ARGB can be used for real transparency
### NOTE that a composite manager is required for real transparency.
### This option will not work as desired (in most cases) in conjunction with
### own_window_type normal
#own_window_argb_visual yes
### When ARGB visuals are enabled, this use this to modify the alpha value
### Use: own_window_type normal
### Use: own_window_transparent no
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
#own_window_argb_value 5
minimum_size 275 1100 ## width, height
maximum_width 275 ## width
gap_x -165
gap_y 25
### alignment values or top_left, bottom_right, etc
# tl, tm, tr
# ml, mm, mr
# bl, bm, br
#alignment tl
alignment top_middle
use_xft yes
xftfont monofur:bold:size=14
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
draw_shades no
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
color1 000000 ## Black
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders yes #no
#default_graph_size 15 40
background yes
use_spacer none
text_buffer_size 256
no_buffers yes
short_units yes
pad_percents 2
format_human_readable yes
short_units yes
imlib_cache_size 0
temperature_unit Fahrenheit
update_interval 1
### Load Lua ###########################################################
lua_load ~/Conky/rings_2.lua
lua_draw_hook_pre main_rings
############################## End LUA Settings ###
TEXT
#${lua conky_draw_bg 132 3 3 264 264 0x000000 0.5}
#${lua conky_draw_bg 98 37 37 196 196 0xFFFFFF 0.2}
#${lua conky_draw_bg 68 67 67 136 136 0x000000 0.4}
#${lua conky_draw_bg 35 100 100 70 70 0x000000 0.3}
${voffset 10}${goto 150}${font BlackChancery:bold:size=15}${color1}/root
${voffset -10}${goto 125}${font BlackChancery:size=10}Used ${goto 190}${fs_used /}
${goto 125}Size ${goto 190}${fs_size /}
${goto 145}${font BlackChancery:bold:size=15}${color1}/home
${voffset -10}${goto 125}${font BlackChancery:size=10}Used ${goto 190}${fs_used /home}
${goto 125} Size${goto 190}${fs_size /home}
${goto 132}${font BlackChancery:bold:size=15}${color1}External
${voffset -5}${goto 122}${font BlackChancery:size=12}Used ${goto 190}${fs_used /media/external}
${goto 122}Size${goto 190}${fs_size /media/external}
${goto 138}${font BlackChancery:bold:size=15}${color1}Videos
${voffset -5}${goto 122}${font BlackChancery:size=12}Used ${goto 190}${fs_used /media/sdb1}
${goto 122}Size${goto 190}${fs_size /media/sdb1}
${goto 148}${font BlackChancery:size=20}${hddtemp /dev/sdb}F
${voffset -9}${goto 128}${font BlackChancery:bold:size=15}${color1}Software
${voffset -5}${goto 122}${font BlackChancery:size=12}Used ${goto 190}${fs_used /media/sdd1}
${goto 122}Size${goto 190}${fs_size /media/sdd1}
${goto 148}${font BlackChancery:size=20}${hddtemp /dev/sdd}F
${voffset -15}${goto 134}${font BlackChancery:bold:size=15}${color1}Storage
${voffset -5}${goto 122}${font BlackChancery:size=12}Used ${goto 190}${fs_used /media/storage}
${goto 122}Size${goto 190}${fs_size /media/storage}
${goto 148}${font BlackChancery:size=20}${hddtemp /dev/sdc}F
conky_weather
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# fiddle with window
use_spacer yes
use_xft yes
# Update interval in seconds
update_interval 3
# Minimum size of text area
minimum_size 1100 200
maximum_width 1100
override_utf8_locale yes
# Draw shades?
draw_shades yes
# Text stuff
draw_outline yes # amplifies text if yes
draw_borders no
#font
xftfont Arial:size=9
uppercase no # set to yes if you want all text to be in uppercase
# Stippled borders?
stippled_borders 3
# border margins
border_margin 9
# border width
border_width 10
# Default colors and also border colors, grey90 == #e5e5e5
default_color cbcbcb
own_window_colour brown
own_window_transparent yes
# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right
alignment top_middle
# Gap between borders of screen and text
gap_x -965
gap_y 30
imlib_cache_size 0
TEXT
${texeci 500 bash $HOME/Accuweather_Conky_USA_Images/acc_usa_images}${image $HOME/Accuweather_Conky_USA_Images/cc.png -p 0,70 -s 180x108}
${font BlackChancery:bold:size=15}${execpi 600 sed -n '3p' $HOME/Accuweather_Conky_USA_Images/curr_cond}${font BlackChancery:bold:size=12}${goto 525}${execpi 600 sed -n '6p' $HOME/Accuweather_Conky_USA_Images/tod_ton} ${goto 750}${execpi 600 sed -n '11p' $HOME/Accuweather_Conky_USA_Images/tod_ton} ${goto 975} ${execpi 600 sed -n '16p' $HOME/Accuweather_Conky_USA_Images/tod_ton}${font BlackChancery:bold:size=10}
${goto 200}TEMP:$color${goto 325}${execpi 600 sed -n '4p' $HOME/Accuweather_Conky_USA_Images/curr_cond}°F (${execpi 600 sed -n '5p' $HOME/Accuweather_Conky_USA_Images/curr_cond}°F)
${goto 200}WIND:$color${goto 325}${execpi 600 sed -n '6p' $HOME/Accuweather_Conky_USA_Images/curr_cond} ${execpi 600 sed -n '14p' $HOME/Accuweather_Conky_USA_Images/curr_cond}
${goto 200}HUM:$color${goto 325}${execpi 600 sed -n '7p' $HOME/Accuweather_Conky_USA_Images/curr_cond}
${goto 200}DEW:$color${goto 325}${execpi 600 sed -n '11p' $HOME/Accuweather_Conky_USA_Images/curr_cond}
${goto 200}SUNRISE:$color${goto 325}${execpi 600 sed -n '15p' $HOME/Accuweather_Conky_USA_Images/curr_cond}
${goto 200}SUNSET:$color${goto 325}${execpi 600 sed -n '16p' $HOME/Accuweather_Conky_USA_Images/curr_cond}
${image $HOME/Accuweather_Conky_USA_Images/7.png -p 480,50 -s 180x108}
${image $HOME/Accuweather_Conky_USA_Images/12.png -p 705,50 -s 180x108}
${image $HOME/Accuweather_Conky_USA_Images/17.png -p 930,50 -s 180x108}
s11_clock
rings.lua
[code]
--[[ RINGS with SECTORS widget
v1.0 by wlourf (08.08.2010)
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display,
for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable,
for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach,
for example for {$cpu cpu0}, just write max=100
Optional parameters:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
v1.0 (08 Aug. 2010) original release
]]
require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={
{
name="cpu",
arg="cpu1",
max=100,
xc=99.5,
yc=347.5,
start_angle=0,
end_angle=360,
thickness=7,
radius=25,
sectors=40,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="cpu",
arg="cpu2",
max=100,
xc=188.5,
yc=345.5,
start_angle=0,
end_angle=360,
thickness=7,
radius=25,
sectors=40,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="cpu",
arg="cpu3",
max=100,
xc=188.5,
yc=410.5,
start_angle=0,
end_angle=360,
thickness=7,
radius=25,
sectors=40,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="cpu",
arg="cpu4",
max=100,
xc=99.5,
yc=410.5,
start_angle=0,
end_angle=360,
thickness=7,
radius=25,
sectors=40,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="cpu",
arg="cpu0",
max=100,
xc=145.5,
yc=380.5,
start_angle=180,
end_angle=-180,
thickness=10,
radius=95,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="memperc",
arg="memperc",
max=100,
xc=145.5,
yc=575,
start_angle=180,
end_angle=-180,
thickness=10,
radius=95,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="swapperc",
arg="swapperc",
max=100,
xc=145.5,
yc=575,
start_angle=180,
end_angle=-180,
thickness=10,
radius=82,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
}
--END OF PARAMETERS HERE
--main function
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)
cr=cairo_create(cs)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
draw_ring(rings_settings[i])
end
end
cairo_destroy(cr)
end
function draw_ring(t)
local function rgba_to_r_g_b_a(tcolour)
colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name'" +
" with 'arg' or only parameter 'arg' ")
return
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
--initialize table
setup(t)
--[[grid
h=conky_window.height
w=conky_window.width
cairo_set_source_rgba(cr,1,1,1,1)
cairo_set_line_width(cr,0.5)
cairo_move_to(cr,0,t.yc)
cairo_line_to(cr,w,t.yc)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,0)
cairo_line_to(cr,t.xc,h)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,t.yc)
cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.radius)
cairo_line_to(cr,w,t.yc-t.radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.int_radius)
cairo_line_to(cr,w,t.yc-t.int_radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.gap_sectors)
cairo_line_to(cr,w,t.yc-t.gap_sectors)
cairo_stroke(cr)
cairo_set_source_rgba(cr,1,0,0,0.5)
cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
cairo_stroke(cr)
cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)
cairo_stroke(cr)
cairo_set_source_rgba(cr,0,1,0,1)
cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
cairo_stroke(cr)
--END GRID
]]
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
valueA = t.max/t.sectors
--first angle of a sector :
lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
function axis(ctx,alpha)
cairo_set_line_width(ctx,1)
cairo_set_source_rgba(ctx,1,0,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,150,0)
cairo_stroke(ctx)
cairo_set_source_rgba(ctx,0,1,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,0,150)
cairo_stroke(ctx)
end
[/code]
--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
21 Jun 2012 - Chronograph modifications by Sector11
22 Jun 2012 - again with mrpeachy's help day names, numbers and month names
12 Nov 2012 - memory leak plugged - mrpeachy
14 Nov 2012 - Personnalisation - Didier-T (forum Ubuntu.fr)
26 Nov 2012 - The Clock - Sector11 (small version)
use in conkyrc
lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT
-- INDEX
-- ### CLOCK POSITION - AND DEFAULTS ###
-- ### SET BORDER OPTIONS FOR "CLOCKS" ### -- I don't know how to remove this - NOT NEEDED
-- See lines 39 to 41 for overall size changes
-- ### START DIAL B ### Day Names Dial ###
-- See Lines 84 - 87 and 131 for changes
-- ### START DIAL C ### Month Names Dial ###
-- See Lines 150 -153 and 198 for changes
-- ### START DIAL D ### Day Numbers Dial ###
-- See Lines 234 & 265 for changes
-- ### START CLOCK A ###
-- See Lines & and 441 & 467 changes
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
NOTE: Putting ### CLOCK A ### last insures that it's functions are written
over the other dials.
]]
require 'cairo'
-- ### CLOCK POSITION - AND DEFAULTS ##########################################
local init={
center_x=135,
center_y=135,
radius=117,
lang="English", -- English French Greek Spanish
hour=12, -- 12 | 24
second=true, --true | false - Seconds: dots and numbers IF 12HR
line=false, -- true | false - Part Second Hand
color=0xFF0000, --color for day, day number and month IF NO SECOND HAND
alpha=1 --alpha for day, day number and month IF NO SECOND HAND
}
-- ONLY NEED ONE COPY OF THIS FUNCTION
function rgb_to_r_g_b(col,alp)
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
local colr, colg, colb, cola=rgb_to_r_g_b(init.color,init.alpha)
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)
cr = cairo_create(cs)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
-- ### CLOCK 12|24 HR SELECTOR ############################
local clock_type_A=init.hour
-- ############################ CLOCK 12|24 HR SELECTOR ###
-- ### SET BORDER OPTIONS FOR "CLOCKS" ####################
--local clock_border_width=0
-- set color and alpha for clock border
--local cbr,cbg,cbb,cba=1,1,1,1 -- full opaque white
-- gap from clock border to minute marks
local b_to_m=0
-- #################### SET BORDER OPTIONS FOR "CLOCKS" ###
-- ### START DIAL B ### Day Names Dial ####################
-- DIAL POSITION
local center_x=init.center_x
local center_y=init.center_y
local radius=22
-- FONT
cairo_select_font_face (cr, "BlackChancery", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 18)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Sun","Mon","Tue","Wed","Thr","Fri","Sat",} end
if init.lang == "French" then text_days={"dim","lun","mar","mer","jeu","ven","sam",} end
if init.lang == "Greek" then text_days={"ΔΕΥ","ΤΡΙ","ΤΕΤ","ΠΕΜ","ΠΑΡ","ΣΑΒ","ΚΥΡ",} end
if init.lang == "Spanish" then text_days={"dom","lun","mar","mie","jue","vie","sab",} end
local day_number=tonumber(os.date("%w"))
if init.handday == true then
for i=1,7 do
-- work out points
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
else
for i=1,7 do -- working out points
if day_number == i-1 then
cairo_set_source_rgba (cr,0,0,0,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0) -- non-active day names
end
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
--[[ INNER POINTS POSITION, radius smaller than text circle
local radius=7
for i=1,7 do
if day_number == i-1 then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.0) -- non-active
end
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end]]
end
-- ######################################### END DIAL B ###
-- ### START DIAL C ### Month Names Dial ##################
-- DIAL POSITION
local center_x=init.center_x --(+85)
local center_y=init.center_y
local radius=53
-- FONT
cairo_select_font_face (cr, "BlackChancery", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 18)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",} end
if init.lang == "French" then text_days={"jan","fév","mar","avr","mai","jui","jul","aôu","sep","oct","nov","déc",} end
if init.lang == "Greek" then text_days={"ΙΑΝ","ΦΕΒ","ΜΑΡ","ΑΠΡ","ΜΑΙ","ΙΟΥ","ΙΟΥ","ΑΥΓ","ΣΕΠ","ΟΚΤ","ΝΟΕ","ΔΕΚ",} end
if init.lang == "Spanish" then text_days={"ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic",} end
local this_month=tonumber(os.date("%m"))
if init.handmonth == true then
for i=1,12 do
-- OUTER POINTS POSTION FOR -- ### START DIAL D ## TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
else
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,0,0,0,1) -- active month colour
else
cairo_set_source_rgba (cr,1,1,1,0.0) -- non-active month names
end
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
--[[ INNER POINTS POSITION, radius smaller than text circle
local radius=38
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.0) -- dots for non-active month names
end
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end]]
end
-- ######################################### END DIAL C ###
-- ### START DIAL D ### Day Numbers Dial ##################
-- GET NUMBER OF DAYS IN CURRENT MONTH
-- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
if init.hour == 12 then
febdaynum=tonumber((os.difftime(t1,t2))/(12*60*60))
else
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
end
-- MONTH TABLE
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]
-- TEXT positioning
local center_x=init.center_x
local center_y=init.center_y
local radius=85
cairo_select_font_face (cr, "BlackChancery", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 32)
local this_day=tonumber(os.date("%d"))
for i=1,number_days do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
--only print even numbers
if math.mod(i, 2) == 0 and math.mod(this_day, 2)==0 then
text=string.format("%02d",i) --formats numbers to double digits
elseif math.mod(i, 2) ~= 0 and math.mod(this_day, 2)~=0 then
text=string.format("%02d",i) --formats numbers to double digits
else
text=""
end --odd even matching
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
if i==this_day then
cairo_set_source_rgba (cr,0,0,0,1) -- active colour
else
cairo_set_source_rgba (cr,0,0,0,0.2) -- dim inactive numbers
end
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
--[[ INNER POINTS POSITION, radius smaller than text circle
local radius=70
for i=1,number_days do
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
if i==this_day then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.2) -- dim the points
end
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
]]
-- ######################################### END DIAL D ###
-- ### START CLOCK A ######################################
-- SET MARKS ###
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=init.hour
-- set mark length
local m_length_A=0 -- doesn't work but can't delete
-- set mark width
local m_width_A=0 -- doesn't work but can't delete
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=0,0,0,0 -- opaque white -- doesn't work but can't delete
-- SETUP HOUR HANDS ###
-- CLOCK A HOUR HAND
hh_length_A=80
-- set hour hand width
hh_width_A=3
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
-- hhr,hhg,hhb,hha=1,0,1,0 -- fully opaque white --doesn't work
-- SETUP MINUTE HANDS ###
-- CLOCK A MINUTE HAND SETUP
-- set length of minute hand
mh_length_A=100
-- set minute hand width
mh_width_A=3
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
--mhr,mhg,mhb,mha=1,1,1,0.5 -- fully opaque white --doesn't work
-- SETUP SECOND HAND ###
-- CLOCK A SECOND HAND SETUP -- DOESN'T WORK - Why ???????????????????????????
-- set length of seconds hand -- yes I know it is commented out!
--sh_length_A=150
-- set hour hand width
--sh_width_A=2
-- set hour hand line cap
--sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
--shr,shg,shb,sha=1,0,0,1 -- fully opaque red
-- PART SECOND HAND
--position
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
if init.line == true then
local arc=(math.pi/180)*((360/60)*seconds)
--calculate point 1
local radius1=100
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=107
local x2=0+radius2*math.sin(arc)
local y2=0-radius2*math.cos(arc)
--draw line connecting points
cairo_move_to (cr, center_x+x1,center_y+y1)
cairo_line_to (cr, center_x+x2, center_y+y2)
cairo_set_source_rgba (cr,255/255,0/255,0/255,0) -- PART SECOND HAND
cairo_stroke (cr)
end
-- CLOCK A ### 12 HR TIME ###
-- CLOCK SETTINGS
clock_radius=0 --does not work
clock_centerx=init.center_x -- centre of Clock hands
clock_centery=init.center_y -- centre of Clock hands
-- DRAWING CODE
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A -- WHAT IS THIS??
-- set line cap type
cairo_set_line_cap (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_A)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end -- of for loop
-- HOUR MARKS -- ???????????????????????????????????????????????????????????????
-- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND ###
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A)) -- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,0,0,0,1) -- active colour Hour Hand ================
cairo_set_line_cap (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds just as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
cairo_set_source_rgba (cr,0,0,0,1) -- active colour Minute Hand ==============
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- ### CLOCK A ###
local center_x=init.center_x -- Centre of the HR / Min Numbers
local center_y=init.center_y -- Centre of the HR / Min Numbers
local radius=init.radius -- 12/24 HR CLOCK Hours/Minutes radius -- seeline 42
cairo_select_font_face (cr, "BlackChancery", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 35)
cairo_set_source_rgba (cr,0,0,0,1) -- HR Clock numbers
-- TABLE OF TEXT -- in order
if init.hour == 12 then
text_days={"12","01","02","03","04","05","06","07","08","09","10","11",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_set_source_rgba (cr,0,0,0,1)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=100 -- 12 HR Clock
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_set_source_rgba (cr,1,1,1,0)
cairo_stroke (cr)
end
end
if init.hour == 24 then
text_days={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
for i=1,24 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=101 -- 24 HR Clock
for i=1,24 do
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_set_source_rgba (cr,1,1,1,0)
cairo_stroke (cr)
end
end
-- ############################################################################
-- POSITION FOR TEXT HOUR NUMBERS
if init.hour == 12 and init.second == true then
text_days={"","01","02","03","04","","06","07","08","09","","11","12","13","14","","16","17","18","19","","21","22","23","24","","26","27","28","29","","31","32","33","34","","36","37","38","39","","41","42","43","44","","46","47","48","49","","51","52","53","54","","56","57","58","59","",}
-- INNER POINTS POSITION, radius smaller than text circle
cairo_set_source_rgba (cr,1,1,1,0) -- does not work -- settings moved
cairo_select_font_face (cr, "BlackChancery", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
for i=1,60 do
local radius=100 -- dots for seconds A Clock
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
if seconds == i-1 then
cairo_set_source_rgba (cr,255/255,0/255,0/255,0) -- does not work - settings moved
else
if i-1 == 0 or i-1 == 5 or i-1 == 10 or i-1 == 15 or i-1 == 25 or i-1 == 30 or i-1 == 35 or i-1 == 40 or i-1 == 45 or i-1 == 50 or i-1 == 55 then
cairo_set_source_rgba (cr,1,1,1,0) -- active colour
else
cairo_set_source_rgba (cr,0,1,1,0) -- dots for seconds A Clock
end
end
cairo_arc (cr,center_x+x,center_y+y,1/2,0,2*math.pi)
cairo_stroke (cr)
end
radius=radius-3
cairo_set_font_size (cr, 15)
for i=1,60 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
if seconds == tonumber(text) then
cairo_set_source_rgba (cr,0,0,0,0) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0) -- seconds numbers
end
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
end
-- ############################################################################
cairo_stroke (cr)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end -- end main function
rings_2.lua
--[[ RINGS with SECTORS widget
v1.0 by wlourf (08.08.2010)
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display,
for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable,
for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach,
for example for {$cpu cpu0}, just write max=100
Optional parameters:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
v1.0 (08 Aug. 2010) original release
]]
require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={
{
name="fs_used_perc",
arg="/",
max=100,
xc=175.5,
yc=125.5,
start_angle=180,
end_angle=-180,
thickness=10,
radius=95,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="fs_used_perc",
arg="/home",
max=100,
xc=175.5,
yc=125.5,
start_angle=180,
end_angle=-180,
thickness=10,
radius=82,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="fs_used_perc",
arg="/media/external",
max=100,
xc=175.5,
yc=325.5,
start_angle=180,
end_angle=-180,
thickness=10,
radius=95,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="fs_used_perc",
arg="/media/sdb1",
max=100,
xc=175.5,
yc=525.5,
start_angle=180,
end_angle=-180,
thickness=10,
radius=95,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="fs_used_perc",
arg="/media/sdd1",
max=100,
xc=175.5,
yc=725.5,
start_angle=180,
end_angle=-180,
thickness=10,
radius=95,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
{
name="fs_used_perc",
arg="/media/storage",
max=100,
xc=175.5,
yc=925.5,
start_angle=180,
end_angle=-180,
thickness=10,
radius=95,
sectors=130,
gap_sectors=1,
bg_colour1={{0.5,0x000000,.15}},
fg_colour1={{0.5,0x000000,1}},
fg_colour2={{0.5,0x660000,1}},
},
}
--END OF PARAMETERS HERE
--main function
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)
cr=cairo_create(cs)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
draw_ring(rings_settings[i])
end
end
cairo_destroy(cr)
end
function draw_ring(t)
local function rgba_to_r_g_b_a(tcolour)
colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name'" +
" with 'arg' or only parameter 'arg' ")
return
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
--initialize table
setup(t)
--[[grid
h=conky_window.height
w=conky_window.width
cairo_set_source_rgba(cr,1,1,1,1)
cairo_set_line_width(cr,0.5)
cairo_move_to(cr,0,t.yc)
cairo_line_to(cr,w,t.yc)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,0)
cairo_line_to(cr,t.xc,h)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,t.yc)
cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.radius)
cairo_line_to(cr,w,t.yc-t.radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.int_radius)
cairo_line_to(cr,w,t.yc-t.int_radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.gap_sectors)
cairo_line_to(cr,w,t.yc-t.gap_sectors)
cairo_stroke(cr)
cairo_set_source_rgba(cr,1,0,0,0.5)
cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
cairo_stroke(cr)
cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)
cairo_stroke(cr)
cairo_set_source_rgba(cr,0,1,0,1)
cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
cairo_stroke(cr)
--END GRID
]]
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
valueA = t.max/t.sectors
--first angle of a sector :
lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
function axis(ctx,alpha)
cairo_set_line_width(ctx,1)
cairo_set_source_rgba(ctx,1,0,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,150,0)
cairo_stroke(ctx)
cairo_set_source_rgba(ctx,0,1,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,0,150)
cairo_stroke(ctx)
end
You can find:
Teos weather scripts here
VastOnes Gmusic Browser howto here
and heres what it looks like:
Monitor #1
Monitor #2
Under a load
Last edited by lwfitz (2012-12-18 08:37:13)
Conky | SMXI HowTo | Super Grub | VastOnes GMB HowTo | VSIDO
Offline
Hi All !
The Last ConkyForecast:
fired
Sorry...I will may be fired... ]:D
Offline
i want to make a countdown similar like the built in countdown within conky-forecast. i do not want to install conkyForecast for only one feature!
xxx hours xxx minutes daylight or
xxx hours xxx minutes till sunset or
xxx hours xxx minutes till sunrise
i've tried doing it within lua. i've started with this:
function countdown_sonne()
-- sonnenaufgang 08:09 uhr
-- sonnenuntergang 16:14 uhr
-- time of the sunrise
local sunrise_h=dropZero(string.sub(sun_rise_24[1],1,2)) -- 8
local sunrise_m=dropZero(string.sub(sun_rise_24[1],4,5)) -- 9
-- sonnenaufgang für den nächsten tag
local vorschau_srh=dropZero(string.sub(sun_rise_24[2],1,2))
local vorschau_srm=dropZero(string.sub(sun_rise_24[2],4,5))
-- time of the sunset
local sunset_h=dropZero(string.sub(sun_set_24[1],1,2)) -- 16
local sunset_m=dropZero(string.sub(sun_set_24[1],4,5)) -- 14
-- mitternacht / midnight
local mitternacht_h=23 -- hours
local mitternacht_m=60 -- minutes
-- actual time
local akt_stunde=dropZero(tonumber(os.date("%H")))
local akt_minute=dropZero(tonumber(os.date("%M")))
-- zeit bis mitternacht / time till midnight
teil_1=mitternacht_h-akt_stunde -- stunden bis mitternacht
teil_2=mitternacht_m-akt_minute -- minuten bis mitternacht
-- zeit von jetzt bis sonnenaufgang am nächsten tag
zeit='Sonnenaufgang in '..(teil_1+vorschau_srh)..'h '..(teil_2+vorschau_srm)..'m'
-- stunden von sonnenaufgang
--zeit=sunset_h-akt_stunde
return zeit
end
can u help me please?
this is my actual screenshot: http://i.imgbox.com/acdibt5j.png
regards, alex
Last edited by lionhead (2012-12-18 16:36:06)
Offline
Hi All !
The Last ConkyForecast:
fired
Sorry...I will may be fired... ]:D
HAHAHAHAHA!! That is great! Yes fired ... you'll be a crispy critter (créature brûlée) long before 999° hits.
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
Just wanted to let everyone know that I have updated my download for the lua scripts I have made (link in signature). I was also wondering if anyone knows why I am having a problem with moc info showing in conky? Is there more I need to have installed then conky and moc, maybe some add-on that makes the information migrate better?
Offline
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