# pkill -xf "conky -c ~/Conky/The_Clock.conky" &
# Chronograph LUA - mrpeachy (originally 4 clocks - tweaked by Sector11)
### Begin Window Settings ##################################################
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour gray
own_window_class Conky
own_window_title Chronograph_mrpeachy
# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
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 0
minimum_size 320 320 ## width, height
#maximum_width 420 ## width
### For use with The-Clock.lua
#minimum_size 264 264 ## width, height
#maximum_width 264 ## width
gap_x 100 #15 ### left &right
gap_y 0 ### up & down
### alignment values or top_left, bottom_right, etc
# tl, tm, tr
# ml, mm, mr
# bl, bm, br
alignment tr
#################################################### End Window Settings ###
### Font Settings ##########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
#xftfont CorporateMonoExtraBold:size=9
xftfont monofur:bold:size=14
# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
#font 8x13
#font 9x15
#font *mintsmild.se*
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
###################################################### End Font Settings ###
### Color Settings #########################################################
draw_shades no
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
default_color DCDCDC #220 220 220 Gainsboro
color0 8FBC8F #143 188 143 DarkSeaGreen
color1 C2CCFF # Not a clue - a blue #778899 #119 136 153 LightSlateGray
color2 FF8C00 #255 140 0 DarkOrange
color3 7FFF00 #127 255 0 Chartreuse
color4 FFA07A #255 160 122 LightSalmon
color5 FFDEAD #255 222 173 NavajoWhite
color6 00BFFF # 0 191 255 DeepSkyBlue
color7 00FFFF # 0 255 255 Cyan
color8 FFFF00 #255 255 0 Yellow
color9 B22222 #178 34 34 FireBrick
##################################################### End Color Settings ###
### Borders Section ########################################################
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
##################################################### End Borders Secton ###
### Miscellaneous Section ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background yes
# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none
# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 256
# Subtract (file system) buffers from used memory?
no_buffers yes
# change GiB to G and MiB to M
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
# If enabled, values which are in bytes will be printed in human readable
# format (i.e., KiB, MiB, etc). If disabled, bytes is printed instead
format_human_readable yes
# Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off.
short_units yes
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
############################################## End Miscellaneous Section ###
### LUA Settings ###########################################################
## draw-bg.lua
##
#lua_load ~/Chrono-TEST/LUA/draw-bg.lua
################### Chronograph ##############################################
lua_load /media/DATEN/francescoPC/Conky/mpearchy/cronograph/crono.lua
#lua_draw_hook_post main
lua_draw_hook_pre main
############################## End LUA Settings ###
update_interval 1
TEXT
--chronograph mrpeachy 12/13/12 - i blame sector11 for starting the whole chronograph thing!
require 'cairo'
extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
function conky_main()
if conky_window == nil then return end
local updates=tonumber(conky_parse("${updates}"))
if updates<=3 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)
--#########################################################################################################
--defaults
default_font_name="White Rabbit"
default_font_size=22
default_font_face="n"
default_hex_color=0xffffff
default_alpha=1
default_red=1
default_green=1
default_blue=1
default_horizontal_justify="l" --"l"=left, "r"=right, "c"=center
default_vertical_justify="n" --"n"=normal, "nb"=normal-ybearing, "m"=middle, "mb"=middle-ybearing, "t"=top
default_rotation="0"
--font({f="name",fs=size,ff="face"}) face="n" or "b" or "i" or "bi"
--hexcolor({c=hexcolor,a=alpha})
--rgbcolor({r=,g=,b=,a=})
--text({x=x,y=y,t="text",hj=horizontal_justify,vj=vertical_justify,r=rotation})
--set center coordinates
centx,centy=200,200
--########################################################################################
--background circle
hexcolor({c=0x212121})
cairo_arc(cr,centx,centy,118,0,2*math.pi)
cairo_fill(cr)
--background circle
hexcolor({c=0x3c3c3c})
cairo_arc(cr,centx,centy,108,0,2*math.pi)
cairo_fill(cr)
--setup font and color
font({})
hexcolor({c=0xccaa7a})
--draw numbers and dots around main circle
for i=1,12 do
if i==12 or i==4 or i==8 then
x,y=pt(centx,centy,84,((360/12)*i))
text({y=y,x=x,t=i,hj="c",vj="m"})
end
if i==2 or i==6 or i==10 then
hexcolor({c=0xdac09b})
x,y=pt(centx,centy,98,((360/12)*i))
cairo_arc(cr,x,y,6,0,2*math.pi)
cairo_fill(cr)
else
hexcolor({c=0xccaa7a})
x,y=pt(centx,centy,98,((360/12)*i))
cairo_arc(cr,x,y,4,0,2*math.pi)
cairo_fill(cr)
end
end--for
--draw inbetween marks
cairo_set_line_width(cr,1)
for i=1,60 do
if string.find(i/5,"%.")~=nil then
x,y=pt(centx,centy,108,((360/60)*i))
cairo_move_to(cr,x,y)
x,y=pt(centx,centy,98,((360/60)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
end
end--for
--outer circle
cairo_arc(cr,centx,centy,108,0,2*math.pi)
cairo_stroke(cr)
--########################################################################################
--hours of day at 2 position
dcx,dcy=pt(centx,centy,98,60)
font({fs=8})
--numbers
for i=0,24,3 do
x,y=pt(dcx,dcy,68,180+((120/24)*i))
text({y=y,x=x,t=string.format("%02d",i),hj="c",vj="m"})
end--for
--marks
for i=0,24 do
if string.find(i/3,"%.")~=nil and i~=0 then
x,y=pt(dcx,dcy,60,180+((120/24)*i))
cairo_move_to(cr,x,y)
x,y=pt(dcx,dcy,56,180+((120/24)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
else
x,y=pt(dcx,dcy,58,180+((120/24)*i))
cairo_arc(cr,x,y,1.5,0,2*math.pi)
cairo_fill(cr)
end
end
--day name
font({fs=22})
dtx,dty=pt(dcx,dcy,30,180+60)
text({x=dtx,y=dty,t=string.upper(os.date("%a")),hj="c",vj="m"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
hour=tonumber(os.date("%H"))
dpx,dpy=pt(dcx,dcy,54,180+(120*(hour/24)))
cairo_move_to(cr,dcx,dcy)
cairo_line_to(cr,dpx,dpy)
cairo_stroke(cr)
--########################################################################################
--days of month at 6 position
font({fs=8})
hexcolor({c=0xccaa7a})
cairo_set_line_width(cr,1)
mcx,mcy=pt(centx,centy,98,180)
--date calcs
local year=os.date("%G")
local today=tonumber(os.date("%d"))
local t1 = os.time({year=year,month=03,day=01,hour=00,min=0,sec=0});
local t2 = os.time({year=year,month=02,day=01,hour=00,min=0,sec=0});
local feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={31,feb,31,30,31,30,31,31,30,31,30,31}
local month=os.date("%m")
local mdays=monthdays[tonumber(month)]
--marks
for i=1,mdays do
if string.find((i-1)/3,"%.")~=nil then
x,y=pt(mcx,mcy,60,300+((120/mdays)*i))
cairo_move_to(cr,x,y)
x,y=pt(mcx,mcy,56,300+((120/mdays)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
else
x,y=pt(mcx,mcy,60,300+((120/mdays)*i))
cairo_move_to(cr,x,y)
x,y=pt(mcx,mcy,54,300+((120/mdays)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
end
end--for
--numbers
for i=1,mdays,3 do
x,y=pt(mcx,mcy,68,300+((120/mdays)*i))
text({y=y,x=x,t=string.format("%02d",i),hj="c",vj="m"})
end--for
--month name
font({fs=22})
text({x=mcx,y=mcy-30,t=string.upper(os.date("%b")),hj="c",vj="m"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
day=tonumber(os.date("%e"))
mpx,mpy=pt(mcx,mcy,52,300+(120*(day/mdays)))
cairo_move_to(cr,mcx,mcy)
cairo_line_to(cr,mpx,mpy)
cairo_stroke(cr)
--########################################################################################
--months of year at 10 position
font({fs=8})
hexcolor({c=0xccaa7a})
cairo_set_line_width(cr,1)
ycx,ycy=pt(centx,centy,98,5*60)
--date calculations
td=0
for i=1,12 do
td=td+monthdays[i]
end
angle={}
ang=0
for i=1,12 do
ang=((monthdays[i]/td)*120)+ang
angle[i]=ang
end
months={"J","F","M","A","M","J","J","A","S","O","N","D"}
--arc line
cairo_arc(cr,ycx,ycy,60,adeg(60),adeg(60+ang))
cairo_stroke(cr)
--arc marks
for i=0,12 do
x,y=pt(ycx,ycy,60,60+((angle[i] or 0)))
cairo_move_to(cr,x,y)
x,y=pt(ycx,ycy,56,60+((angle[i] or 0)))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
end
--month letters
for i=1,12 do
x,y=pt(ycx,ycy,68,60+((120/12)*i)-(120/24))
text({y=y,x=x,t=months[i],hj="c",vj="m"})
end--for
--year text
font({fs=22})
ytx,yty=pt(ycx,ycy,30,60+60)
text({x=ytx,y=yty,t=string.upper(os.date("%y")),hj="c",vj="m"})
font({fs=12})
text({x=ytx-4,y=yty-10,t="20",hj="c",vj="n"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
today=tonumber(os.date("%j"))-1
ypx,ypy=pt(ycx,ycy,55,60+(120*(today/td)))
cairo_move_to(cr,ycx,ycy)
cairo_line_to(cr,ypx,ypy)
cairo_stroke(cr)
--center circle
hexcolor({c=0xdac09b,a=1})
cairo_arc(cr,centx,centy,5,0,2*math.pi)
cairo_stroke(cr)
--hand calculations #######################################################
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
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*12))
--call hand drawing function
--hexcolor({c=0xccaa7a,a=0.8})
hexcolor({c=0xdac09b,a=0.8})
cairo_set_line_width(cr,2)
hands(
centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y
hsec_degs,--string or value for hand degrees
70,--string or value for hand length (radius)
3,--set hand center width in pixels
10,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.9--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)
--[[hands(
centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y
hsec_degs+180,--string or value for hand degrees
30,--string or value for hand length (radius)
6,--set hand center width in pixels
18,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
.8--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)--]]
--MINUTES HAND
--hexcolor({c=0xdac09b,a=0.8})
hands(
200,--string or coodinate for clock center x
200,--string or coodinate for clock center y
360*((m_to_s+seconds)/(60*60)),--string or value for hand degrees
90,--string or value for hand length (radius)
3,--set hand center width in pixels
8,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.9--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)
--[[hands(
200,--string or coodinate for clock center x
200,--string or coodinate for clock center y
180+(360*((m_to_s+seconds)/(60*60))),--string or value for hand degrees
30,--string or value for hand length (radius)
4,--set hand center width in pixels
18,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.8--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)--]]
--#########################################################################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end--end main function
--this function draws hands
function hands(clock_centerx,clock_centery,degrees,length,hand_center_width,hand_mid_width,hand_end_width,distance_to_mid)
--draw_middle
--calc start point
xs,ys=pt(clock_centerx,clock_centery,hand_center_width,degrees-90)
cairo_move_to(cr,xs,ys)
x1,y1=pt(clock_centerx,clock_centery,length*distance_to_mid,degrees-(hand_mid_width/2))
cairo_line_to (cr,x1,y1)
x2,y2=pt(clock_centerx,clock_centery,length,degrees)
cairo_arc(cr,x2,y2,hand_end_width,(degrees+180)*(math.pi/180),(degrees)*(math.pi/180))
--cairo_line_to (cr,x2,y2)
x3,y3=pt(clock_centerx,clock_centery,length*distance_to_mid,degrees+(hand_mid_width/2))
cairo_line_to (cr,x3,y3)
--calc end point
xe,ye=pt(clock_centerx,clock_centery,hand_center_width,degrees+90)
cairo_line_to (cr,xe,ye)
cairo_arc(cr,clock_centerx,clock_centery,hand_center_width,(degrees)*(math.pi/180),(degrees+180)*(math.pi/180))
cairo_fill(cr)
end
function adeg(deg)
return(math.pi/180)*(deg-90)
end
function pt(px,py,prad,pdeg)
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1
end
function font(fontt)
local name=fontt.f or default_font_name or "mono"
local size=fontt.fs or default_font_size or 12
local face=fontt.ff or default_font_face or "n"
if face=="n" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="b" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
elseif face=="i" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="bi" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD)
end
cairo_set_font_size(cr,size)
end
function hexcolor(hexcolort)
local col=hexcolort.c or default_hex_color or 0xffffff
local a=hexcolort.a or default_alpha or 1
local r,g,b=((col/0x10000) % 0x100)/255,((col/0x100) % 0x100)/255,(col % 0x100)/255
cairo_set_source_rgba(cr,r,g,b,a)
end
function rgbcolor(rgbcolort)
local r=rgbcolort.r or default_red or 1
local g=rgbcolort.g or default_green or 1
local b=rgbcolort.b or default_blue or 1
local a=rgbcolort.a or default_alpha or 1
cairo_set_source_rgba(cr,r,g,b,a)
end
function text(textt)
local x=textt.x or 100
local y=textt.y or 100
local t=textt.t or "set txt"
local hj=textt.hj or default_horizontal_justify or "l"
local vj=textt.vj or default_vertical_justify or "n"
local r=textt.r or default_rotation or 0
cairo_text_extents(cr,t,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
--hl-- l=left, c=center, r=right
if hj=="l" then
xa=x-bx
rad=0
elseif hj=="c" then
xa=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
xa=x-wx
rad=wx-bx
else
print ('hj not set correctly for text: '..t..' - "l", "c" or "r"')
xa=0
rad=0
end
--vj-- n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
ya=y
rad2=0
ry=by
elseif vj=="nb" then
ya=y-by
rad2=-by
ry=by
elseif vj=="m" then
ya=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
ya=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
ya=y+hy-by
rad2=hy-by
ry=0+by
else
print ('vj not set correctly for text: '..t..' - "n", "nb", "m", "mb" or "t"')
ya=0
rad2=0
ry=0
end
--rotation
if r~=0 then
local x2,y2=pt(x,y,rad2,r-180)
local x1,y1=pt(x2,y2,rad,r-90)
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*r)
cairo_show_text (cr,t)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,xa,ya)
cairo_show_text (cr,t)
cairo_stroke (cr)
end--if ro
--set non local variables to nil
xa=nil;ya=nil;rad=nil;rad2=nil;ry=nil
end--function text ###################################################################
Ich beschuldige Sektor11 zum Starten der ganzen Chronographen-Sache!
# killall conky && conky -c ~/Conky/The_Clock.conky &
#
# Thank you:
# Chronograph LUA - mrpeachy (originally 4 clocks - tweaked by Sector11)
# v9000 LUA weather - mrpeachy
# background - londonali1010, mrpeachy, dk75
# mounted.lua - mrpeachy
### Begin Window Settings ##################################################
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour gray
own_window_class Conky
own_window_title Chronograph TEST
# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
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 0
#minimum_size 420 420 ## width, height
#maximum_width 420 ## width
### For use with The-Clock.lua
minimum_size 264 264 ## width, height
maximum_width 264 ## width
gap_x 10 #15 ### left &right
gap_y 10 ### up & down
### alignment values or top_left, bottom_right, etc
# tl, tm, tr
# ml, mm, mr
# bl, bm, br
alignment tl
#################################################### End Window Settings ###
### Font Settings ##########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
#xftfont CorporateMonoExtraBold:size=9
xftfont monofur:bold:size=14
# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
#font 8x13
#font 9x15
#font *mintsmild.se*
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
###################################################### End Font Settings ###
### Color Settings #########################################################
draw_shades no
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
default_color DCDCDC #220 220 220 Gainsboro
color0 8FBC8F #143 188 143 DarkSeaGreen
color1 C2CCFF # Not a clue - a blue #778899 #119 136 153 LightSlateGray
color2 FF8C00 #255 140 0 DarkOrange
color3 7FFF00 #127 255 0 Chartreuse
color4 FFA07A #255 160 122 LightSalmon
color5 FFDEAD #255 222 173 NavajoWhite
color6 00BFFF # 0 191 255 DeepSkyBlue
color7 00FFFF # 0 255 255 Cyan
color8 FFFF00 #255 255 0 Yellow
color9 B22222 #178 34 34 FireBrick
##################################################### End Color Settings ###
### Borders Section ########################################################
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
##################################################### End Borders Secton ###
### Miscellaneous Section ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background yes
# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none
# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 256
# Subtract (file system) buffers from used memory?
no_buffers yes
# change GiB to G and MiB to M
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
# If enabled, values which are in bytes will be printed in human readable
# format (i.e., KiB, MiB, etc). If disabled, bytes is printed instead
format_human_readable yes
# Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off.
short_units yes
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
############################################## End Miscellaneous Section ###
### LUA Settings ###########################################################
## draw-bg.lua
##
lua_load ~/Chrono-TEST/LUA/draw-bg.lua
################### Chronograph ##############################################
lua_load ~/Chrono-TEST/LUA/The_S11_Clock.lua
lua_draw_hook_post main
############################## End LUA Settings ###
update_interval 1
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}
--[[ 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=118,
lang="English", -- English French Greek Spanish
hour=24, -- 12 | 24
second=true, --true | false - Seconds: dots and numbers IF 12HR
line=true, -- 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, "CorporateMonoExtraBold", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14)
-- 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,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.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, "CorporateMonoExtraBold", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14)
-- 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,1,1,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, "Liquid Crystal", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 20)
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,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,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=1,1,1,0 -- opaque white -- doesn't work but can't delete
-- SETUP HOUR HANDS ###
-- CLOCK A HOUR HAND
hh_length_A=66
-- set hour hand width
hh_width_A=4
-- 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=2
-- 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,1) -- 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,1,1,0.7) -- 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,1,1,0.7) -- 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, "DS-Digital", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 22)
cairo_set_source_rgba (cr,1,1,1,1.0) -- 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,1,1,1,1.0)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=101 -- 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.5)
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.5)
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.2) -- does not work -- settings moved
cairo_select_font_face (cr, "monofur", 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.3) -- 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,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,0,1,1,0.5) -- 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, 10)
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,1,1,1.0) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.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
--[[Background originally by londonali1010 (2009)
ability to set any size for background mrpeachy 2011
ability to set variables for bg in conkyrc dk75
the change is that if you set width and/or height to 0
then it assumes the width and/or height of the conky window
so:
Above and After TEXT (requires a composite manager or it blinks!)
lua_load ~/wea_conky/draw_bg.lua
TEXT
${lua conky_draw_bg 10 0 0 0 0 0x000000 0.2}
OR Both above TEXT (no composite manager required - no blinking!)
lua_load ~/wea_conky/draw_bg.lua
lua_draw_hook_pre draw_bg 10 0 0 0 0 0x000000 0.2
TEXT
Note
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.2}
See below: 1 2 3 4 5 6 7
${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
covers the whole window and will change if you change the minimum_size setting
1 = 20 corner_radius
2 = 0 x_position l|r
3 = 0 y_position u|d
4 = 0 width
5 = 0 height
6 = 0x000000 color
7 = 0.4 alpha
######### calendar function ##################################################
then to use it, you activate the calendar function BELOW TEXT like this
${lua luacal {settings}}
#${lua luacal {x=,y=,tf="",tfs=,tc=,ta=,bf="",bfs=,bc=,ba=,hf="",hfs=,hc=,ha=,sp="",gh=,gt=,gv=,sd=}}
# x=x position top left
# y=y position top left
# tf=title font, eg "mono" must be in quotes
# tfs=title font size
# tc=title color
# ta=title alpha
# bf=body font, eg "mono" must be in quotes
# bfs=body font size
# bc=body color
# ba=body alpha
# hf=highlight font, eg "mono" must be in quotes
# hfs=highlight font size
# hc=highlight color
# ha=highlight alpha
# sp=spacer, eg " " or sp="0"... 0,1 or 2 spaces can help with positioning of non-monospaced fonts
##### GAPS #####
# gt=gap from title to body
# gh=gap horizontal between columns
# gv=gap vertical between rows
# sd=start day, 0=Sun, 1=Mon
# hstyle = heading style, 0=just days, 1=date insert
# tdf=title date font, eg "mono" must be in quotes
# tdfs=title date font size
# tdc=title date color
# tda=title date alpha
# test line
-- ${lua luacal {x=20,y=100,tf="Monofur",tfs=24,tc=0xFFDEAD,ta=1,bf="Monofur",bfs=24,bc=0xFFDEAD,ba=1,hf="Monofur",hfs=24,hc=0x00BFFF,ha=1,sp="0",gh=60,gt=26,gv=20,sd=0,hstyle=1,tdf="Monofur",tdfs=24,tdc=0x00BFFF,tda=1}}
]]
require 'cairo'
local cs, cr = nil
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function conky_draw_bg(r,x,y,w,h,color,alpha)
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
w=w
h=h
if w=="0" then w=tonumber(conky_window.width) end
if h=="0" then h=tonumber(conky_window.height) end
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end
-- ###### calendar function ##################################################
function conky_luacal(caltab) -- {x=,y=,tf="",tfs=,tc=,ta=,bf="",bfs=,bc=,ba=,hf="",hfs=,hc=,ha=,sp="",gt=,gh=,gv=,sd=,hstyle=,tdf=,tdfs=,tdc=,tda=}
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
--############################################################################
if caltab.x==nil then
caltab=loadstring("return" .. caltab)()
end
local cal_x=caltab.x
local cal_y=caltab.y
local tfont=caltab.tf or "mono"
local tfontsize=caltab.tfs or 12
local tc=caltab.tc or 0xffffff
local ta=caltab.ta or 1
local bfont=caltab.bf or "mono"
local bfontsize=caltab.bfs or 12
local bc=caltab.bc or 0xffffff
local ba=caltab.ba or 1
local hfont=caltab.hf or "mono"
local hfontsize=caltab.hfs or 12
local hc=caltab.hc or 0xff0000
local ha=caltab.ha or 1
local spacer=caltab.sp or " "
local gaph=caltab.gh or 20
local gapt=caltab.gt or 15
local gapl=caltab.gv or 15
local sday=caltab.sd or 0
local hstyle=caltab.hstyle or 0
--convert colors
--local font=string.gsub(font,"_"," ")
local tred,tgreen,tblue,talpha=rgb_to_r_g_b(tc,ta)
--main body text color
local bred,bgreen,bblue,balpha=rgb_to_r_g_b(bc,ba)
--highlight text color
local hred,hgreen,hblue,halpha=rgb_to_r_g_b(hc,ha)
--############################################################################
--calendar calcs
local year=os.date("%G")
local today=tonumber(os.date("%d"))
local t1 = os.time( { year=year,month=03,day=01,hour=00,min=0,sec=0} );
local t2 = os.time( { year=year,month=02,day=01,hour=00,min=0,sec=0} );
local feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={ 31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local day=tonumber(os.date("%w"))+1-sday
local day_num = today
local remainder=day_num % 7
local start_day=day-(day_num % 7)
if start_day<0 then start_day=7+start_day end
local month=os.date("%m")
local mdays=monthdays[tonumber(month)]
local x=mdays+start_day
local dnum={}
local dnumh={}
if mdays+start_day<36 then
dlen=35
plen=29
else
dlen=42
plen=36
end
for i=1,dlen do
if i<=start_day then
dnum[i]=" "
else
dn=i-start_day
if dn=="nil" then dn=0 end
if dn<=9 then dn=(spacer .. dn) end
if i>x then dn="" end
dnum[i]=dn
dnumh[i]=dn
if dn==(spacer .. today) or dn==today then
dnum[i]=""
end
if dn==(spacer .. today) or dn==today then
dnumh[i]=dn
place=i
else dnumh[i]=" "
end
end
end--for
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tfontsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
if hstyle==0 then
if tonumber(sday)==0 then
dys={"SU","MO","TU","WE","TH","FR","SA"}
else
dys={"MO","TU","WE","TH","FR","SA","SU"}
end
--draw calendar titles
elseif hstyle==1 then
if tonumber(sday)==0 then
dys={"SU","MO"," "," "," ","FR","SA"}
cairo_text_extents(cr,"MO",extents)
local s=extents.x_advance+gaph
local f=gaph*5
local tdfont=caltab.tdf or "mono"
local tdfontsize=caltab.tdfs or 12
local tdc=caltab.tdc or 0xffffff
local tda=caltab.tda or 1
cairo_select_font_face (cr, tdfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tdfontsize);
local tdred,tdgreen,tdblue,tdalpha=rgb_to_r_g_b(tdc,tda)
cairo_set_source_rgba (cr,tdred,tdgreen,tdblue,tdalpha)
local insert=os.date("%b %y")
cairo_text_extents(cr,insert,extents)
local w=extents.x_advance
cairo_move_to (cr, cal_x+((s+f)/2)-(w/2), cal_y)
cairo_show_text (cr,insert)
cairo_stroke (cr)
else
dys={"MO","TU"," "," "," ","SA","SU"}
cairo_text_extents(cr,"TU",extents)
local s=extents.x_advance+gaph
local f=gaph*5
local tdfont=caltab.tdf or "mono"
local tdfontsize=caltab.tdfs or 12
local tdc=caltab.tdc or 0xffffff
local tda=caltab.tda or 1
cairo_select_font_face (cr, tdfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tdfontsize);
local tdred,tdgreen,tdblue,tdalpha=rgb_to_r_g_b(tdc,tda)
cairo_set_source_rgba (cr,tdred,tdgreen,tdblue,tdalpha)
local insert=os.date("%b %y")
cairo_text_extents(cr,insert,extents)
local w=extents.x_advance
cairo_move_to (cr, cal_x+((s+f)/2)-(w/2), cal_y)
cairo_show_text (cr,insert)
cairo_stroke (cr)
end
end
--draw calendar titles
for i=1,7 do
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tfontsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
cairo_move_to (cr, cal_x+(gaph*(i-1)), cal_y)
cairo_show_text (cr, dys[i])
cairo_stroke (cr)
end
--draw calendar body
cairo_select_font_face (cr, bfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, bfontsize);
cairo_set_source_rgba (cr,bred,bgreen,bblue,balpha)
for i=1,plen,7 do
local fn=i
for i=fn,fn+6 do
cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
cairo_show_text (cr, dnum[i])
cairo_stroke (cr)
end
end
--highlight
cairo_select_font_face (cr, hfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, hfontsize);
cairo_set_source_rgba (cr,hred,hgreen,hblue,halpha)
for i=1,plen,7 do
local fn=i
for i=fn,fn+6 do
cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
cairo_show_text (cr, dnumh[i])
cairo_stroke (cr)
end
end
--############################################################################
caltab=nil
dlen=nil
plen=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end
-- end main function #########################################################
require 'cairo'
Lua bindings:
* Cairo
* Imlib2
#conky V1.9 configuration
update_interval 0.1
update_interval_on_battery 30
own_window yes
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager #sticky,
own_window_title conky_clock
own_window_argb_visual yes
own_window_transparent yes
minimum_size 200 200
#maximum_width 300
alignment tl
gap_x 20
gap_y 20
background no
draw_shades no
draw_outline no
draw_borders no
double_buffer yes
lua_load /media/DATEN/francescoPC/Conky/Uhren/SwissRailway/clock.lua
lua_shutdown_hook shutdown
lua_draw_hook_pre clock
TEXT
# http://crunchbang.org/forums/viewtopic.php?pid=281625#p281625
# To use #! in a conky use: ${exec echo '#!'}
# killall conky && conky -c ~/Conky/S11_24_white.conky &
background yes
update_interval 1
### Begin Window Settings ##################################################
own_window yes
own_window_type normal
own_window_transparent yes
#own_window_colour 1E90FF
own_window_hints undecorated,below,skip_taskbar,skip_pager #sticky,
#own_window_colour yellow
own_window_class 24HRClock
own_window_title 24HRClock
# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
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 override
#========================================
own_window_argb_visual yes
### When ARGB visuals are enabled, this use this to modify the alpha value
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
#own_window_argb_value 180
#=========================================
minimum_size 128 128 ## width, height
maximum_width 128 ## width, usually a good idea to equal minimum width
alignment tm
gap_x 295 # left-right
gap_y 60 # up-down
################################################### End Window Settings ###
### Font Settings #########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
xftfont Anonymous Pro:size=8
#xftfont WenQuanYi Macro Hei Mono:bold:size=8
#xftfont WenQuanYi Zen Hei Mono:bold:size=8
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 0
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
###################################################### End Font Settings ###
### Color Settings #########################################################
draw_shades yes
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
#default_color DCDCDC #Gainsboro
default_color 121212
color0 9ACD32 #YellowGreen
color1 778899 #LightSlateGrey
color2 FF8C00 #Darkorange
color3 7FFF00 #Chartreuse
color4 FFA07A #LightSalmon
color5 FFDEAD #NavajoWhite
color6 00BFFF #DeepSkyBlue
color7 00FFFF #Cyan 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #Red
##################################################### End Color Settings ###
### Borders Section ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 0
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders no #yes
default_graph_size 15 40
##################################################### End Borders Secton ###
### Miscellaneous Section ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background yes
# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none
# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 512
# Subtract (file system) buffers from used memory?
no_buffers yes
# change GiB to G and MiB to M
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
default_bar_size 120 20 # reverse to commandline and no comma: ${cpubar 20,102}
cpu_avg_samples 1
net_avg_samples 1
imlib_cache_size 0
############################################## End Miscellaneous Section ###
### LUA Settings ###########################################################
## Above and After TEXT - requires a composite manager or blinks.
##
# lua_load ~/Conky/LUA/draw-bg.lua
#TEXT
# ${lua conky_draw_bg 10 0 0 0 0 0x000000 0.6}
#
## ${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
##
## OR Both above TEXT (No composite manager required - no blinking!)
#
# lua_load ~/Conky/LUA/draw-bg.lua
# lua_draw_hook_pre draw_bg 125 0 0 0 0 0x000000 0.4
#
############## 12-24 Hour Clock #######################
lua_load /media/DATEN/francescoPC/Conky/Uhren/unbekannte/luaclock2412.lua
lua_draw_hook_pre main
#lua_load /media/DATEN/francescoPC/Conky/Uhren/unbekannte/transbg.lua
#lua_draw_hook_post draw_bg 32 0 0 0 0 0x140C0B 0.16
####################################################### End LUA Settings ###
# The all important - How often conky refreshes.
# If you have a "Crey" try: 0.2 - smokin' - but watch the CPU useage go UP!
TEXT
--[[drawing a clock in conkyrc
by mrpeachy - 12 March 2010
Edited by Sector11 for personal use - 12 Mar 2012
lua_load /path/clock.lua
lua_draw_hook_pre main
TEXT
]]
require 'cairo'
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)
--##############################################################################
-- SETTINGS AREA
--##############################################################################
-- image
-- how do I add images.
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")
--12 OR 24
-- local clock_type=24
local clock_type=12
--CLOCK SETTINGS
local clock_radius=64
local clock_centerx=64
local clock_centery=64
-- SET MARKS
--how many marks around edge
local number_marks=12 --24
--set mark length
local m_length=5
--set mark line width
local m_width=1
--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=1,1,1,1 --opaque white
--SET BORDER OPTIONS
local clock_border_width=0 --2
--set color and alpha for clock border
local cbr,cbg,cbb,cba=1,1,1,1 --full opaque white
--gap from clock border to hour marks
local b_to_m=5
--SECONDS HAND SETUP
--set length of seconds hand
local sh_length=12
--set hand width
local sh_width=1
--set hand line cap
local sh_cap=CAIRO_LINE_CAP_ROUND
--set seconds hand color
local shr,shg,shb,sha=0,1,1,0 --fully opaque cyan
--MINUTE HAND SETUP
--set length of minutes hand
local mh_length=56
--set hand width
local mh_width=1
--set hand line cap
local mh_cap=CAIRO_LINE_CAP_ROUND
--set minute hand color
local mhr,mhg,mhb,mha=1,1,1,1 --fully opaque white
--HOUR HAND SETUP
--set length of hour hand
local hh_length=40
--set hand width
local hh_width=2
--set hand line cap
local hh_cap=CAIRO_LINE_CAP_ROUND
--set hour hand color
local hhr,hhg,hhb,hha=1,1,1,1 --fully opaque white
--##############################################################################
-- END SETTINGS AREA
--##############################################################################
--DRAWING CODE
--draw border
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
--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
--set line cap type
cairo_set_line_cap (cr, m_cap)
--set line width
cairo_set_line_width (cr,m_width)
--set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
--start for loop
for i=1,number_marks do
--drawing code using the value of i to calculate degrees
--calculate start point for 12 oclock mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks))
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 oclock mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks))
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
--TIME CALCULATIONS ###########################
if clock_type==12 then
hours=tonumber(os.date("%I")) --12 hour clock
--convert hours to seconds
h_to_s=hours*60*60
elseif clock_type==24 then
hours=tonumber(os.date("%H")) --24 hour clock
--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 ############################
--convert hours, minutes & seconds to seconds
hsecs=h_to_s+m_to_s+seconds
--calculate number of degrees for each hand per second
hsec_degs=hsecs*(360/(60*60*clock_type)) -- USING AN EQUATION INSTEAD OF TYPING THE CALCULATION IN BECAUSE THE RESULT OF 360/43200 HAS DECIMAL PLACES
--set radius we will use to calculate hand points
radius=hh_length
--set our starting line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
--calculate coordinates for end of minutes 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)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap (cr, hh_cap)
cairo_stroke (cr)
--DRAW MINUTES HAND ############################
--convert minutes & seconds to seconds
msecs=m_to_s+seconds
--calculate degrees for the hand each second
msec_degs=msecs*0.1
--set radius we will use to calculate hand points
radius=mh_length
--set our starting line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
--calculate coordinates for end of minutes 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)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
--DRAW SECOND HAND #############################
--calculate degrees for each second the hand moves
sec_degs=seconds*6
--set radius we will use to calculate hand points
radius=sh_length
--set our starting line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
--calculate coordinates for end of second hand
point=(math.pi/180)*sec_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,sh_width)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap (cr, sh_cap)
cairo_stroke (cr)
--##############################################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
--[[Background originally by londonali1010 (2009)
ability to set any size for background mrpeachy 2011
ability to set variables for bg in conkyrc dk75
the change is that if you set width and/or height to 0
then it assumes the width and/or height of the conky window
so:
Above and After TEXT (requires a composite manager or it blinks!)
lua_load ~/wea_conky/draw_bg.lua
TEXT
${lua conky_draw_bg 10 0 0 0 0 0x000000 0.4}
OR Both above TEXT (no composite manager required - no blinking!)
lua_load ~/wea_conky/draw_bg.lua
lua_draw_hook_pre draw_bg 10 0 0 0 0 0x000000 0.5
TEXT
Note
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.4}
See below: 1 2 3 4 5 6 7
${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
covers the whole window and will change if you change the minimum_size setting
1 = 20 corner_radius
2 = 0 x_position
3 = 0 y_position
3 = 0 width
5 = 0 height
6 = 0x000000 color
7 = 0.4 alpha
]]
require 'cairo'
local cs, cr = nil
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function conky_draw_bg(r,x,y,w,h,color,alpha)
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
w=w
h=h
if w=="0" then w=tonumber(conky_window.width) end
if h=="0" then h=tonumber(conky_window.height) end
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end
Inzwischen bin ich bei Version 3 von dem Script und wollte es eigentlich schon längst hier einstellen.......nun ja es sind mir halt ein paar Dinge dazwischen gekommen.AndieY hat geschrieben:Die Vorhersage von Akkuweather ist mir zu unzuverlässig, also hab ich mir ein Script für Wetter.com geschrieben.
AndieY hat geschrieben:Problem2: wie kann ich anklickbare Links bzw Verknüpfungen zu lokal gespeicherten Websites in eine Conkyrc einbauen?
AndieY hat geschrieben:Problem2: wie kann ich anklickbare Links bzw Verknüpfungen zu lokal gespeicherten Websites in eine Conkyrc einbauen?
AndieY hat geschrieben:Problem1: von Zeit zu Zeit erzeugt Wget nur eine Leere Datei.....keine Ahnung warum genau, tritt nur Sporadisch auf.... Wie sage ich nun Wget das es versuchen soill die Datei erneut herunterzuladen anstatt mir eine 0Byte Datei zu erzeugen?
-O
nicht das ich hier die Arbeit auf jemanden anderen abwälzen möchte, aber das übersteigt meine Fähigkeiten. Hast du vielleicht mal ein Beispiel wie so was aussehen muss?Oder du legst das einfach in eine while-Schleife, die erst im Erfolgsfall wieder verlassen wird.
Conky: llua_do_call: function conky_weather execution failed: ...r11-1/McLovin/originalChronograph/chrono-weather.lua:96: attempt to perform arithmetic on global 'start_day' (a nil value)
Conky: llua_do_call: function conky_weather execution failed: ...r11-1/McLovin/originalChronograph/chrono-weather.lua:96: attempt to perform arithmetic on global 'start_day' (a nil value)
Conky: llua_do_call: function conky_weather execution failed: ...r11-1/McLovin/originalChronograph/chrono-weather.lua:96: attempt to perform arithmetic on global 'start_day' (a nil value)
Conky: llua_do_call: function conky_weather execution failed: ...r11-1/McLovin/originalChronograph/chrono-weather.lua:96: attempt to perform arithmetic on global 'start_day' (a nil value)
Conky: llua_do_call: function conky_weather execution failed: ...r11-1/McLovin/originalChronograph/chrono-weather.lua:96: attempt to perform arithmetic on global 'start_day' (a nil value)
start_day=1
--########################################################################################
--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=1
topy=240
ygap=80
# killall conky & conky -c /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/McLovin/McLovin_Chronograph.conky &
# mühsam gesucht @unklar im Dec.2016
######################
# - Conky settings - #
######################
background yes
update_interval 1
cpu_avg_samples 1
total_run_times 0
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 1024 #10240
imlib_cache_size 0 #10240
minimum_size 350 350
#maximum_width 350
#####################
# - Text settings - #
#####################
use_xft yes
xftfont monofur:size=10
#xftfont Antipasto:size=10
#xftfont CorporateMonoExtraBold:size=10
xftalpha 1 #.8
uppercase no
# Text alignment, other possible values are commented
#alignment middle_left
#alignment middle_middle
#alignment middle_right
#alignment top_middle
alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment bottom_middle
gap_x 5
gap_y 5
######################
# - Color settings - #
######################
default_color c3c3c3
default_shade_color gray
default_outline_color black
color0 c3c3c3 #mid gray
color1 FF0000 #red
color2 09FF00 #bright green
color3 007EFF #bright blue
color4 E3E3E3 #very light gray
color5 FF8600 #an orange shade
color6 CA8718 #a dust like color
color7 FFE500 #a darker yellow color
color8 C3FF00 #lime green
color9 00FCFF #sky blue
#############################
# - Window specifications - #
#############################
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour gray
own_window_class Conky
own_window_title Chronograph
own_window_argb_visual yes
own_window_argb_value 200
border_inner_margin 0
border_outer_margin 0
#########################
# - Graphics settings - #
#########################
draw_shades no #yes
draw_outline no
draw_borders no
stippled_borders 0
draw_graph_borders no
####################
# - LUA Settings - #
####################
lua_load /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/McLovin/letzteChronograph.lua
lua_draw_hook_post main
#lua_load /media/5/conky/McBars_McLovin/McBars/scripts/clock_rings.lua
#lua_draw_hook_pre clock_rings
# - WEATHER - #
lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
lua_load /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/McLovin/letzte-chrono-weather.lua
lua_load ~/LUA/draw-bg.lua
TEXT
${lua conky_draw_bg 15 0 0 0 0 0x000000 0.2}
--[[ 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
02 Nov 2012 - edited by McLovin to add the outside rings, and minute numbers
12 Nov 2012 - memory leak plugged - mrpeachy via arclance
use in conkyrc
lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT
-- INDEX (use find with):
-- ###### 12 OR 24 CLOCK FACE
-- SET BORDER OPTIONS ###### ALL CLOCKS
-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
-- CLOCK A ###### 24 HR TIME
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- ### START DIAL C ### Right - Month Names Dial ##########
-- ### START DIAL D ### Left - Day Numbers Dial ###########
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
-- CLOCK E HOUR HAND
-- CLOCK E MINUTE HAND SETUP
-- CLOCK E SECOND HAND SETUP
-- CLOCK E ###### 12 HR TIME
NOTE: Putting ### CLOCK A ### last insures that it's functions are written
over the other dials.
]]
require 'cairo'
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)
-- ########################################################
-- SETTINGS AREA
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")
-- ###### 12 OR 24 CLOCK FACE #############################
local clock_type_A=12 -- Large Main 24 HR Clock
local clock_type_E=12 -- Bottom - 12 HR Clock
-- ###### CLOCK SETTINGS ##################################
-- 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=1
-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- DIAL POSITION FOR TEXT
local center_x=175
local center_y=95
local radius=50
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,42/255,149/255,180/255,1) --(cr,194/255,204/255,255/255,1) --(cr,42/255,149/255,180/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"So","Mo","Di","Mi","Do","Fr","Sa",} -- English
--text_days={"Dom","Lun","Mar","Mie","Jue","Vie","Sab",} -- Spanish
--text_days={"dim","lun","mar","mer","jeu","ven","sam",} -- French
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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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
cairo_set_source_rgba (cr,195/255,195/255,195/255,1)
local radius=38
for i=1,7 do
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
-- DRAW HAND -- snaps to current day of week
cairo_set_source_rgba (cr,1,0,0,1)
local hand_length=30
local day_number=tonumber(os.date("%w"))
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
local hand_width=2
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END DIAL B #########################################
-- ########################################################
-- ### START DIAL C ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=260
local center_y=175
local radius=45
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,42/255,149/255,180/255,1) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",} -- English
--text_days={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic",} -- Spanish
--text_days={"jan","fév","mar","avr","mai","jui","jul","aôu","sep","oct","nov","déc",} -- French
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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
local radius=32
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_stroke (cr)
end
-- DRAW HAND -- snaps to current month
cairo_set_source_rgba (cr,1,0,0,1)
local this_month=tonumber(os.date("%m"))
local hand_length=28 --radius for this calculation
local point=(math.pi/180)*((360/12)*(this_month-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK C ########################################
-- ########################################################
-- ### START DIAL D ### Left - 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});
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
-- 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=95
local center_y=175
local radius=50
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 9)
cairo_set_source_rgba (cr,42/255,149/255,180/255,1) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
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, 1) == 0 then
--set text when even
text=string.format("%01d",i) --formats numbers to double digits
else
--set text when odd
text=""
end--odd even matching
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
local radius=42
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))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current DAY
cairo_set_source_rgba (cr,1,0,0,1)
local this_day=tonumber(os.date("%d"))
local hand_length=40--radius for this calculation
local point=(math.pi/180)*((360/number_days)*(this_day-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK D ########################################
-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- 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=1,1,0,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=25
-- set hour hand width
hh_width_E=2
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=35
-- set minute hand width
mh_width_E=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,0,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK E SECOND HAND SETUP
-- set length of seconds hand
sh_length_E=32
-- set hour hand width
sh_width_E=1
-- 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
-- CLOCK E ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=45
clock_centerx=175
clock_centery=260
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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_E
-- set line cap type
cairo_set_line_cap (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E 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_E))
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_E))
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-- MARKS AROUND CLOCK A
cairo_stroke (cr)
end-- of for loop
--[[ TIME CALCULATIONS CLOCK E
if clock_type_E==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_E==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 and draw it
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_E))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_E
-- 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)*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_E)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds 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_E
-- 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_E)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_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
cairo_set_line_width (cr,sh_width_E)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap (cr, sh_cap)
cairo_stroke (cr)
-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=260
local radius=45
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 11)
cairo_set_source_rgba (cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
--text_days={"12","01","02","03","04","05","06","07","08","09","10","11",}
-- FOR A 12 HOUR CLOCK WITH THE NUMBERS 13-00
text_days={"00","13","14","15","16","17","18","19","20","21","22","23",}
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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=32
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_stroke (cr)
end ]]
-- ### END CLOCK E ########################################
-- ########################################################
-- ### START CLOCK A ######################################
-- SET MARKS ##############################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=12
-- set mark length
local m_length_A=0
-- set mark width
local m_width_A=0
-- 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=1,1,1,1 -- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK A HOUR HAND
-- set length of hour hand
hh_length_A=120
-- set hour hand width
hh_width_A=4
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
cairo_set_source_rgba (cr,69/255,169/255,19/255,1)
-- SETUP MINUTE HANDS #####################################
-- CLOCK A MINUTE HAND SETUP
-- set length of minute hand
mh_length_A=140
-- set minute hand width
mh_width_A=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,0,0,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
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
-- CLOCK A ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=200
clock_centerx=175
clock_centery=175
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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
-- 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,hhr,hhg,hhb,hha)
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
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,mhr,mhg,mhb,mha)
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
--[[
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))BOLD
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap (cr, sh_cap)
cairo_stroke (cr)
]]
--[[ ####################################################################
-- outer part of a Hour hand
--position
local center_x=175
local center_y=175
--get seconds value
local seconds=tonumber(os.date("%I"))
--calculate rotation of second hand in degrees
local arc=(math.pi/180)*((360/12)*hours)
--calculate point 1
local radius1=90
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=140
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,1)
cairo_stroke (cr)]]
-- ####################################################################
-- outer part of a second hand
--position
local center_x=175
local center_y=175
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
local arc=(math.pi/180)*((360/60)*seconds)
--calculate point 1
local radius1=90
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=140
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,1)
cairo_stroke (cr)
-- ####################################################################
-- inner part of a second hand
--position
local center_x=175
local center_y=175
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
local arc=(math.pi/180)*((360/60)*seconds)
--calculate point 1
local radius1=1
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=90
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,169/255,169/255,169/255,1)
cairo_stroke (cr)
-- ####################################################################
-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=175
local radius=165
-- FONT
--[[cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 15)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=150
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_stroke (cr)
end
-- ####################################################################]]
-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=175
local radius=165
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 20)
cairo_set_source_rgba (cr,42/255,149/255,180/255,1) --(cr,42/255,149/255,180/255,1)_light blue --(cr,194/255,204/255,255/255,1)_light-gray -- (cr,1,1,1,1)_white
-- TABLE OF TEXT -- in order
text_days={"12","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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
--[[ CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
local extents=cairo_text_extents_t:create()
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]]
-- POSITION FOR TEXT MINUTE NUMBERS
local center_x=175
local center_y=175
local radius=160
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,1,1,1,128/255) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"","1","2","3","4","","6","7","8","9","","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","",}
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
local extents=cairo_text_extents_t:create()
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
cairo_set_source_rgba (cr,1,1,1,1)
local radius=150
for i=1,60 do
local point=(math.pi/180)*((360/60)*(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
--[[ HOUR POINTS CIRCLES, ##########Uncoment section to draw rings around numbers
local radius=162
for i=1,60 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,12,0,2*math.pi)
cairo_stroke (cr)
end]]
-- ### END CLOCK A ########################################
-- ########################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
--[[
The latest script is a lua only weather script. aka: v9000
http://crunchbanglinux.org/forums/topic/16100/weather-in-conky/
the file:
http://dl.dropbox.com/u/19008369/v9000.tar.gz
mrppeachys LUA Tutorial
http://crunchbanglinux.org/forums/topic/17246/how-to-using-lua-scripts-in-conky/
--sun_rise[n]
--sun_set[n]
--moon_rise[n]
--moon_set[n]
--now["time"]
--now["fc_hour1_time"]
--now["fc_hour2_time"]
--now["fc_hour3_time"]
]]
_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="monofur"--font must be in quotes
default_font_size=16
default_color=0xffffff --white
default_alpha=1 --fully opaque
default_image_width=60
default_image_height=60
-- ## New Options ###
default_face="normal"
-- "normal" for normal/normal
-- "bold" for normal/bold
-- "italic" for italic/normal
-- "bolditalic" for italic/bold
--END OF DEFAULTS #######################################################
--[[ SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="monofur"--font must be in quotes
default_font_size=15
default_color=0xffffff--white
default_alpha=1--fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################]]
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
-- Icon and Image section
image({x=120,y=180,h=110,w=110,file=now["weather_icon"]})
image({x=52,y=132,h=85,w=85,file=now["wind_icon"]})
image({x=140,y=60,h=70,w=70,file=moon_icon[1]})
-- Temp / FeelsLike & CONDITIONS TEXT
out({c=0xE3E3E3,a=1,f="monofur",fs=13,x=60,y=90,txt=moon_phase[1] })
out({c=0x21768E,a=1,f="monofur",fs=30,x=265,y=253,txt=now["temp"].."°"})
out({c=0xE3E3E3,a=1,f="monofur",fs=18,x=220,y=249,txt="Temp:"})
out({c=0x21768E,a=1,f="monofur",fs=20,x=263,y=270,txt=now["feels_like"].."°"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=210,y=270,txt="Feels:"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=215,y=283,txt="Hi:"})
out({c=0xC94029,a=1,f="monofur",fs=15,x=255,y=283,txt=high_temp[1].."°"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=210,y=295,txt="Lo:"})
out({c=0x21768E,a=1,f="monofur",fs=15,x=240,y=295,txt=low_temp[1].."°"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=40,y=128,txt="Wind:"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=50,y=240,txt=now["wind_nesw"].." @"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=90,y=240,txt=now["wind_mph"]})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=55,y=255,txt="Wind Chill:"})
out({c=0x21768E,a=1,f="monofur",fs=15,x=145,y=255,txt=now["wind_chill"].."°"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=70,y=270,txt="Hum:"})
out({c=0x21768E,a=1,f="monofur",fs=15,x=110,y=270,txt=now["humidity"].."%"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=80,y=285,txt="Precip:"})
out({c=0x21768E,a=1,f="monofur",fs=15,x=140,y=285,txt=precipitation[1].."%"})
out({c=0xE3E3E3,a=1,f="monofur",fs=15,x=100,y=300,txt="Dew-P:"})
out({c=0x21768E,a=1,f="monofur",fs=15,x=155,y=300,txt=now["dew_point"].."°"})
--########################################################################################
-- 3 hour output
--out({c=0x94C2FF,a=1,f="monofur",fs=16,x=25,y=380,txt="Next 3"})
--out({c=0x94C2FF,a=1,f="monofur",fs=16,x=25,y=395,txt="Hours"})
-- 1st hour
--out({c=0xFF9600,x=75,y=365,txt=now["fc_hour1_time"]..":00"})
--image({w=60,h=60,x=60,y=365,file=now["fc_hour1_wicon"]}) -- image({w=30,h=30,x=223,y=55,file="/home/sector11/Conky/images/red_1.png"})
--out({c=0xAFAFAF,x=85,y=425,txt=now["fc_hour1_temp"] .."°"})
-- 2nd hour
--out({c=0xFF9600,x=178,y=365,txt=now["fc_hour2_time"]..":00"})
--image({w=60,h=60,x=160,y=365,file=now["fc_hour2_wicon"]}) -- image({w=30,h=30,x=223,y=130,file="/home/sector11/Conky/images/red_1.png"})
--out({c=0xAFAFAF,x=185,y=425,txt=now["fc_hour2_temp"] .."°"})
-- 3rd hour
--out({c=0xFF9600,x=278,y=365,txt=now["fc_hour3_time"]..":00"})
--image({w=60,h=60,x=260,y=365,file=now["fc_hour3_wicon"]}) -- image({w=30,h=30,x=223,y=215,file="/home/sector11/Conky/images/red_1.png"})
--out({c=0xAFAFAF,x=285,y=425,txt=now["fc_hour3_temp"] .."°"})
--########################################################################################
--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=1
topy=240
ygap=80
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do --start of day repeat, do not edit #######
tlx=top_left_x_coordinate[i] --sets top left x position for each repeat ##################
tly=top_left_y_coordinate[i] --sets top left y position for each repeat ##################
--########################################################################################
--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################
# pkill -xf conky -c /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/McBars/alle/2.conky &
# Original @Sector11 2012
# modifiziert @unklar im Dec.2016
######################
# - Conky settings - #
######################
background yes
update_interval 1
cpu_avg_samples 1
total_run_times 0
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 1024 #10240
imlib_cache_size 0 #10240
minimum_size 350 350
#maximum_width 350
#####################
# - Text settings - #
#####################
use_xft yes
xftfont Antipasto:size=10
#xftfont CorporateMonoExtraBold:size=10
xftalpha 1 #.8
uppercase no
# Text alignment, other possible values are commented
#alignment middle_left
#alignment middle_middle
#alignment middle_right
#alignment top_middle
alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment bottom_middle
gap_x 15
gap_y 15
######################
# - Color settings - #
######################
default_color c3c3c3
default_shade_color gray
default_outline_color black
color0 c3c3c3 #mid gray
color1 FF0000 #red
color2 09FF00 #bright green
color3 007EFF #bright blue
color4 E3E3E3 #very light gray
color5 FF8600 #an orange shade
color6 CA8718 #a dust like color
color7 FFE500 #a darker yellow color
color8 C3FF00 #lime green
color9 00FCFF #sky blue
#############################
# - Window specifications - #
#############################
###################################################################################################
# - Create own window instead of using desktop (required in all file-managers, other than caja) - #
###################################################################################################
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour gray
own_window_class Conky
own_window_title Chronograph
own_window_argb_visual yes
own_window_argb_value 200
border_inner_margin 0
border_outer_margin 0
#########################
# - Graphics settings - #
#########################
draw_shades no #yes
draw_outline no
draw_borders no
stippled_borders 0
draw_graph_borders no
####################
# - LUA Settings - #
####################
#lua_load /media/5/conky/scripts/draw-bg.lua ###########################################################
#lua_draw_hook_pre draw_bg 20 0 0 0 0 0x000000 0.3 #### - Uncoment these lines to have BG-Image -#
#lua_draw_hook_post draw-bg 125 0 0 0 0 0x000000 0.01 ############################################
lua_load /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/McBars/alle/Chronograph-Didier-T-2.lua
lua_draw_hook_post main
#lua_load /media/5/conky/McBars_McLovin/McBars/scripts/clock_rings.lua
#lua_draw_hook_pre clock_rings
# - WEATHER - #
lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
lua_load /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/McBars/alle/crono_full_2.template.lua
lua_load ~/LUA/draw-bg.lua
TEXT
${lua conky_draw_bg 15 0 0 0 0 0x000000 0.2}
--[[ 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)
use in conkyrc
lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT
-- INDEX (use find with):
-- ###### 12 OR 24 CLOCK FACE
-- SET BORDER OPTIONS ###### ALL CLOCKS
-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
-- CLOCK A ###### 24 HR TIME
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- ### START DIAL C ### Right - Month Names Dial ##########
-- ### START DIAL D ### Left - Day Numbers Dial ###########
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
-- CLOCK E HOUR HAND
-- CLOCK E MINUTE HAND SETUP
-- CLOCK E SECOND HAND SETUP
-- CLOCK E ###### 12 HR TIME
NOTE: Putting ### CLOCK A ### last insures that it's functions are written
over the other dials.
]]
require 'cairo'
--Position et taille horloge
local init={
center_x=175,
center_y=175,
radius=170, -- do not touch
lang="English", --English or Spanish or French
hour=24, --12 or 24
second=true, --true or false - Seconds: dots and numbers
line=true, -- part second hand true or false
handday=false, -- DAY NAME hand - true or false
handdaynum=false, -- DAY NUMBER hand - true or false
handmonth=false, -- MONTH NAME hand - true or false
color=0xFF0000, --color for day, day number and month if no hand
alpha=1 --alpha for day, day number and month if no hand
}
function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
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)
-- ########################################################
-- SETTINGS AREA
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")
local clock_type_A=init.hour -- Large Main 24 HR Clock
-- ###### CLOCK SETTINGS ##################################
-- 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=1
-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- DIAL POSITION FOR TEXT
local center_x=init.center_x
local center_y=init.center_y-85
local radius=50
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 11)
cairo_set_source_rgba (cr,1,1,1,0) --doesn't work - setting changed location
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Sun","Mon","Tue","Wed","Thr","Fri","Sat",} end -- English
if init.lang == "Spanish" then text_days={"Dom","Lun","Mar","Mie","Jue","Vie","Sab",} end -- Spanish
if init.lang == "French" then text_days={"Dim","Lun","Mar","Mer","Jeu","Ven","Sam",} end -- French
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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=35
for i=1,7 do
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
-- DRAW HAND -- snaps to current day of week
local hand_length=30
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
local hand_width=2
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
else
for i=1,7 do
-- work out points
if day_number == i-1 then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,0.3) -- 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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=35
for i=1,7 do
if day_number == i-1 then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,0.3) -- dots for non-active day name
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 ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=init.center_x+85
local center_y=init.center_y
local radius=45
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 11)
cairo_set_source_rgba (cr,1,1,1,0) -- doesn't work setting moved
-- 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 -- English
if init.lang == "Spanish" then text_days={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic",} end -- Spanish
if init.lang == "French" then text_days={"Jan","Fév","Mar","Avr","Mai","Jui","Jul","Aôu","Sep","Oct","Nov","Déc",} end -- French
local this_month=tonumber(os.date("%m"))
if init.handmonth == true then
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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=32
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_stroke (cr)
end
-- DRAW HAND -- snaps to current month
local hand_length=28 --radius for this calculation
local point=(math.pi/180)*((360/12)*(this_month-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
else
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,0.3) -- 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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=32
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,0.3) -- 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 CLOCK C ########################################
-- ########################################################
-- ### START DIAL D ### Left - 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-85
local center_y=init.center_y
local radius=50
cairo_select_font_face (cr, "Liquid Crystal", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,1,1,1,0) -- does not work - settings relocated
local this_day=tonumber(os.date("%d"))
if init.handdaynum == true then
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 then
--set text when even
text=string.format("%02d",i) --formats numbers to double digits
else
--set text when odd
text=""
end--odd even matching
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=40
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))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current DAY
local hand_length=35--radius for this calculation
local point=(math.pi/180)*((360/number_days)*(this_day-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
else
for i=1,number_days do
if this_day == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,0.3) -- non-active day numbers
end
-- 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 then
--set text when even
text=string.format("%02d",i) --formats numbers to double digits
else
--set text when odd
text=""
end--odd even matching
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=40
for i=1,number_days do
if this_day == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,0.3) -- dots non-active day numbers
end
local point=(math.pi/180)*((360/number_days)*(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 CLOCK D ########################################
-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- 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=1,1,0,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=25
-- set hour hand width
hh_width_E=2
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=35
-- set minute hand width
mh_width_E=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,0,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK E SECOND HAND SETUP
-- set length of seconds hand
sh_length_E=32
-- set hour hand width
sh_width_E=1
-- 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
-- CLOCK E ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=45
clock_centerx=init.center_x
clock_centery=init.center_y+85
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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_E
-- set line cap type
cairo_set_line_cap (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E 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_E))
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_E))
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-- MARKS AROUND CLOCK A
cairo_stroke (cr)
end-- of for loop
-- 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
-- set mark width
local m_width_A=0
-- 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=1,1,1,1 -- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK A HOUR HAND
-- set length of hour hand
hh_length_A=130
-- 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,1,1,.5-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK A MINUTE HAND SETUP
-- set length of minute hand
mh_length_A=145
-- set minute hand width
mh_width_A=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,1,.5-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
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
-- CLOCK A ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=200
clock_centerx=init.center_x
clock_centery=init.center_y
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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
-- 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,hhr,hhg,hhb,hha)
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
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,mhr,mhg,mhb,mha)
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
--[[
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))BOLD
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap (cr, sh_cap)
cairo_stroke (cr)
]]
-- ####################################################################
local center_x=init.center_x
local center_y=init.center_y
local radius=init.radius-5
cairo_select_font_face (cr, "Liquid Crystal", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 15)
cairo_set_source_rgba (cr,1,1,1,1) -- 12 HR Clock numbers
-- TABLE OF TEXT -- in order
if init.hour == 12 then
text_days={"00","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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=150
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_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
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
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=150
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_stroke (cr)
end
end
-- 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=140
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=155
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,1) -- PART SECOND HAND
cairo_stroke (cr)
end
-- ####################################################################
-- POSITION FOR TEXT HOUR NUMBERS
--affiche secondes
if init.hour == 12 and init.second == true then
text_days={"","1","2","3","4","","6","7","8","9","","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.3) -- does not work -- settings moved
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
for i=1,60 do
local radius=150 -- 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.3) -- 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,0,1,1,1) --??
else
cairo_set_source_rgba (cr,0,1,1,0.3) -- 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, 10)
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,1,0,0,1) -- ??
else
cairo_set_source_rgba (cr,1,1,1,0.3) -- seconds numbers
end
--local extents=cairo_text_extents_t:create()
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
-- Fin affiche secondes
-- FONT
-- ########################################################
cairo_stroke (cr)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
--[[
The latest script is a lua only weather script. aka: v9000
http://crunchbang.org/forums/viewtopic.php?id=16100
the file:
http://dl.dropbox.com/u/19008369/current%20v9000/v9000.tar.gz
mrppeachys LUA Tutorial
http://crunchbang.org/forums/viewtopic.php?id=17246
]]
_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="monofur"--font must be in quotes
default_font_size=12
default_color=0xffffff --white
default_alpha=1 --fully opaque
default_image_width=50
default_image_height=50
-- ## New Options ###
default_face="bold"
-- "normal" for normal/normal
-- "bold" for normal/bold
-- "italic" for italic/normal
-- "bolditalic" for italic/bold
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
-- forecast
datay=375
datayy=15 --datay+(datayy*1)
datafx1=20
imgx=35
imgy=500
imgyy=60 -- imgy+(imgyy*1)
-- =============================================================================
-- Sun & Moon Rise -------------------------------------------------------------
out({c=0xFAFAEC,a=1,x=10,y=15,txt="Sunrise"})
out({c=0xFAFAEC,a=1,x=10,y=28,txt=sun_rise_24[1]})
out({c=0xC0C0C0,a=1,x=290,y=15,txt="Moonrise"})
out({c=0xC0C0C0,a=1,x=310,y=28,txt=moon_rise_24[1]})
-- Sun & Moon Set --------------------------------------------------------------
out({c=0xFAFAEC,a=1,x=10,y=333,txt="Sunset"})
out({c=0xFAFAEC,a=1,x=10,y=345,txt=sun_set_24[1]})
out({c=0xC0C0C0,a=1,x=300,y=333,txt="Moonset"})
out({c=0xC0C0C0,a=1,x=313,y=345,txt=moon_set_24[1]})
-- Moon Phase - Top Center Circle ----------------------------------------------
out({c=0x48D1CC,a=1,x=150,y=36,txt=moon_phase[1]})
image({x=148,y=64,w=55,h=55,file=moon_icon[1]})
-- image({x=148,y=64,w=55,h=55,file="/media/5/Conky/images/red_1.png"})
-- Forecast for Today - see Day# Circle - Left ---------------------------------
out({c=0xFF8C00,fs=14,a=1,x=83,y=150,txt=high_temp[1]})
image({x=65,y=151,w=50,h=50,file=weather_icon[1]})
-- image({x=65,y=151,w=50,h=50,file="/media/5/Conky/images/red_1.png"})
out({c=0x00BFFF,fs=14,a=1,x=83,y=210,txt=low_temp[1]})
-- Above the Month Circle on the Right -----------------------------------------
-- Humidity
out({c=0xFAFAEC,a=1,x=240,y=100,txt="Hum:"})
out({c=0x48D1CC,a=1,x=268,y=100,txt=now["humidity"].."%"})
-- Chance of Rain
out({c=0xFAFAEC,a=1,x=240,y=115,txt="Rain:"})
out({c=0x48D1CC,a=1,x=277,y=115,txt=precipitation[1].."%"})
-- Wind Info - See Months Circle & below ---------------------------------------
image({x=235,y=150,w=50,h=50,file=now["wind_icon"]})
-- image({x=235,y=150,w=50,h=50,file="/media/5/Conky/images/red_1.png"})
out({c=0x48D1CC,a=1,x=240,y=245,txt=now["wind_km"]})
-- out({c=0x48D1CC,a=1,x=240,y=260,txt=now["wind_nesw"]})
out({c=0xFAFAEC,a=1,x=250,y=260,txt="@"})
out({c=0x48D1CC,a=1,x=260,y=260,txt=now["wind_deg"]})
-- Dew Point -------------------------------------------------------------------
out({c=0xFAFAEC,a=1,x=238,y=275,txt="DP:"})
out({c=0x48D1CC,a=1,x=260,y=275,txt=now["dew_point"].."°"})
-- Above Day# Circle on left ---------------------------------------------------
-- Cloud Cover
out({c=0xFAFAEC,a=1,x=60,y=100,txt="CC:"})
out({c=0x48D1CC,a=1,x=80,y=100,txt=cloud_cover[1].."%"})
-- Ceiling
--out({c=0xFAFAEC,a=1,x=45,y=115,txt="Ceil:"})
out({c=0x48D1CC,a=1,x=60,y=115,txt=now["ceiling"]})
-- Current for Today - Day# Circle ---------------------------------------------
out({c=0xFAFAEC,a=1,x=155,y=215,txt="T:"})
out({c=0x9ACD32,fs=14,a=1,x=170,y=215,txt=now["temp"].."°"})
image({x=132,y=218,w=80,h=80,file=now["weather_icon"]})
-- image({x=132,y=218,w=85,h=85,file="/media/5/Conky/images/red_1.png"})
out({c=0xFAFAEC,a=1,x=155,y=310,txt="F:"})
out({c=0x00BFFF,fs=14,a=1,x=170,y=310,txt=now["feels_like"].."°"})
-- Below day# Circle on left ---------------------------------------------------
-- Barometric Pressure
out({c=0xFAFAEC,a=1,x=42,y=245,txt=" BP:"})
out({c=0x48D1CC,a=1,x=70,y=245,txt=now["pressure_mb"]})
-- UV
out({c=0xFAFAEC,a=1,x=55,y=260,txt="UV:"})
out({c=0x48D1CC,a=1,x=80,y=260,txt=uv_index_num[1]})
out({c=0x48D1CC,a=1,x=68,y=275,txt=uv_index_txt[1]})
-- Forecast for the next 3 hours -----------------------------------------------
-- image({x=5,y=353,w=340,h=2,file="/media/5/Conky/images/LightSlateGrey_1.png"})
image({x=5,y=360,w=120,h=2,file="/home/unklar/1_pixel_images/LightSlateGrey_1.png"})
out({c=0xFAFAEC,a=1,x=136,y=365,txt="Next 3 Hours"})
image({x=230,y=360,w=115,h=2,file="/home/unklar/1_pixel_images/LightSlateGrey_1.png"})
-- 1st hour
out({c=0x48D1CC,x=52,y=380,txt=now["fc_hour1_time_24"]..":00"})
image({w=80,h=80,x=30,y=380,file=now["fc_hour1_wicon"]})
-- image({w=80,h=80,x=30,y=380,file="/media/5/Conky/images/red_1.png"})
out({c=0x00BFFF,fs=18,x=55,y=470,txt=now["fc_hour1_temp"] .."°"})
-- 2nd hour
out({c=0x48D1CC,x=159,y=380,txt=now["fc_hour2_time_24"]..":00"})
image({w=80,h=80,x=135,y=380,file=now["fc_hour2_wicon"]})
-- image({w=80,h=80,x=135,y=380,file="/media/5/Conky/images/red_1.png"})
out({c=0x00BFFF,fs=18,x=160,y=470,txt=now["fc_hour2_temp"] .."°"})
-- 3rd hour
out({c=0x48D1CC,x=268,y=380,txt=now["fc_hour3_time_24"]..":00"})
image({w=80,h=80,x=245,y=380,file=now["fc_hour3_wicon"]})
-- image({w=80,h=80,x=245,y=380,file="/media/5/Conky/images/red_1.png"})
out({c=0x00BFFF,fs=18,x=270,y=470,txt=now["fc_hour3_temp"] .."°"})
-- line
image({x=5,y=475,w=340,h=2,file="/home/unklar/1_pixel_images/LightSlateGrey_1.png"})
-- =============================================================================
-- FORECAST for the next 9 days
-- Forecast day 2 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*0.4,y=datay+(datayy*8),txt=forecast_day_short[2]})
out({c=0x9ACD32,a=1,x=datafx1*2.1,y=datay+(datayy*8),txt=forecast_date[2]})
out({c=0x9ACD32,a=1,x=datafx1*3.7,y=datay+(datayy*8),txt=forecast_month_short[2]})
image({x=imgx*0.6,y=imgy,file=weather_icon[2]})
out({c=0xFF8C00,a=1,x=datafx1*0.4,y=datay+(datayy*9.5),txt=high_temp[2]})
out({c=0x00BFFF,a=1,x=datafx1*0.4,y=datay+(datayy*11),txt=low_temp[2]})
out({c=0xFAFAEC,a=1,x=datafx1*3.7,y=datay+(datayy*8.8),txt=sun_rise_24[2]})
out({c=0xFAFAEC,a=1,x=datafx1*3.7,y=datay+(datayy*9.5),txt=sun_set_24[2]})
out({c=0xC0C0C0,a=1,x=datafx1*3.7,y=datay+(datayy*10.8),txt=moon_rise_24[2]})
out({c=0xC0C0C0,a=1,x=datafx1*3.7,y=datay+(datayy*11.5),txt=moon_set_24[2]})
-- Forecast day 3 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*6.6,y=datay+(datayy*8),txt=forecast_day_short[3]})
out({c=0x9ACD32,a=1,x=datafx1*8.2,y=datay+(datayy*8),txt=forecast_date[3]})
out({c=0x9ACD32,a=1,x=datafx1*9.8,y=datay+(datayy*8),txt=forecast_month_short[3]})
image({x=imgx*4.15,y=imgy,file=weather_icon[3]})
out({c=0xFF8C00,a=1,x=datafx1*6.5,y=datay+(datayy*9.5),txt=high_temp[3]})
out({c=0x00BFFF,a=1,x=datafx1*6.5,y=datay+(datayy*11),txt=low_temp[3]})
out({c=0xFAFAEC,a=1,x=datafx1*9.8,y=datay+(datayy*8.8),txt=sun_rise_24[3]})
out({c=0xFAFAEC,a=1,x=datafx1*9.8,y=datay+(datayy*9.5),txt=sun_set_24[3]})
out({c=0xC0C0C0,a=1,x=datafx1*9.8,y=datay+(datayy*10.8),txt=moon_rise_24[3]})
out({c=0xC0C0C0,a=1,x=datafx1*9.8,y=datay+(datayy*11.5),txt=moon_set_24[3]})
-- Forecast day 4 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*12.4,y=datay+(datayy*8),txt=forecast_day_short[4]})
out({c=0x9ACD32,a=1,x=datafx1*14.3,y=datay+(datayy*8),txt=forecast_date[4]})
out({c=0x9ACD32,a=1,x=datafx1*15.7,y=datay+(datayy*8),txt=forecast_month_short[4]})
image({x=imgx*7.52,y=imgy,file=weather_icon[4]})
out({c=0xFF8C00,a=1,x=datafx1*12.4,y=datay+(datayy*9.5),txt=high_temp[4]})
out({c=0x00BFFF,a=1,x=datafx1*12.4,y=datay+(datayy*11),txt=low_temp[4]})
out({c=0xFAFAEC,a=1,x=datafx1*15.7,y=datay+(datayy*8.8),txt=sun_rise_24[4]})
out({c=0xFAFAEC,a=1,x=datafx1*15.7,y=datay+(datayy*9.5),txt=sun_set_24[4]})
out({c=0xC0C0C0,a=1,x=datafx1*15.7,y=datay+(datayy*10.8),txt=moon_rise_24[4]})
out({c=0xC0C0C0,a=1,x=datafx1*15.7,y=datay+(datayy*11.5),txt=moon_set_24[4]})
-- =============================================================================
-- Forecast day 5 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*0.4,y=datay+(datayy*13),txt=forecast_day_short[5]})
out({c=0x9ACD32,a=1,x=datafx1*2.1,y=datay+(datayy*13),txt=forecast_date[5]})
out({c=0x9ACD32,a=1,x=datafx1*3.7,y=datay+(datayy*13),txt=forecast_month_short[5]})
image({x=imgx*0.6,y=imgy+(imgyy*1.2),file=weather_icon[5]})
out({c=0xFF8C00,a=1,x=datafx1*0.4,y=datay+(datayy*14.5),txt=high_temp[5]})
out({c=0x00BFFF,a=1,x=datafx1*0.4,y=datay+(datayy*16),txt=low_temp[5]})
out({c=0xFAFAEC,a=1,x=datafx1*3.7,y=datay+(datayy*13.7),txt=sun_rise_24[5]})
out({c=0xFAFAEC,a=1,x=datafx1*3.7,y=datay+(datayy*14.4),txt=sun_set_24[5]})
out({c=0xC0C0C0,a=1,x=datafx1*3.7,y=datay+(datayy*15.7),txt=moon_rise_24[5]})
out({c=0xC0C0C0,a=1,x=datafx1*3.7,y=datay+(datayy*16.4),txt=moon_set_24[5]})
-- Forecast day 6 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*6.6,y=datay+(datayy*13),txt=forecast_day_short[6]})
out({c=0x9ACD32,a=1,x=datafx1*8.2,y=datay+(datayy*13),txt=forecast_date[6]})
out({c=0x9ACD32,a=1,x=datafx1*9.8,y=datay+(datayy*13),txt=forecast_month_short[6]})
image({x=imgx*4.18,y=imgy+(imgyy*1.2),file=weather_icon[6]})
out({c=0xFF8C00,a=1,x=datafx1*6.7,y=datay+(datayy*14.5),txt=high_temp[6]})
out({c=0x00BFFF,a=1,x=datafx1*6.7,y=datay+(datayy*16),txt=low_temp[6]})
out({c=0xFAFAEC,a=1,x=datafx1*9.8,y=datay+(datayy*13.7),txt=sun_rise_24[6]})
out({c=0xFAFAEC,a=1,x=datafx1*9.8,y=datay+(datayy*14.4),txt=sun_set_24[6]})
out({c=0xC0C0C0,a=1,x=datafx1*9.8,y=datay+(datayy*15.7),txt=moon_rise_24[6]})
out({c=0xC0C0C0,a=1,x=datafx1*9.8,y=datay+(datayy*16.4),txt=moon_set_24[6]})
-- Forecast day 7 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*12.4,y=datay+(datayy*13),txt=forecast_day_short[7]})
out({c=0x9ACD32,a=1,x=datafx1*14.3,y=datay+(datayy*13),txt=forecast_date[7]})
out({c=0x9ACD32,a=1,x=datafx1*15.7,y=datay+(datayy*13),txt=forecast_month_short[7]})
image({x=imgx*7.49,y=imgy+(imgyy*1.2),file=weather_icon[7]})
out({c=0xFF8C00,a=1,x=datafx1*12.4,y=datay+(datayy*14.5),txt=high_temp[7]})
out({c=0x00BFFF,a=1,x=datafx1*12.4,y=datay+(datayy*16),txt=low_temp[7]})
out({c=0xFAFAEC,a=1,x=datafx1*15.7,y=datay+(datayy*13.7),txt=sun_rise_24[7]})
out({c=0xFAFAEC,a=1,x=datafx1*15.7,y=datay+(datayy*14.4),txt=sun_set_24[7]})
out({c=0xC0C0C0,a=1,x=datafx1*15.7,y=datay+(datayy*15.7),txt=moon_rise_24[7]})
out({c=0xC0C0C0,a=1,x=datafx1*15.7,y=datay+(datayy*16.4),txt=moon_set_24[7]})
-- =============================================================================
-- Forecast day 8 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*0.4,y=datay+(datayy*18),txt=forecast_day_short[8]})
out({c=0x9ACD32,a=1,x=datafx1*2.1,y=datay+(datayy*18),txt=forecast_date[8]})
out({c=0x9ACD32,a=1,x=datafx1*3.7,y=datay+(datayy*18),txt=forecast_month_short[8]})
image({x=imgx*0.6,y=imgy+(imgyy*2.5),file=weather_icon[8]})
out({c=0xFF8C00,a=1,x=datafx1*0.4,y=datay+(datayy*19.5),txt=high_temp[8]})
out({c=0x00BFFF,a=1,x=datafx1*0.4,y=datay+(datayy*21),txt=low_temp[8]})
out({c=0xFAFAEC,a=1,x=datafx1*3.7,y=datay+(datayy*18.7),txt=sun_rise_24[8]})
out({c=0xFAFAEC,a=1,x=datafx1*3.7,y=datay+(datayy*19.4),txt=sun_set_24[8]})
out({c=0xC0C0C0,a=1,x=datafx1*3.7,y=datay+(datayy*20.7),txt=moon_rise_24[8]})
out({c=0xC0C0C0,a=1,x=datafx1*3.7,y=datay+(datayy*21.4),txt=moon_set_24[8]})
-- Forecast day 9 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*6.5,y=datay+(datayy*18),txt=forecast_day_short[9]})
out({c=0x9ACD32,a=1,x=datafx1*8.1,y=datay+(datayy*18),txt=forecast_date[9]})
out({c=0x9ACD32,a=1,x=datafx1*9.7,y=datay+(datayy*18),txt=forecast_month_short[9]})
image({x=imgx*4.14,y=imgy+(imgyy*2.5),file=weather_icon[9]})
out({c=0xFF8C00,a=1,x=datafx1*6.5,y=datay+(datayy*19.5),txt=high_temp[9]})
out({c=0x00BFFF,a=1,x=datafx1*6.5,y=datay+(datayy*21),txt=low_temp[9]})
out({c=0xFAFAEC,a=1,x=datafx1*9.8,y=datay+(datayy*18.7),txt=sun_rise_24[9]})
out({c=0xFAFAEC,a=1,x=datafx1*9.8,y=datay+(datayy*19.4),txt=sun_set_24[9]})
out({c=0xC0C0C0,a=1,x=datafx1*9.8,y=datay+(datayy*20.7),txt=moon_rise_24[9]})
out({c=0xC0C0C0,a=1,x=datafx1*9.8,y=datay+(datayy*21.4),txt=moon_set_24[9]})
-- Forecast day 10 -- x = l|r y = u|d
out({c=0x9ACD32,a=1,x=datafx1*12.4,y=datay+(datayy*18),txt=forecast_day_short[10]})
out({c=0x9ACD32,a=1,x=datafx1*14.3,y=datay+(datayy*18),txt=forecast_date[10]})
out({c=0x9ACD32,a=1,x=datafx1*15.7,y=datay+(datayy*18),txt=forecast_month_short[10]})
image({x=imgx*7.55,y=imgy+(imgyy*2.5),file=weather_icon[10]})
out({c=0xFF8C00,a=1,x=datafx1*12.4,y=datay+(datayy*19.5),txt=high_temp[10]})
out({c=0x00BFFF,a=1,x=datafx1*12.4,y=datay+(datayy*21),txt=low_temp[10]})
out({c=0xFAFAEC,a=1,x=datafx1*15.7,y=datay+(datayy*18.7),txt=sun_rise_24[10]})
out({c=0xFAFAEC,a=1,x=datafx1*15.7,y=datay+(datayy*19.4),txt=sun_set_24[10]})
out({c=0xC0C0C0,a=1,x=datafx1*15.7,y=datay+(datayy*20.7),txt=moon_rise_24[10]})
out({c=0xC0C0C0,a=1,x=datafx1*15.7,y=datay+(datayy*21.4),txt=moon_set_24[10]})
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################
--[[
colorfill.lua
easysid
Monday, 23 January 2017 13:44 IST
]]--
require 'cairo'
-- common
local base = {0x404040, 1} -- {base fill color, alpha}
local font_face = 'champagne & limousines'
local settings_t = {
{
label = "CPU",
arg = "cpu cpu0",
max = 100,
x = 20,
y = 280,
color = {0x912d2d, 1},
font = font_face,
size = 80,
},
{
label = "RAM",
arg = "memperc",
max = 100,
x = 210,
y = 280,
color = {0x721d61, 1},
font = font_face,
size = 80,
},
{
label = "DAT",
arg = "fs_used_perc /media/Distris",
max = 100,
x = 400,
y = 280,
color = {0x1d7235, 1},
font = font_face,
size = 80,
},
{
label = nil,
arg = "time %H",
max = 24,
x = 80,
y = 160,
color = {0xd07036, 1},
font = font_face,
size = 120
},
{
label = nil,
arg = "time %M",
max = 60,
x = 240,
y = 160,
color = {0x3f75d7, 1},
font = font_face,
size = 105,
},
{
label = nil,
arg = "time %S",
max = 60,
x = 380,
y = 160,
color = {0xbfb622, 1},
font = font_face,
size = 90
}
}
-- ###### should not need to edit below this line ###### --
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 updates=tonumber(conky_parse('${updates}'))
if updates > 3 then
for i in ipairs(settings_t) do
drawText(settings_t[i])
end -- for
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr = nil
end --end main()
function drawText(t)
local text = conky_parse(string.format("${%s}", t.arg))
local value = tonumber(text)
if t.label then text = t.label end
local x = t.x or 100
local y = t.y or 100
local font = t.font or "sans"
local size = t.size or 50
local col = t.color or {0xFFFFFF, 1}
local max = t.max or 100
local perc = 1 - value/max
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
cairo_select_font_face(cr, font, 0, 0)
cairo_set_font_size(cr, size)
cairo_text_extents(cr, text, extents)
local w = extents.width
local h = extents.height
local pat = cairo_pattern_create_linear(x, y-h, x, y)
cairo_pattern_add_color_stop_rgba(pat, perc, rgba_to_r_g_b_a(base))
cairo_pattern_add_color_stop_rgba(pat, perc, rgba_to_r_g_b_a(col))
cairo_set_source(cr, pat)
cairo_move_to(cr, x, y)
cairo_show_text(cr, text)
cairo_stroke(cr)
end
function rgba_to_r_g_b_a(tcolor)
local color,alpha=tcolor[1],tcolor[2]
return ((color / 0x10000) % 0x100) / 255.,
((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end
label = "BAT",
arg = "battery_percent BAT0",
# pkill -xf conky -c /media/DATEN/francescoPC/Conky/derivantArt/easysid/farbenUhr/easysidrc &
# von easysid 23.01.2017
# config unklar
background yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager #sticky,
own_window_title easysid_full_color
own_window_class Conky
### 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 140
double_buffer yes
use_spacer right
uppercase no
stippled_borders 0
border_width 0
default_outline_color black
default_shade_color black
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
border_inner_margin 5
border_outer_margin 0
default_color DCDCDC #220 220 220 Gainsboro
color0 8FBC8F #143 188 143 DarkSeaGreen
color1 778899 #119 136 153 LightSlateGray
color2 FF8C00 #255 140 0 DarkOrange
color3 7FFF00 #127 255 0 Chartreuse
color4 FFA07A #255 160 122 LightSalmon
color5 FFDEAD #255 222 173 NavajoWhite
color6 00BFFF # 0 191 255 DeepSkyBlue
color7 00FFFF # 0 255 255 Cyan
color8 FFFF00 #255 255 0 Yellow
color9 B22222 #178 34 34 FireBrick
text_buffer_size 510 # 256 is minimum
no_buffers yes
short_units yes
pad_percents 2
imlib_cache_size 0
gap_x 0 ## left &right
gap_y 0 ## up & down
minimum_size 580 280 ## width, height
#maximum_width 280 ## make this equal to minimum size width
alignment mm
use_xft yes
xftfont Droid Sans Mono:bold:size=7
# xftfont Santana:bold:size=8
#xftfont WenQuanYi Macro Hei Mono:bold:size=8
#xftfont WenQuanYi Zen Hei Mono:bold:size=8
xftalpha 1.0
override_utf8_locale yes
### LUA Settings ###########################################################
lua_load /media/DATEN/francescoPC/Conky/derivantArt/easysid/farbenUhr/colorfill.lua
lua_draw_hook_pre main
##lua_load ~/LUA/draw-bg.lua
## ${lua conky_draw_bg 10 0 0 0 0 0x000000 0.6}
## ${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
##
##
## OR Both above TEXT (No xcompmgr required - no blinking!)
#lua_load ~/LUA/draw-bg.lua
#lua_draw_hook_pre draw_bg 5 0 0 0 0 0x000000 0.4
##
####################################################### End LUA Settings ###
update_interval 1 #43200 ## 12 hours
TEXT
#${lua conky_draw_bg 10 0 0 0 0 0x000000 0.6}
--[[
colorfill.lua
lua script for colors conky
easysid
Monday, 23 January 2017 13:44 IST
Update:
Tuesday, 24 January 2017
* Allow conky vars as labels
* catch nil value errors
]]--
require 'cairo'
-- common
local base = {0x404040, 1} -- {base fill color, alpha}
local font_face = 'champagne & limousines'
local settings_t = {
{
label = "CPU", -- simple label
arg = "cpu cpu0",
max = 100,
x = 20,
y = 240,
color = {0x912d2d, 1},
font = font_face,
size = 60,
},
{
label = "RAM",
arg = "memperc",
max = 100,
x = 165,
y = 240,
color = {0xa9309f, 1},
font = font_face,
size = 60,
},
{
label = "DAT",
arg = "fs_used_perc /media/Distris",
max = 100,
x = 310,
y = 240,
color = {0x1d7235, 1},
font = font_face,
size = 60,
},
{
label = nil, -- no label, use the arg value
arg = "time %H",
max = 24,
x = 10,
y = 160,
color = {0xd07036, 1},
font = font_face,
size = 160
},
{
label = nil,
arg = "time %M",
max = 60,
x = 240,
y = 160,
color = {0x3f75d7, 1},
font = font_face,
size = 160,
},
{
label = nil,
arg = "time %d",
max = 30,
x = 480,
y = 90,
color = {0x0fb575, 1},
font = font_face,
size = 60
},
{
label = "time %B", -- conky var as a label
parse_label = true, -- we need to parse the label value
arg = "time %m",
max = 12,
x = 580,
y = 90,
color = {0xd07036, 1},
font = font_face,
size = 60
},
{
label = "time %A",
parse_label = true,
arg = "time %u",
max = 7,
x = 480,
y = 160,
color = {0xa9309f, 1},
font = font_face,
size = 80
},
}
-- ###### should not need to edit below this line ###### --
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 updates=tonumber(conky_parse('${updates}'))
if updates > 7 then
for i in ipairs(settings_t) do
drawText(settings_t[i])
end -- for
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr = nil
end --end main()
function drawText(t)
local text = conky_parse(string.format("${%s}", t.arg))
local value = tonumber(text)
-- catch any nil value errors
if value == nil then
print(string.format("{%s} returned a nil value", t.arg))
return
end
-- label jugglery
if t.label then
text = t.label
if t.parse_label then
text = conky_parse(string.format("${%s}", t.label))
end
end
local x = t.x or 100
local y = t.y or 100
local font = t.font or "sans"
local size = t.size or 50
local col = t.color or {0xFFFFFF, 1}
local max = t.max or 100
local perc = 1 - value/max
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
cairo_select_font_face(cr, font, 0, 0)
cairo_set_font_size(cr, size)
cairo_text_extents(cr, text, extents)
local w = extents.width
local h = extents.height
local pat = cairo_pattern_create_linear(x, y-h, x, y)
cairo_pattern_add_color_stop_rgba(pat, perc, rgba_to_r_g_b_a(base))
cairo_pattern_add_color_stop_rgba(pat, perc, rgba_to_r_g_b_a(col))
cairo_set_source(cr, pat)
cairo_move_to(cr, x, y)
cairo_show_text(cr, text)
cairo_stroke(cr)
end
function rgba_to_r_g_b_a(tcolor)
local color,alpha=tcolor[1],tcolor[2]
return ((color / 0x10000) % 0x100) / 255.,
((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end
# To use #! in a conky use: ${exec echo '#!'}
# ${font DS\-Digital:bold:size=24}
# OS: ${pre_exec lsb_release -d | cut -c14-50}
# killall conky && conky -c ~/Conky/S11_Chronograph.conky &
# Thank you - mrpeachy
### Begin Window Settings ##################################################
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour gray
own_window_class Conky
own_window_title Chronograph
# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
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 200
minimum_size 340 340 ##420 420 ## width, height
maximum_width 340 ##420 ## width, usually a good idea to equal minimum width
gap_x 10 #15 ### left &right
gap_y -150 ### up & down
alignment ml #ml
#################################################### End Window Settings ###
### Font Settings ##########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
xftfont CorporateMonoExtraBold:size=9
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
draw_shades no
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
uppercase no
###################################################### End Font Settings ###
### Color Settings #########################################################
default_shade_color gray
default_outline_color black
default_color DCDCDC #220 220 220 Gainsboro
color0 8FBC8F #143 188 143 DarkSeaGreen
color1 778899 #119 136 153 LightSlateGray
color2 FF8C00 #255 140 0 DarkOrange
color3 7FFF00 #127 255 0 Chartreuse
color4 FFA07A #255 160 122 LightSalmon
color5 FFDEAD #255 222 173 NavajoWhite
color6 00BFFF # 0 191 255 DeepSkyBlue
color7 00FFFF # 0 255 255 Cyan
color8 FFFF00 #255 255 0 Yellow
color9 B22222 #178 34 34 FireBrick
##################################################### End Color Settings ###
### Borders Section ########################################################
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
##################################################### End Borders Secton ###
### Miscellaneous Section ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background yes
# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none
# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 256
# Subtract (file system) buffers from used memory?
no_buffers yes
# change GiB to G and MiB to M
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
# 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
############################################## End Miscellaneous Section ###
### LUA Settings ###########################################################
## Above and After TEXT - requires a composite manager or blinks.
##
# lua_load ~/Conky/LUA/draw-bg.lua
#TEXT
# ${lua conky_draw_bg 125 0 0 0 0 0x000000 0.3}
#
## ${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
##
## OR Both above TEXT (No composite manager required - no blinking!)
#
#--------------------------------
#lua_load /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/LUA/draw-bg.lua
#lua_draw_hook_pre draw_bg 20 0 0 0 0 0x000000 0.3
# lua_draw_hook_post draw-bg 125 0 0 0 0 0x000000 0.01
##
################### Chronograph ##############################################
lua_load /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/LUA/Chronograph.lua
#lua_load /media/DATEN/francescoPC/Conky/Sector11/12-1-Sector11-1/LUA/chrono.lua
#lua_load ~/Conky/LUA/clock_rings_mrp.lua
lua_draw_hook_pre main
####################################################### End LUA Settings ###
# The all important - How often conky refreshes.
# If you have a "Crey" try: 0.2 - smokin' - but watch the CPU useage go UP!
update_interval 1
TEXT
${color}CPU ${hwmon 1 temp 2}°${alignr 10}MB ${hwmon 0 temp 2}°
1: ${if_match ${cpu cpu0} < 10}00${cpu cpu0}\
${else}${if_match ${cpu cpu0} < 100}0${cpu cpu0}\
${else}${cpu cpu0}\
${endif}${endif}%\
${alignr 10}2: ${if_match ${cpu cpu1} < 10}00${cpu cpu1}\
${else}${if_match ${cpu cpu1} < 100}0${cpu cpu1}\
${else}${cpu cpu1}\
${endif}${endif}%
FAN:${alignr 10}${hwmon 0 fan 4}
${voffset -7} 3: ${if_match ${cpu cpu2} < 10}00${cpu cpu2}\
${else}${if_match ${cpu cpu2} < 100}0${cpu cpu2}\
${else}${cpu cpu2}\
${endif}${endif}%\
${alignr 5}4: ${if_match ${cpu cpu3} < 10}00${cpu cpu3}\
${else}${if_match ${cpu cpu3} < 100}0${cpu cpu3}\
${else}${cpu cpu3}\
${endif}${endif}%
${color}HDD ${execi 600 hddtemp -n /dev/sda}°${alignr 5}GPU ${hwmon 2 temp 1}°
--[[ 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
use in conkyrc
lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT
-- INDEX (use find with):
-- ###### 12 OR 24 CLOCK FACE
-- SET BORDER OPTIONS ###### ALL CLOCKS
-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
-- CLOCK A ###### 24 HR TIME
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- ### START DIAL C ### Right - Month Names Dial ##########
-- ### START DIAL D ### Left - Day Numbers Dial ###########
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
-- CLOCK E HOUR HAND
-- CLOCK E MINUTE HAND SETUP
-- CLOCK E SECOND HAND SETUP
-- CLOCK E ###### 12 HR TIME
NOTE: Putting ### CLOCK A ### last insures that it's functions are written
over the other dials.
]]
require 'cairo'
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)
-- ########################################################
-- SETTINGS AREA
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")
-- ###### 12 OR 24 CLOCK FACE #############################
local clock_type_A=24 -- Large Main 24 HR Clock
local clock_type_E=12 -- Bottom - 12 HR Clock
-- ###### CLOCK SETTINGS ##################################
-- 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=1
-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- DIAL POSITION FOR TEXT
local center_x=175
local center_y=95
local radius=50
-- FONT
cairo_select_font_face (cr, "CorporateMonoExtraBold", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"SO","MO","DI","MI","DO","FR","SA",}
-- text_days={"DOM","LUN","MAR","MIE","JUE","VIE","SAB",}
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
local extents=cairo_text_extents_t:create()
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=35
for i=1,7 do
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
-- DRAW HAND -- snaps to current day of week
local hand_length=30
local day_number=tonumber(os.date("%w"))
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
local hand_width=2
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END DIAL B #########################################
-- ########################################################
-- ### START DIAL C ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=260
local center_y=175
local radius=45
-- FONT
cairo_select_font_face (cr, "CorporateMonoExtraBold", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC",}
-- text_days={"ENE","FEB","MAR","ABR","MAY","JUN","JUL","AGO","SEP","OCT","NOV","DIC",}
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
local extents=cairo_text_extents_t:create()
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=32
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_stroke (cr)
end
-- DRAW HAND -- snaps to current month
local this_month=tonumber(os.date("%m"))
local hand_length=28 --radius for this calculation
local point=(math.pi/180)*((360/12)*(this_month-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK C ########################################
-- ########################################################
-- ### START DIAL D ### Left - 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});
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
-- 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=95
local center_y=175
local radius=50
cairo_select_font_face (cr, "CorporateMonoExtraBold", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 8)
cairo_set_source_rgba (cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
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
local text=i
local extents=cairo_text_extents_t:create()
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=40
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))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current DAY
local this_day=tonumber(os.date("%d"))
local hand_length=35--radius for this calculation
local point=(math.pi/180)*((360/number_days)*(this_day-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK D ########################################
-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- 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=1,1,0,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=25
-- set hour hand width
hh_width_E=2
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=35
-- set minute hand width
mh_width_E=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,0,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK E SECOND HAND SETUP
-- set length of seconds hand
sh_length_E=32
-- set hour hand width
sh_width_E=1
-- 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
-- CLOCK E ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=45
clock_centerx=175
clock_centery=260
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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_E
-- set line cap type
cairo_set_line_cap (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E 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_E))
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_E))
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
-- TIME CALCULATIONS CLOCK E
if clock_type_E==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_E==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 and draw it
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_E))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_E
-- 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)*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_E)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds 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_E
-- 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_E)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_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
cairo_set_line_width (cr,sh_width_E)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap (cr, sh_cap)
cairo_stroke (cr)
-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=260
local radius=45
-- FONT
cairo_select_font_face (cr, "CorporateMonoExtraBold", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"12","01","02","03","04","05","06","07","08","09","10","11",}
-- FOR A 12 HOUR CLOCK WITH THE NUMBERS 13-00
--text_days={"00","13","14","15","16","17","18","19","20","21","22","23",}
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
local extents=cairo_text_extents_t:create()
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=32
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_stroke (cr)
end
-- ### END CLOCK E ########################################
-- ########################################################
-- ### START CLOCK A ######################################
-- SET MARKS ##############################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=24
-- set mark length
local m_length_A=0
-- set mark width
local m_width_A=0
-- 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=1,1,1,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK A HOUR HAND
-- set length of hour hand
hh_length_A=130
-- 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,1,1,1-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK A MINUTE HAND SETUP
-- set length of minute hand
mh_length_A=145
-- set minute hand width
mh_width_A=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,1,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
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
-- CLOCK A ###### 24 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=200
clock_centerx=175
clock_centery=175
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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
-- 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,hhr,hhg,hhb,hha)
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,mhr,mhg,mhb,mha)
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
--[[
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_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
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap (cr, sh_cap)
cairo_stroke (cr)
]]
-- ####################################################################
-- part of a second hand
--position
local center_x=175
local center_y=175
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
local arc=(math.pi/180)*((360/60)*seconds)
--calculate point 1
local radius1=149
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=151
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,1)
cairo_stroke (cr)
-- ####################################################################
-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=175
local radius=160
-- FONT
cairo_select_font_face (cr, "CorporateMonoExtraBold", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
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
local extents=cairo_text_extents_t:create()
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=150
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_stroke (cr)
end
-- ### END CLOCK A ########################################
local num=conky_parse("${fs_used_perc /home}")
local used=conky_parse("${fs_used /home}")
local size=conky_parse("${fs_size /home}")
-- ########################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
# — Conky settings — #
background yes
update_interval 1
total_run_times 0
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
imlib_cache_size 0
# — Window specifications — #
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_argb_value 200
own_window_class revolution_clock_conky
own_window_type normal
own_window_title revolution_clock_conky
own_window_hints undecorated,below,skip_taskbar,skip_pager #,sticky
border_inner_margin 0
border_outer_margin 0
minimum_size 202 202
maximum_width 202
alignment top_left
#gap_x 1410
#gap_y -68
gap_x 15
gap_y 15
# — Graphics settings — #
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders no
# — Text settings — #
use_xft yes
xftfont hooge 05_53:size=6.4
xftalpha 1.0
uppercase no
use_spacer right
default_color CC9900
default_shade_color 8B0000
color0 EE7600
# — Lua Load — #
lua_load /media/DATEN/francescoPC/Conky/derivantArt/arlance/cups_n_saucers.lua
lua_draw_hook_post main
TEXT
${voffset 80}${goto 38}${font hooge 05_53:size=20}${time %H:%M:%S}
${color0}${voffset 5}${goto 50}${font hooge 05_53:size=12}${time %a %d. %b}
#${voffset 140}${goto 108}${font NovaMono:size=43}${time %I:%M:%S}
#${color0}${voffset -20}${goto 115}${font NovaMono:size=30}${time %a %d %b}
#${voffset 68}${goto 38}${font DS-Digital:size=23}${time %I:%M:%S}
#${color0}${voffset 8}${goto 43}${font DS-Digital:size=17}${time %a %d %b}
---
--==============================================================================
-- Cups and Saucers
-- Lua conky script
--
-- author : Abu Yahya
-- license : Distributed under the terms of GNU GPL v3
-- 30.05.2012
-- v.1.0.1
--==============================================================================
require 'cairo'
--------------------------------------------------------------------------------
----Adjustable Settings -- cup sector angle adjusts step size
table_setting = {
{
name='time', arg='%H.%M', max_value=24,
x=102, y=102,
cup_radius=35,
cup_wall_thickness=90,
cup_sector_angle=15, cup_sector_circ=10,
cup_bg_clr=0xffffff, cup_bg_alpha=0.0,
cup_fg_clr=0xFFFFFF, cup_fg_alpha=0.0,
handle_length=70, handle_circ=1,
handle_fg_clr=0xFFFFFF, handle_fg_alpha=0.0,
graduation_radius=-60+124,
graduation_thickness=8, graduation_mark_circ=1.5,
graduation_mark_angle=30,
graduation_fg_clr=0xCC9900, graduation_fg_alpha=0.0,
saucer_thickness=6, thick_saucer_circ=11/12,
saucer_radius=-60+135, thin_saucer_circ=11/12,
saucer_fg_clr=0xCC9900, saucer_fg_alpha=0.5,
saucer_mark_fg_clr=0xCC9900, saucer_mark_fg_alpha=1.0,
inner_saucer=true,
txt_weight=0, txt_size=0,
txt_fg_clr=0xFFFFFF, txt_fg_alpha=1.0,
caption='', caption2='',
},
{
name='time', arg='%M', max_value=60,
x=102, y=102,
cup_radius=55,
cup_wall_thickness=120,
cup_sector_angle=6, cup_sector_circ=3,
cup_bg_clr=0xffffff, cup_bg_alpha=0.0,
cup_fg_clr=0xFFFFFF, cup_fg_alpha=0.0,
graduation_radius=-60+123,
graduation_thickness=10, graduation_mark_circ=2.5,
graduation_mark_angle=90,
graduation_fg_clr=0xCC9900, graduation_fg_alpha=0.0,
handle_length=110, handle_circ=1,
handle_fg_clr=0xCC9900, handle_fg_alpha=0.0,
saucer_thickness=6, thick_saucer_circ=11/12,
saucer_radius=-60+155, thin_saucer_circ=11/12,
saucer_fg_clr=0xCC9900, saucer_fg_alpha=0.5,
saucer_mark_fg_clr=0xCC9900, saucer_mark_fg_alpha=1.0,
txt_weight=0, txt_size=8.0,
txt_fg_clr=0xFFFFFF, txt_fg_alpha=0.0,
caption='', caption2='',
},
{
name='time', arg='%S', max_value=60,
x=102, y=102,
cup_radius=59,
cup_wall_thickness=120,
cup_sector_angle=6, cup_sector_circ=3,
cup_bg_clr=0xffffff, cup_bg_alpha=0.0,
cup_fg_clr=0xFFFFFF, cup_fg_alpha=0.0,
handle_fg_clr=0xFFFFFF, handle_fg_alpha=0.0,
handle_length=118, handle_circ=1,
graduation_radius=-60+125,
graduation_thickness=6, graduation_mark_circ=0.5,
graduation_mark_angle=6,
graduation_fg_clr=0xEE7600, graduation_fg_alpha=0.0,
saucer_thickness=5, thick_saucer_circ=1,
saucer_radius=-60+145, thin_saucer_circ=11/12,
saucer_fg_clr=0xEE7600, saucer_fg_alpha=0.5,
saucer_mark_fg_clr=0xEE7600, saucer_mark_fg_alpha=1.0,
txt_weight=0, txt_size=8.0,
txt_fg_clr=0xEE7600, txt_fg_alpha=0.0,
caption='', caption2='',
},
}
--Fixed code -do not edit unless you know what you are doing------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- converts color in hexa to decimal
function rgb_to_r_g_b(clr, alpha)
return ((clr / 0x10000) % 0x100) / 255., ((clr / 0x100) % 0x100) / 255., (clr % 0x100) / 255., alpha
end
-------------------------------------------------------------------------------
-- convert degree to rad and rotate (0 degree is top/north)
function angle_to_position(start_angle, current_angle)
local pos = current_angle + start_angle
return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end
-------------------------------------------------------------------------------
------------------------------------------------------------------------
-- displays cups and saucers
function draw_table_setting_ring(display, data, value)
local max_value = data['max_value']
local x, y = data['x'], data['y']
local cup_radius = data['cup_radius']
local cup_wall_thickness, cup_sector_circ = data['cup_wall_thickness'], data['cup_sector_circ']
local handle_length, handle_circ = data['handle_length'], data['handle_circ']
local cup_start_angle = data['cup_start_angle']
if cup_start_angle == nil then cup_start_angle =0 end
local cup_sector_angle = data['cup_sector_angle']
local cup_bg_clr, cup_bg_alpha = data['cup_bg_clr'], data['cup_bg_alpha']
local cup_fg_clr, cup_fg_alpha = data['cup_fg_clr'], data['cup_fg_alpha']
local handle_fg_clr, handle_fg_alpha = data['handle_fg_clr'], data['handle_fg_alpha']
local cup_end_angle = (max_value * cup_sector_angle) + cup_start_angle
if cup_end_angle > 360 then cup_end_angle = cup_end_angle - 360 end
-- cup centre background
cairo_arc(display, x, y, cup_radius, angle_to_position(cup_start_angle, 0), angle_to_position(cup_start_angle, cup_end_angle))
cairo_set_source_rgba(display, rgb_to_r_g_b(cup_bg_clr, cup_bg_alpha))
cairo_set_line_width(display, cup_wall_thickness)
cairo_stroke(display)
local val = (value % (max_value))
local start_arc = 0
local stop_arc = 0
local i = 1
while i <= val do
start_arc = (cup_sector_angle * i) - (cup_sector_circ*0.5)
stop_arc = (cup_sector_angle * i) + (cup_sector_circ*0.5)
cairo_arc(display, x, y, cup_radius, angle_to_position(cup_start_angle, start_arc), angle_to_position(cup_start_angle, stop_arc))
cairo_set_source_rgba(display, rgb_to_r_g_b(cup_fg_clr, cup_fg_alpha))
cairo_stroke(display)
i = i + 1
end
-- cup handle
local start_handle = (cup_sector_angle * value) - (handle_circ*0.5)
local stop_handle = (cup_sector_angle * value) + (handle_circ*0.5)
cairo_arc(display, x, y, cup_radius, angle_to_position(cup_start_angle, start_handle), angle_to_position(cup_start_angle, stop_handle))
cairo_set_line_width(display, handle_length)
cairo_set_source_rgba(display, rgb_to_r_g_b(handle_fg_clr, handle_fg_alpha))
cairo_stroke(display)
--saucers
local saucer_thickness = data['saucer_thickness']
local saucer_fg_clr = data['saucer_fg_clr']
local saucer_fg_alpha = data['saucer_fg_alpha']
local saucer_radius = data['saucer_radius']
local saucer_mark_fg_alpha = data['saucer_mark_fg_alpha']
local saucer_mark_fg_clr = data['saucer_mark_fg_clr']
local thick_saucer_circ = data['thick_saucer_circ']
local thin_saucer_circ = data['thin_saucer_circ']
local inner_saucer = data['inner_saucer']
---thick saucer
if saucer_fg_alpha > 0 and (thin_saucer_circ >0 or thick_saucer_circ > 0)
then
if i < (max_value/2)
then j = value + (max_value/2)
else j = value - (max_value/2)
end
local start_saucer = (cup_sector_angle * j) - (value*cup_sector_angle*0.5*thick_saucer_circ)
local stop_saucer = (cup_sector_angle * j) + (value*cup_sector_angle*0.5*thick_saucer_circ)
cairo_arc(display, x, y, saucer_radius, angle_to_position(cup_start_angle, start_saucer), angle_to_position(cup_start_angle, stop_saucer))
cairo_set_source_rgba(display, rgb_to_r_g_b(saucer_fg_clr, saucer_fg_alpha))
cairo_set_line_width(display, saucer_thickness)
cairo_stroke(display)
--thin saucer
if inner_saucer == true
then rt = (saucer_radius - 0.5) + (0.5 * saucer_thickness)
else rt = (saucer_radius + 0.5) - (0.5 * saucer_thickness)
end
local start_thin_saucer = (cup_sector_angle * j) - (max_value *0.5*cup_sector_angle*thin_saucer_circ)
local stop_thin_saucer = (cup_sector_angle * j) + (max_value *0.5*cup_sector_angle*thin_saucer_circ)
cairo_arc(display, x, y, rt, angle_to_position(cup_start_angle, start_thin_saucer), angle_to_position(cup_start_angle, stop_thin_saucer))
cairo_set_source_rgba(display, rgb_to_r_g_b(saucer_fg_clr, saucer_fg_alpha))
cairo_set_line_width(display, 1)
cairo_stroke(display)
end
--saucer mark
if saucer_mark_fg_alpha > 0
then
local start_cm = (cup_sector_angle * value) - (handle_circ *0.5 )
local stop_cm = (cup_sector_angle * value) + (handle_circ *0.5 )
cairo_arc(display, x, y, saucer_radius, angle_to_position(cup_start_angle, start_cm), angle_to_position(cup_start_angle, stop_cm))
cairo_set_source_rgba(display, rgb_to_r_g_b(saucer_mark_fg_clr, saucer_mark_fg_alpha))
cairo_set_line_width(display, saucer_thickness)
cairo_stroke(display)
end
--graduation mark
local graduation_radius = data['graduation_radius']
local graduation_thickness, graduation_mark_circ = data['graduation_thickness'], data['graduation_mark_circ']
local graduation_mark_angle = data['graduation_mark_angle']
local graduation_fg_clr, graduation_fg_alpha = data['graduation_fg_clr'], data['graduation_fg_alpha']
if graduation_radius > 0 and graduation_thickness > 0 and graduation_mark_angle > 0 then
if cup_start_angle < cup_end_angle
then number_graduation = (cup_end_angle-cup_start_angle) / graduation_mark_angle
else number_graduation = (cup_end_angle+(360-cup_start_angle)) / graduation_mark_angle
end
local i = 0
while i < number_graduation do
cairo_set_line_width(display, graduation_thickness)
local start_arc_grad = (graduation_mark_angle * (i-1)) - (graduation_mark_circ *0.5)
local stop_arc_grad = (graduation_mark_angle * (i-1)) + (graduation_mark_circ *0.5)
cairo_arc(display, x, y, graduation_radius, angle_to_position(cup_start_angle, start_arc_grad), angle_to_position(cup_start_angle, stop_arc_grad))
cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_clr,graduation_fg_alpha))
cairo_stroke(display)
cairo_set_line_width(display, cup_wall_thickness)
i = i + 1
end
end
-- text
local txt_fg_clr, txt_fg_alpha = data['txt_fg_clr'], data['txt_fg_alpha']
local txt_weight, txt_size = data['txt_weight'], data['txt_size']
local txt_fg_clr, txt_fg_alpha = data['txt_fg_clr'], data['txt_fg_alpha']
local caption = data['caption']
local caption2 = data['caption2']
if inner_saucer == true
then
ytxt=-(txt_size*0.5)
else ytxt =(txt_size)
end
cairo_select_font_face (display, "hooge 05_53", CAIRO_FONT_SLANT_NORMAL, txt_weight);
cairo_set_font_size (display,txt_size)
cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_clr, txt_fg_alpha))
cairo_move_to (display,x-(saucer_radius*0.7),(y+ytxt))
cairo_show_text (display, caption ) cairo_show_text (display,value)cairo_show_text (display, caption2 )
cairo_stroke (display)
end
-------------------------------------------------------------------------------
-- loads data and displays table_settings
function display_table_settings(display)
local function load_table_settings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
value = tonumber(str)
if value == nil then value = 0 end
draw_table_setting_ring(display, data, value)
end
for i in pairs(table_setting) do
load_table_settings(display, table_setting[i])
end
end
-------------------------------------------------------------------------------
function conky_main()
if conky_window == nil then
return
end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local display = cairo_create(cs)
local updates = conky_parse('${updates}')
update_num = tonumber(updates)
if update_num > 5 then
cairo_set_antialias (display, CAIRO_ANTIALIAS_SUBPIXEL)
display_table_settings(display)
cairo_set_antialias (display, CAIRO_ANTIALIAS_DEFAULT)
end
cairo_surface_destroy(cs)
cairo_destroy(display)
end
# -- Paramètres Conky Météo -- #
# Text alignment, other possible values are commented
alignment mr
#alignment top_right
#alignment bottom_left
#alignment bottom_right
# -- Conky settings -- #
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
imlib_cache_size 0
# -- Window specifications -- #
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorate,skip_taskbar,skip_pager,below #sticky,
own_window_argb_visual yes
own_window_argb_value 150
show_graph_range no
show_graph_scale no
short_units yes
own_window_class Conky
border_inner_margin 0
border_outer_margin 0
# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
# -- Couleurs -- #
default_color 645D5D
#color1 3B6702
#color2 645D5D
color0 Cornsilk1#FFD700#GOLD#3b6702 # vert
color1 black
color2 white
color3 EFEFEF # argile
color4 LightGoldenrod3#vert_spring#645d5d # gris foncé
color5 7FDD4C # vert clair
color6 CC0000 # rouge
color7 884DA7 # mauve
color8 6892C6 # bleu ciel 2
color9 443AFF # bleu marine
# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 25
gap_y -100
# Minimum size of text area
minimum_size 305 305 #Taille minimum (px) ; largeur / hauteur
maximum_width 305 #Largeur maximum (px)
#out_to_console no
# Force UTF8? note that UTF8 support required XFT
#override_utf8_locale yes
# Stippled borders?
#stippled_borders 0
# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0
# set to yes if you want all text to be in uppercase
uppercase no
# Add spaces to keep things from moving about? This only affects certain objects.
#use_spacer no
# -- Text settings -- #
# Use Xft?
use_xft yes
xftalpha 0.8 #0.4
xftfont caviar dreams:style=Bold:size=9 #Helvetica LT Std:size=10 #MaiandraGD:size=10
TEXT
##RADAR_EUROPE
${execi 1200 /media/DATEN/francescoPC/Conky/nasa/ragaEUR/script_test_convert.sh}
${image /tmp/imagesat-couvnuage.png -p 0,0 -s 300x300 -f 60}
#!/bin/bash
# Crée par JPDipsy
# script de recupération imagesat couverture nuageuse http://www.sat24.com
# et mise en forme polaroïd imagemagick et pagecurl doivent être installés
# ce script et le script pagecurl doivent être dans le même rep.
#----------------------------------------------------------------------------------
path=`dirname $0`
heuremodif=`date +%H`; minmodif=`date +%M`
# ce que vous voulez
fonte=monofur
nomimage=imagesat-couvnuage
tailleimage=60 # ceci est en pourcentage
tailledecoupe=440x440
rotation=0
libelle="Infrarot Radarbild um "
wget -q -O /tmp/$nomimage.gif "http://www.meteo-mc.fr/dedie/Images/sat/satireu1.gif"
function mise_en_forme_image {
convert /tmp/$nomimage.png -background gray60 -bordercolor gray60 -border 1% -gravity South -splice 0x22 -density 150 \
-font $fonte -pointsize 10 -annotate 0x10-3+8 "$libelle $heuremodif h $minmodif m" /tmp/$nomimage.png
#creation coin et masque à l'aide du script pagecurl
#composition image finale
convert /tmp/$nomimage.png -background none -alpha set -gravity SouthEast -define compose:outside-overlay=false \
-compose DstIn -composite -resize $tailleimage% -virtual-pixel background \
+distort ScaleRotateTranslate $rotation +repage /tmp/$nomimage.png
#rm /tmp/pagecurl_overlay.png ; rm /tmp/pagecurl_mask.png
##aqua effect
convert /tmp/$nomimage.png -alpha off -fill white -colorize 100% \
-draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
-background gray60 -alpha Shape /tmp/thumbnail_mask.png
###aqua effect2
convert /tmp/thumbnail_mask.png -bordercolor None -border 1x1 \
-alpha Extract -blur 0x10 -shade 130x30 -alpha On \
-background gray60 -alpha background -auto-level \
-function polynomial 3.5,-5.05,2.05,0.3 \
\( +clone -alpha extract -blur 0x2 \) \
-channel RGB -compose multiply -composite \
+channel +compose -chop 1x1 \
/tmp/thumbnail_lighting.png
##final
convert /tmp/$nomimage.png -alpha Set /tmp/thumbnail_lighting.png \
\( -clone 0,1 -alpha Opaque -compose Hardlight -composite \) \
-delete 0 -compose In -composite \
/tmp/imagesat-couvnuage.png
}
function ombre {
convert /tmp/$nomimage.png -background red \( +clone -shadow 60x4+2+2 \) +swap -background none -flatten /tmp/$nomimage.png
}
if [[ -e /tmp/$nomimage.gif ]] ; then
# decoupage de la partie utile
convert /tmp/$nomimage.gif -filter Lanczos -crop $tailledecoupe+140+110\! /tmp/$nomimage.png
mise_en_forme_image ; ombre ; rm /tmp/$nomimage.gif
else
# comme ça votre conky aura toujours une image au cas ou
convert -size $tailledecoupe plasma: /tmp/$nomimage.png
libelle="Désolé pas d'image radar à "
mise_en_forme_image ; ombre
fi
ORIGINAL-Daten
font=White-Rabbit-Regular
tailleimage=60 #prozentualer Wert
tailledecupe=400x400
libelle="Image radar infrarouge"
Zeile 21 -border 2%
Zeile 22 -pointsize 8
ceci est en pourcentage dies ist ein prozentualer
taille image Bildgröße
taille decoupe Größe decupe
density Dichte
Zurück zu Allgemeine Diskussionen über Mageia
Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast