Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#2151 Le 09/12/2012, à 20:07

chepioq

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Je viens de m’apercevoir que tu utilises xfce.

Il y a des problèmes avec la transparence de conky et certaines versions de xfce (voir ici : http://forum.xfce.org/viewtopic.php?id=6847 )

Il donne certaines solutions, dont la dernière me semble la plus intéressante.


Tout est dans tout et réciproquement....

Hors ligne

#2152 Le 10/12/2012, à 13:56

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@Didier-T
Salut; finalement avec les modifs du script qui récupère les images d'archives de la nasa, j'ai fais un simple diaporama en commentant les récupérations de textes...Ensuite un script convert pour redimensionner et mettre un effet "aqua".
Je ne sais pas si c'était la bonne marche à suivre; bon ça fonctionne mais le dossier ou le travail se fait avec les scripts, se rempli de "png" que j'avais pourtant décidé d'éffacer à la fin du script...?
diaponasa
Si ça fait trop mal aux yeux j'enlève... lol cool

Donc voici :
Script perl modifié vers ~/wallpapers "random-nasa-wallpaper.pl":

 #!/usr/bin/perl
# Copyright (c) Laszlo Simon.
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or ( at your option) any later version.
#             
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#                            
# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA)

# CONFIGURATION
##$explonation = 'true';        # true | false
##$explonation_place = 'south'; # east|north|west|south|norteast|...

# INIT
if (`xdpyinfo | grep dimensions` =~ /(\d+)x(\d+)\s+pixels/)
{
  ($width, $height) = ($1,$2);
}
else
{
  die("Can not determine screen resolution. Maybe 'xdpyinfo' not installed.\n");
}
  
$explonation_width = int($width * 2 / 3);
$explonation_height = int($width / 10);

$date = sprintf("%02d",0+int(rand(8)))
        .sprintf("%02d",1+int(rand(12)))
        .sprintf("%02d",1+int(rand(28)));

if (system("wget --version"))
{
  die("'wget' should be installed.\n")
}

system("wget -O /tmp/apxxxxxx.html 'http://antwrp.gsfc.nasa.gov/apod/ap$date.html'");

# Get image

open HTML, "/tmp/apxxxxxx.html";
$content = join('',(<HTML>));
close HTML;

$content =~ /\<a\s+href\=\"((?:\w+\/)*)(\w+)(\.\w+)\"\s*\>\s*\n*\s*\<img/ims;

$path = $1;
$img = $2;
$ext = $3;

`mkdir -p ~/wallpapers`;
print ">>>>http://antwrp.gsfc.nasa.gov/$path$img$ext\n";
system("wget -O ~/wallpapers/$img$ext 'http://antwrp.gsfc.nasa.gov/$path$img$ext'");

# Get text

#if (system("html2text -version"))
#{
#  warn("Explonation disabled. 'html2text' should be installed.\n");
#  $explonation = 'false';
#}

#if (system("convert -version"))
#{
#  warn("Explonation disabled. 'convert' (imagemagick) should be installed. \n");
#  $explonation = 'false';
#}


#if ($explonation eq 'true')
#{
#  system("html2text -style pretty -o /tmp/apxxxxxx.txt /tmp/apxxxxxx.html");
 
#  open TXT, "/tmp/apxxxxxx.txt";
#  $content = join('',(<TXT>));
#  close TXT;

#  $text = 
#    ($content =~ /Explanation:\s*(.*)\s*Tomorrow\'s picture:/s)
#    ? $1
#    : '';

#  print $text."\n";
  
#  $text =~ s/\n/ /g;

#  open TXT, ">/tmp/apxxxxxx-anno.txt";
#  print TXT $text;
#  close TXT;

#  system("convert ~/wallpapers/$img$ext "
#         ."-resize $width"."x$height\\> "
#         ."-size $width"."x$height xc:black +swap "
#         ."-gravity center "
#         ."-composite "
#         ."~/wallpapers/$img$ext"
#         );
         
#  system("convert "
#         ."-background '#0008' "
#         ."-fill white "
#         ."-gravity north "
#         ."-pointsize 20 "
#         ."-size $explonation_width"."x$explonation_height "
#         ."caption:\@/tmp/apxxxxxx-anno.txt "
#         ."~/wallpapers/$img$ext "
#          ."+swap -gravity $explonation_place -composite "
#         ."~/wallpapers/$img$ext"
#         );
#}

system("mv ~/wallpapers/$img$ext ~/wallpapers/image.jpg");
 

script convert "random_nasa_pix.sh":

 #!/bin/bash

convert ~/wallpapers/image.jpg  ~/wallpapers/image_random.png

convert ~/wallpapers/image_random.png -resize 640x360 ~/wallpapers/image_nasalight.png
##aqua effect
convert ~/wallpapers/image_nasalight.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     ~/wallpapers/thumbnail_mask.png
###aqua effect2
convert ~/wallpapers/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 \
          ~/wallpapers/thumbnail_lighting.png
##final
convert ~/wallpapers/image_nasalight.png -alpha Set ~/wallpapers/thumbnail_lighting.png \
          \( -clone 0,1 -alpha Opaque -compose Hardlight -composite \) \
          -delete 0 -compose In -composite \
          ~/wallpapers/image_nasa.png

#convert ~/wallpapers/image_nasa.png -resize 640x360 ~/wallpapers/image_nasalight.png

rm ~/wallpapers/thumbnail_lighting.png ;rm ~/wallpapers/thumbnail_mask.png ;rm ~/wallpapers/image_nasalight.png ;rm ~/wallpapers/image_random.png
 

conky:

 background yes
update_interval 30
total_run_times 0

own_window yes
own_window_transparent yes
own_window_type override
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pagers
double_buffer yes
minimum_size 650 400#Taille minimum (px) ; largeur / hauteur
maximum_width 650  
alignment ml

gap_x 20
gap_y -80

imlib_cache_size 0
text_buffer_size 2048

TEXT

${execi 60 ~/développement/pgcrs-0.2.1/random-nasa-wallpaper.pl > /dev/null 2>&1}

${image ~/wallpapers/image_nasa.png -p 0,0 -n}

${execi 60 ~/.conky/script/random_nasa_pix.sh} 

Dernière modification par ragamatrix (Le 10/12/2012, à 23:14)

Hors ligne

#2153 Le 12/12/2012, à 17:28

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

J'essaie de traduire un calendrier maya lua de l'anglais vers le français et je rencontre quelques difficultés...
Dans ce script je voudrais changer : "wednesday le douze december" par "mercredi 12 decembre" donc que la date soit formatée correctement dans le script mais je n'y arrive pas... sad
maya-trad
script en travaux :
mayan5.lua:

  --[[mayancalander by mrpeachy . version5.18.11
changes
improved and shortened number_to_words and date_to_words functions
increased number of settings (settings begin on line 65)
call in conkyrc like so
lua_load /path to file/filename.lua
lua_draw_hook_pre draw_fig

note about color and alpha
to set colors use the following format
color={0xFFFFFF,1}
         ^      ^
       color  alpha
]]
require 'cairo'
-------------------------------------------------------------------
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end--of function
-------------------------------------------------------------------
function number_to_words(number)
--by mrpeachy 11-4-2012
number=tonumber(number)
local n_len=string.len(number)
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"un","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","dix sept","dix huit","dix neuf",}
n2_tab={"dix","vingt","trente","quarante","cinquante","soixante","soixante dix","quatre vingt","quatre vingt dix"}
if tu<20 and tu~=10 and number~=0 then 
	nout=n1_tab[tu]
elseif tu==10 then
	nout="dix"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	nout=n2_tab[t]..joinu..u
elseif number==0 then
nout="zero"
end
if number>99 and number~=100 then
	h=n1_tab[h]
	return h.." cent "..nout
elseif number==100 then
	return " cent "
elseif number<100 then
	return nout
end
end--function
---------------------------------------------------------------------
function date_to_words()
date=tonumber(os.date("%d"))
datecut=string.gsub(date, ".", "%1|")
datetable=string.split(datecut, "|")
d1_tab={d1="premier",d2="deux",d3="trois",d4="quatre",d5="cinq",d6="six",d7="sept",d8="huit",d9="neuf",d10="dix",d11="onze",d12="douze",d13="treize",d14="quatorze",d15="quinze",d16="seize",d17="dix sept",d18="dix huit",d19="dix neuf",d20="vingt",d30="trente"}
d2_tab={d2="vingt",d3="trente",}
if tonumber(date)<21 or tonumber(date)==30 then
return (d1_tab[tostring("d" .. date)])
elseif tonumber(date)>20 and tonumber(date)~=30 then
return (d2_tab[tostring("d" .. datetable[1])] .. " " .. d1_tab[tostring("d" .. datetable[2])])
end
end--function
----------------------------------------------------------------------
function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end
----------------------------------------------------------------------
function conky_draw_fig()
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>5 then
--#########################################################################################################
--#########################################################################################################
--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--
--center position
hx0,hy0=200,200
inner_radius=40
--line width
linew=1
--general settings to apply globally, can be altered/overriden for each section below
--line color and alpha
local global_line_color={0xFFFFFF,1}
--font
local font="mono"
--font size
local fsize=10
--text color and alpha
local global_text_color={0xFFFF00,1}
--gap under text
local tbg=3
--gap from indicator to text
local tig=6
--indicator circle width
local cw=10
--text circle width
local tcw=13
--indicator color and alpha
local global_indicator_color={0xFFFFFF,1}
--############################################
--settings for each section of calendar
--############################################
--MONTHS--------------------------------------
--line color and alpha
--eg month_line_color={0xFFFFFF,1}
local month_line_color=global_line_color
--text
local mfont=font
local mfsize=fsize
--text color and alpha
local month_text_color=global_text_color
--gap at bottom of text
local mtbg=tbg
--gap from indicator to text
local mtig=tig
--circle width
local mcw=cw
--text circle width
local mtcw=tcw
--indicator color and alpha
local month_indicator_color=global_indicator_color
--############################################
--DAYS----------------------------------------
--line color and alpha
--eg day_line_color={0xFFFFFF,1}
local day_line_color=global_line_color
--text
local dfont=font
local dfsize=fsize
--text color and alpha
local day_text_color=global_text_color
--gap at bottom of text
local dtbg=tbg
--gap from indicator to text
local dtig=tig
--circle width
local dcw=cw
--text circle width
local dtcw=tcw
--indicator color and alpha
local day_indicator_color=global_indicator_color
--############################################
--HOURS---------------------------------------
--line color and alpha
--eg hour_line_color={0xFFFFFF,1}
local hour_line_color=global_line_color
--text
local hfont=font
local hfsize=fsize
--text color
local hour_text_color=global_text_color
--gap at bottom of text
local htbg=tbg
--gap from indicator to text
local htig=tig
--indicator circle width
local hcw=cw
--text circle width
local htcw=tcw
--indicator color
local hour_indicator_color=global_indicator_color
--############################################
--MINUTES-------------------------------------
--line color and alpha
--eg min_line_color={0xFFFFFF,1}
local min_line_color=global_line_color
--text
local minfont=font
local minfsize=fsize
--text color and alpha
local min_text_color=global_text_color
--gap at bottom of text
local mintbg=tbg
--gap from indicator to text
local mintig=tig
--circle width
local mincw=cw
--text circle width
local mintcw=tcw
--indicator color and alpha
local min_indicator_color=global_indicator_color
--############################################
--SECONDS-------------------------------------
--line color and alpha
--eg sec_line_color={0xFFFFFF,1}
local sec_line_color=global_line_color
--text
local sfont=font
local sfsize=fsize
--text color and alpha
local sec_text_color=global_text_color
--gap at bottom of text
local stbg=tbg
--gap from indicator to text
local stig=tig
--circle width
local scw=cw
--text circle width
local stcw=tcw
--indicator color and alpha
local sec_indicator_color=global_indicator_color
--#################################################
--END OF SETTINGS--END OF SETTINGS--END OF SETTINGS
--#################################################
--months of the year---------------------------------------------------------------------------------------------------
mnrad1=inner_radius
mnrad2=mnrad1+mcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_line_color))
--draw circles
cairo_set_line_width (cr,linew)
cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
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))
yeardays=31+febdaynum+31+30+31+30+31+31+30+31+30+31
yearsec=(yeardays*24*60*60)
jan=31*24*60*60
feb=jan+(febdaynum*24*60*60)
mar=feb+(31*24*60*60)
apr=mar+(30*24*60*60)
may=apr+(31*24*60*60)
jun=may+(30*24*60*60)
jul=jun+(31*24*60*60)
aug=jul+(31*24*60*60)
sep=aug+(30*24*60*60)
oct=sep+(31*24*60*60)
nov=oct+(30*24*60*60)
dec=nov+(31*24*60*60)
secdays = {jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}
--circle indicator lines
for i=1,12 do
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx1=0+mnrad1*(math.sin(arc))
mny1=0-mnrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx2=0+mnrad2*(math.sin(arc))
mny2=0-mnrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
end
--indicator-----------------------------------------------------
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_indicator_color))
doy=tonumber(os.date("%j"))
yrsecs=((doy-1)*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mnrad3=mnrad2+mtcw
arc=(2*math.pi/360)*((360/yearsec)*(yrsecs))
mnx1=0+(mnrad2+linew)*(math.sin(arc))
mny1=0-(mnrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))+4)
mnx2=0+mnrad3*(math.sin(arc))
mny2=0-mnrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))-4)
mnx3=0+mnrad3*(math.sin(arc))
mny3=0-mnrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx3,hy0+mny3)
cairo_stroke (cr)
--circlewriting-------------------------------------------------
--text must be in quotes
text=((string.upper(os.date('%B'))) .. " DEUX MILLE " .. string.upper(number_to_words(os.date('%y'))))
start=((360/yearsec)*((yrsecs))+mtig)
slen2=string.len(text)
finish=start+270
circlewriting(text,mfont,mfsize,mnrad2+mtbg,hx0,hy0,month_text_color,start,finish)
--end of months around year-------------------------------------------------------------------------------------------------------------------------------
--##########################################################################################
--days around month----------------------------------------------------------------------
drad1=mnrad3
drad2=drad1+dcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,drad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,drad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
monthnum=(tonumber(os.date('%m')))
monthdays = { 31, febdaynum, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--drawin circle indicator lines
for i=1,monthdays[monthnum] do
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx1=0+drad1*(math.sin(arc))
dy1=0-drad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx2=0+drad2*(math.sin(arc))
dy2=0-drad2*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_indicator_color))
daynumsec=(tonumber(os.date('%d'))*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
monthnumsec=(monthdays[monthnum])*24*60*60
drad3=drad2+dtcw
arc=(2*math.pi/360)*((360/monthnumsec)*(daynumsec))
dx1=0+(drad2+linew)*(math.sin(arc))
dy1=0-(drad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))+4)
dx2=0+drad3*(math.sin(arc))
dy2=0-drad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))-4)
dx3=0+drad3*(math.sin(arc))
dy3=0-drad3*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx3,hy0+dy3)
cairo_stroke (cr)
--circlewriting
text=((string.upper(os.date('%A'))) .. " LE " .. string.upper(date_to_words()))
start=((360/monthnumsec)*(daynumsec)+dtig)
slen1=string.len(text)
finish=start+(7.5*slen1)
circlewriting(text,dfont,dfsize,drad2+dtbg,hx0,hy0,day_text_color,start,finish)
--end of days around month-------------------------------------------------------------------------------------------------------
--##########################################################################################
--hours around day ---------------------------------------------------------------------------------------------------------------------
hrad1=drad3
hrad2=hrad1+hcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_line_color))
--draw eings
cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
cairo_stroke (cr)
--draw ring indicator lines
for i=1,24 do
arc=((2*math.pi/360)*((360/24)*i))
hx1=0+hrad1*(math.sin(arc))
hy1=0-hrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/24)*i))
hx2=0+hrad2*(math.sin(arc))
hy2=0-hrad2*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_indicator_color))
hrsec=(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
hrad3=hrad2+htcw
arc=((2*math.pi/360)*((360/(24*60*60)*hrsec)))
hx1=0+(hrad2+linew)*(math.sin(arc))
hy1=0-(hrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)-4)
hx2=0+hrad3*(math.sin(arc))
hy2=0-hrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)+4)
hx3=0+hrad3*(math.sin(arc))
hy3=0-hrad3*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx3,hy0+hy3)
cairo_stroke (cr)
--circlewriting
hrnum=tonumber(os.date('%H'))
if hrnum==1 then hour="HEURE"
else hour="HEURES" end
text=((string.upper(number_to_words(hrnum))) .. " " .. hour)
start=((360/(24*60*60))*(hrsec)+htig)
slen4=string.len(text)
finish=start+(slen4*5)
circlewriting(text,hfont,hfsize,hrad2+htbg,hx0,hy0,hour_text_color,start,finish)
--end of hours around day----------------------------------------------------------------------------------------------------
--##########################################################################################
--minutes around hour--------------------------------------------------------------------------------------------------------------
minrad1=hrad3
minrad2=minrad1+mincw
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,minrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,minrad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
mx1=0+minrad1*(math.sin(arc))
my1=0-minrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
mx2=0+minrad2*(math.sin(arc))
my2=0-minrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_indicator_color))
minsec=(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
minrad3=minrad2+mintcw
arc=((2*math.pi/360)*((360/(60*60)*minsec)))
mx1=0+(minrad2+linew)*(math.sin(arc))
my1=0-(minrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)-4)
mx2=0+minrad3*(math.sin(arc))
my2=0-minrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)+4)
mx3=0+minrad3*(math.sin(arc))
my3=0-minrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx3,hy0+my3)
cairo_stroke (cr)
--circlewriting
min=tonumber(os.date('%M'))
if min==1 then minute="MINUTE"
else minute="MINUTES" end
text=((string.upper(number_to_words(min))) .. " " .. minute)
start=((360/(60*60))*(minsec)+mintig)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(text,minfont,minfsize,minrad2+mintbg,hx0,hy0,min_text_color,start,finish)
--end minutes around hour--------------------------------------------------------------------------------------
--##########################################################################################
--seconds of minute-------------------------------------------------------------------------------------------
srad1=minrad3
srad2=srad1+scw
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
sx1=0+srad1*(math.sin(arc))
sy1=0-srad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
sx2=0+srad2*(math.sin(arc))
sy2=0-srad2*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_indicator_color))
sec=(tonumber(os.date('%S')))
srad3=srad2+stcw
arc=((2*math.pi/360)*((360/(60)*sec)))
sx1=0+(srad2+linew)*(math.sin(arc))
sy1=0-(srad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))-4)
sx2=0+srad3*(math.sin(arc))
sy2=0-srad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))+4)
sx3=0+srad3*(math.sin(arc))
sy3=0-srad3*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx3,hy0+sy3)
cairo_stroke (cr)
--outer circle
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
cairo_arc (cr,hx0,hy0,srad3,0,2*math.pi)
cairo_stroke (cr)
--circlewriting
sec=tonumber(os.date('%S'))
if sec==1 then second="SECONDE"
else second="SECONDES" end
text=(string.upper(number_to_words(sec)) .. " " .. second)
start=((360/60)*((sec))+stig)
slen3=string.len(text)
finish=start+(slen3*5)
circlewriting(text,sfont,sfsize,srad2+stbg,hx0,hy0,sec_text_color,start,finish)
--end seconds of minute-----------------------------------------------------------------------------------------------------------------------------
--END OF CALENDAR
--#########################################################################################################
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
---------------------------------------------------------------------------
function circlewriting(text, font, fsize, radi, horiz, verti, text_color, start, finish)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,rgb_to_r_g_b(text_color));
local inum=string.len(text)
deg=(finish-start)/(inum-1)
degrads=(math.pi/180)
local textcut=string.gsub(text, ".", "%1|")
texttable=string.split(textcut, "|")
for i=1,inum do
interval=(degrads*(start+(deg*(i-1))))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval)
end
end--of function
--------------------------------------------------------------------------- 

Hors ligne

#2154 Le 12/12/2012, à 18:04

Didier-T

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@ ragamatrix,

ligne n°343

text=((string.upper(os.date('%A'))) .. " LE " .. string.upper(date_to_words()))

le problème vient du fait que lua n'utilise pas les format locaux pour les dates donc os.date('%A'), ne renvoie pas mercredi, mais Wednesday.
Il faut donc ruser.

je pense que ceci pourrais faire l’affaire.

local jour=conky_parse( '${exec date +%A}' )
text=((string.upper(jour)) .. " LE " .. string.upper(date_to_words()))

Edit:
j'avais pas fait attention au December

ligne 291, même principe.
ceci

text=((string.upper(os.date('%B'))) .. " DEUX MILLE " .. string.upper(number_to_words(os.date('%y'))))

devient

local mois=conky_parse( '${exec date +%B}' )
text=((string.upper(mois)) .. " DEUX MILLE " .. string.upper(number_to_words(os.date('%y'))))

Dernière modification par Didier-T (Le 12/12/2012, à 19:12)

Hors ligne

#2155 Le 12/12/2012, à 18:09

chepioq

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@ragamatrix

Essaye en ajoutant une ligne dans le conky qui lance ton script lua :

${time %t}

juste après TEXT


Tout est dans tout et réciproquement....

Hors ligne

#2156 Le 12/12/2012, à 18:51

maan

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

ragamatrix a écrit :

J'essaie de traduire un calendrier maya lua de l'anglais vers le français et je rencontre quelques difficultés...
Dans ce script je voudrais changer : "wednesday le douze december" par "mercredi 12 decembre" donc que la date soit formatée correctement dans le script mais je n'y arrive pas... sad
http://pix.toile-libre.org/upload/origi … 329601.png

........

MODE      BOulette ON :   Dépèche toi il ne te reste plus que 9 jours  lol:lol:   

MODE     BOulette OFF


Ubuntu_studio 14.04

Hors ligne

#2157 Le 12/12/2012, à 21:33

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@Didier-T et Chepioq
ça ne fonctionne pas ... merci quand même.

Hors ligne

#2158 Le 13/12/2012, à 07:34

chepioq

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

ragamatrix a écrit :

@Didier-T et Chepioq
ça ne fonctionne pas ... merci quand même.

Chez moi, ton conky ne s"affiche même pas...

Je n'ai aucune erreur concernant le script lua, mais rien ne s'affiche...

Tu peux me donner le conky associé à ce script lua ?


Tout est dans tout et réciproquement....

Hors ligne

#2159 Le 13/12/2012, à 10:24

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@Chepioq
Salut, voici,
conky:

 # To use #! in a conky use: ${exec echo '#!'}
# OB_topconky

own_window yes
own_window_type override
own_window_transparent yes
own_window_hints below,skip_taskbar,skip_pager
own_window_title mayan-time
own_window_class mayan-time

background no
border_inner_margin 0
border_width 0
default_outline_color black
default_shade_color black
double_buffer yes
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
no_buffers yes
override_utf8_locale yes
pad_percents 2
short_units yes
stippled_borders 0
text_buffer_size 1028
uppercase no
use_spacer right
use_xft yes
xftfont Zekton:bold:size=10
xftalpha 1.0

# Colors
default_color DCDCDC #Gainsboro
color0 FFFFF0 #Ivory
color1 FFA07A #LightSalmon
color2 FF8C00 #Darkorange
color3 7FFF00 #Chartreuse
color4 778899 #LightSlateGrey
color5 FFDEAD #NavajoWhite
color6 00BFFF #DeepSkyBlue
color7 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #Red

imlib_cache_size 0

update_interval 1
gap_x 700 # left &right
gap_y 320 # up & down
minimum_size 640 640 # width, height
alignment tl



	

# -- Lua load -- #
lua_load ~/développement/mayan5.lua
lua_draw_hook_pre draw_fig



TEXT

#${image ~/développement/Mayan/dec.png -p 171,171 -s 56x56}
 

Hors ligne

#2160 Le 13/12/2012, à 14:58

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

maan a écrit :
ragamatrix a écrit :

J'essaie de traduire un calendrier maya lua de l'anglais vers le français et je rencontre quelques difficultés...
Dans ce script je voudrais changer : "wednesday le douze december" par "mercredi 12 decembre" donc que la date soit formatée correctement dans le script mais je n'y arrive pas... sad
http://pix.toile-libre.org/upload/origi … 329601.png

........

MODE      BOulette ON :   Dépèche toi il ne te reste plus que 9 jours  lol:lol:   

MODE     BOulette OFF

Salut;
L'idée n'était pas pour le calendrier de la fin des temps, mais c'est vrai qu'on en parle beaucoup.
Alors entre stargate et les mystérieuses cités d'or (pour les nostalgiques) l'idée c'est un truc dans ce genre (pour l'instant tout en Anglais, pour apprendre les chiffres et les dates)
English lesson for Didier-T wink and lua lessons for all of us by Didier-T :
EnglishMayaCalendar
Le script original de Mr Peachy:
mayan.lua

 --[[mayancalander by mrpeachy . version5.18.11
changes
improved and shortened number_to_words and date_to_words functions
increased number of settings (settings begin on line 65)
call in conkyrc like so
lua_load /path to file/filename.lua
lua_draw_hook_pre draw_fig

note about color and alpha
to set colors use the following format
color={0xFFFFFF,1}
         ^      ^
       color  alpha
]]
require 'cairo'
-------------------------------------------------------------------
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end--of function
-------------------------------------------------------------------
function number_to_words(number)
--by mrpeachy 11-4-2012
number=tonumber(number)
local n_len=string.len(number)
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen",}
n2_tab={"ten","twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"}
if tu<20 and tu~=10 and number~=0 then 
	nout=n1_tab[tu]
elseif tu==10 then
	nout="ten"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	nout=n2_tab[t]..joinu..u
elseif number==0 then
nout="zero"
end
if number>99 and number~=100 then
	h=n1_tab[h]
	return h.." hundred and "..nout
elseif number==100 then
	return "one hundred"
elseif number<100 then
	return nout
end
end--function
---------------------------------------------------------------------
function date_to_words()
date=tonumber(os.date("%d"))
datecut=string.gsub(date, ".", "%1|")
datetable=string.split(datecut, "|")
d1_tab={d1="first",d2="second",d3="third",d4="fourth",d5="fifth",d6="sixth",d7="seventh",d8="eigth",d9="nineth",d10="tenth",d11="eleventh",d12="twelfth",d13="thirteenth",d14="fourteenth",d15="fifteenth",d16="sixteenth",d17="seventeenth",d18="eighteenth",d19="nineteenth",d20="twentieth",d30="thirtieth"}
d2_tab={d2="twenty",d3="thirty",}
if tonumber(date)<21 or tonumber(date)==30 then
return (d1_tab[tostring("d" .. date)])
elseif tonumber(date)>20 and tonumber(date)~=30 then
return (d2_tab[tostring("d" .. datetable[1])] .. " " .. d1_tab[tostring("d" .. datetable[2])])
end
end--function
----------------------------------------------------------------------
function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end
----------------------------------------------------------------------
function conky_draw_fig()
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>5 then
--#########################################################################################################
--#########################################################################################################
--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--
--center position
hx0,hy0=200,200
inner_radius=40
--line width
linew=1
--general settings to apply globally, can be altered/overriden for each section below
--line color and alpha
local global_line_color={0xFFFFFF,1}
--font
local font="mono"
--font size
local fsize=10
--text color and alpha
local global_text_color={0xFFFF00,1}
--gap under text
local tbg=3
--gap from indicator to text
local tig=6
--indicator circle width
local cw=10
--text circle width
local tcw=13
--indicator color and alpha
local global_indicator_color={0xFFFFFF,1}
--############################################
--settings for each section of calendar
--############################################
--MONTHS--------------------------------------
--line color and alpha
--eg month_line_color={0xFFFFFF,1}
local month_line_color=global_line_color
--text
local mfont=font
local mfsize=fsize
--text color and alpha
local month_text_color=global_text_color
--gap at bottom of text
local mtbg=tbg
--gap from indicator to text
local mtig=tig
--circle width
local mcw=cw
--text circle width
local mtcw=tcw
--indicator color and alpha
local month_indicator_color=global_indicator_color
--############################################
--DAYS----------------------------------------
--line color and alpha
--eg day_line_color={0xFFFFFF,1}
local day_line_color=global_line_color
--text
local dfont=font
local dfsize=fsize
--text color and alpha
local day_text_color=global_text_color
--gap at bottom of text
local dtbg=tbg
--gap from indicator to text
local dtig=tig
--circle width
local dcw=cw
--text circle width
local dtcw=tcw
--indicator color and alpha
local day_indicator_color=global_indicator_color
--############################################
--HOURS---------------------------------------
--line color and alpha
--eg hour_line_color={0xFFFFFF,1}
local hour_line_color=global_line_color
--text
local hfont=font
local hfsize=fsize
--text color
local hour_text_color=global_text_color
--gap at bottom of text
local htbg=tbg
--gap from indicator to text
local htig=tig
--indicator circle width
local hcw=cw
--text circle width
local htcw=tcw
--indicator color
local hour_indicator_color=global_indicator_color
--############################################
--MINUTES-------------------------------------
--line color and alpha
--eg min_line_color={0xFFFFFF,1}
local min_line_color=global_line_color
--text
local minfont=font
local minfsize=fsize
--text color and alpha
local min_text_color=global_text_color
--gap at bottom of text
local mintbg=tbg
--gap from indicator to text
local mintig=tig
--circle width
local mincw=cw
--text circle width
local mintcw=tcw
--indicator color and alpha
local min_indicator_color=global_indicator_color
--############################################
--SECONDS-------------------------------------
--line color and alpha
--eg sec_line_color={0xFFFFFF,1}
local sec_line_color=global_line_color
--text
local sfont=font
local sfsize=fsize
--text color and alpha
local sec_text_color=global_text_color
--gap at bottom of text
local stbg=tbg
--gap from indicator to text
local stig=tig
--circle width
local scw=cw
--text circle width
local stcw=tcw
--indicator color and alpha
local sec_indicator_color=global_indicator_color
--#################################################
--END OF SETTINGS--END OF SETTINGS--END OF SETTINGS
--#################################################
--months of the year---------------------------------------------------------------------------------------------------
mnrad1=inner_radius
mnrad2=mnrad1+mcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_line_color))
--draw circles
cairo_set_line_width (cr,linew)
cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
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))
yeardays=31+febdaynum+31+30+31+30+31+31+30+31+30+31
yearsec=(yeardays*24*60*60)
jan=31*24*60*60
feb=jan+(febdaynum*24*60*60)
mar=feb+(31*24*60*60)
apr=mar+(30*24*60*60)
may=apr+(31*24*60*60)
jun=may+(30*24*60*60)
jul=jun+(31*24*60*60)
aug=jul+(31*24*60*60)
sep=aug+(30*24*60*60)
oct=sep+(31*24*60*60)
nov=oct+(30*24*60*60)
dec=nov+(31*24*60*60)
secdays = {jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}
--circle indicator lines
for i=1,12 do
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx1=0+mnrad1*(math.sin(arc))
mny1=0-mnrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx2=0+mnrad2*(math.sin(arc))
mny2=0-mnrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
end
--indicator-----------------------------------------------------
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_indicator_color))
doy=tonumber(os.date("%j"))
yrsecs=((doy-1)*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mnrad3=mnrad2+mtcw
arc=(2*math.pi/360)*((360/yearsec)*(yrsecs))
mnx1=0+(mnrad2+linew)*(math.sin(arc))
mny1=0-(mnrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))+4)
mnx2=0+mnrad3*(math.sin(arc))
mny2=0-mnrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))-4)
mnx3=0+mnrad3*(math.sin(arc))
mny3=0-mnrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx3,hy0+mny3)
cairo_stroke (cr)
--circlewriting-------------------------------------------------
--text must be in quotes
text=((string.upper(os.date('%B'))) .. " TWO THOUSAND AND " .. string.upper(number_to_words(os.date('%y'))))
start=((360/yearsec)*((yrsecs))+mtig)
slen2=string.len(text)
finish=start+270
circlewriting(text,mfont,mfsize,mnrad2+mtbg,hx0,hy0,month_text_color,start,finish)
--end of months around year-------------------------------------------------------------------------------------------------------------------------------
--##########################################################################################
--days around month----------------------------------------------------------------------
drad1=mnrad3
drad2=drad1+dcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,drad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,drad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
monthnum=(tonumber(os.date('%m')))
monthdays = { 31, febdaynum, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--drawin circle indicator lines
for i=1,monthdays[monthnum] do
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx1=0+drad1*(math.sin(arc))
dy1=0-drad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx2=0+drad2*(math.sin(arc))
dy2=0-drad2*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_indicator_color))
daynumsec=(tonumber(os.date('%d'))*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
monthnumsec=(monthdays[monthnum])*24*60*60
drad3=drad2+dtcw
arc=(2*math.pi/360)*((360/monthnumsec)*(daynumsec))
dx1=0+(drad2+linew)*(math.sin(arc))
dy1=0-(drad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))+4)
dx2=0+drad3*(math.sin(arc))
dy2=0-drad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))-4)
dx3=0+drad3*(math.sin(arc))
dy3=0-drad3*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx3,hy0+dy3)
cairo_stroke (cr)
--circlewriting
text=((string.upper(os.date('%A'))) .. " THE " .. string.upper(date_to_words()))
start=((360/monthnumsec)*(daynumsec)+dtig)
slen1=string.len(text)
finish=start+(7.5*slen1)
circlewriting(text,dfont,dfsize,drad2+dtbg,hx0,hy0,day_text_color,start,finish)
--end of days around month-------------------------------------------------------------------------------------------------------
--##########################################################################################
--hours around day ---------------------------------------------------------------------------------------------------------------------
hrad1=drad3
hrad2=hrad1+hcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_line_color))
--draw eings
cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
cairo_stroke (cr)
--draw ring indicator lines
for i=1,24 do
arc=((2*math.pi/360)*((360/24)*i))
hx1=0+hrad1*(math.sin(arc))
hy1=0-hrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/24)*i))
hx2=0+hrad2*(math.sin(arc))
hy2=0-hrad2*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_indicator_color))
hrsec=(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
hrad3=hrad2+htcw
arc=((2*math.pi/360)*((360/(24*60*60)*hrsec)))
hx1=0+(hrad2+linew)*(math.sin(arc))
hy1=0-(hrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)-4)
hx2=0+hrad3*(math.sin(arc))
hy2=0-hrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)+4)
hx3=0+hrad3*(math.sin(arc))
hy3=0-hrad3*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx3,hy0+hy3)
cairo_stroke (cr)
--circlewriting
hrnum=tonumber(os.date('%H'))
if hrnum==1 then hour="HOUR"
else hour="HOURS" end
text=((string.upper(number_to_words(hrnum))) .. " " .. hour)
start=((360/(24*60*60))*(hrsec)+htig)
slen4=string.len(text)
finish=start+(slen4*5)
circlewriting(text,hfont,hfsize,hrad2+htbg,hx0,hy0,hour_text_color,start,finish)
--end of hours around day----------------------------------------------------------------------------------------------------
--##########################################################################################
--minutes around hour--------------------------------------------------------------------------------------------------------------
minrad1=hrad3
minrad2=minrad1+mincw
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,minrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,minrad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
mx1=0+minrad1*(math.sin(arc))
my1=0-minrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
mx2=0+minrad2*(math.sin(arc))
my2=0-minrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_indicator_color))
minsec=(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
minrad3=minrad2+mintcw
arc=((2*math.pi/360)*((360/(60*60)*minsec)))
mx1=0+(minrad2+linew)*(math.sin(arc))
my1=0-(minrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)-4)
mx2=0+minrad3*(math.sin(arc))
my2=0-minrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)+4)
mx3=0+minrad3*(math.sin(arc))
my3=0-minrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx3,hy0+my3)
cairo_stroke (cr)
--circlewriting
min=tonumber(os.date('%M'))
if min==1 then minute="MINUTE"
else minute="MINUTES" end
text=((string.upper(number_to_words(min))) .. " " .. minute)
start=((360/(60*60))*(minsec)+mintig)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(text,minfont,minfsize,minrad2+mintbg,hx0,hy0,min_text_color,start,finish)
--end minutes around hour--------------------------------------------------------------------------------------
--##########################################################################################
--seconds of minute-------------------------------------------------------------------------------------------
srad1=minrad3
srad2=srad1+scw
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
sx1=0+srad1*(math.sin(arc))
sy1=0-srad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
sx2=0+srad2*(math.sin(arc))
sy2=0-srad2*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_indicator_color))
sec=(tonumber(os.date('%S')))
srad3=srad2+stcw
arc=((2*math.pi/360)*((360/(60)*sec)))
sx1=0+(srad2+linew)*(math.sin(arc))
sy1=0-(srad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))-4)
sx2=0+srad3*(math.sin(arc))
sy2=0-srad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))+4)
sx3=0+srad3*(math.sin(arc))
sy3=0-srad3*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx3,hy0+sy3)
cairo_stroke (cr)
--outer circle
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
cairo_arc (cr,hx0,hy0,srad3,0,2*math.pi)
cairo_stroke (cr)
--circlewriting
sec=tonumber(os.date('%S'))
if sec==1 then second="SECOND"
else second="SECONDS" end
text=(string.upper(number_to_words(sec)) .. " " .. second)
start=((360/60)*((sec))+stig)
slen3=string.len(text)
finish=start+(slen3*5)
circlewriting(text,sfont,sfsize,srad2+stbg,hx0,hy0,sec_text_color,start,finish)
--end seconds of minute-----------------------------------------------------------------------------------------------------------------------------
--END OF CALENDAR
--#########################################################################################################
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
---------------------------------------------------------------------------
function circlewriting(text, font, fsize, radi, horiz, verti, text_color, start, finish)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,rgb_to_r_g_b(text_color));
local inum=string.len(text)
deg=(finish-start)/(inum-1)
degrads=(math.pi/180)
local textcut=string.gsub(text, ".", "%1|")
texttable=string.split(textcut, "|")
for i=1,inum do
interval=(degrads*(start+(deg*(i-1))))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval)
end
end--of function
--------------------------------------------------------------------------- 

Dernière modification par ragamatrix (Le 13/12/2012, à 15:02)

Hors ligne

#2161 Le 14/12/2012, à 12:08

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Nouveau chrono Mr Peachy en Anglais big_smile
chrono
chrono
code lua :

 --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 ###################################################################

Dernière modification par ragamatrix (Le 14/12/2012, à 12:09)

Hors ligne

#2162 Le 14/12/2012, à 18:24

maan

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@ Ragamatrix

Salut une ptite idée en voyant ton chrono ci-dessus, le truc c'est que n'y connaissant pas grand chose je n'arrive pas à le faire tourner roll

J'ai copier le script lua en le nommant chrono.lua, j'ai crée un Conkyrc_Chrono sans rien après "TEXT"

# — 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

# — Window specifications — #

#own_window_class Conky
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

border_inner_margin 0
border_outer_margin 0

minimum_size 300 300
maximum_width 300 300

alignment tm

gap_x -250
gap_y 30


# — Graphics settings — #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

# — Text settings — #
use_xft yes
xftfont hooge 05_53:size=6
xftalpha 0.5

default_color FFFFFF

uppercase no
use_spacer right

color0 white
color1 orange
color2 green
color3 yellow

# — Lua Load — #
lua_load ~/Public/essai_conky/chrono.lua

TEXT

et en terminal, j'ai ça

┌─( maan ) - ( 3.2.0-34-generic ) - ( ~/Public/essai_conky )
└─> conky -c Conkyrc_Chrono
Conky: forked to background, pid is 17370
┌─( maan ) - ( 3.2.0-34-generic ) - ( ~/Public/essai_conky )
└─> 
Conky: desktop window (1200003) is subwindow of root window (158)
Conky: window type - override
Conky: drawing to created window (0x2600001)
Conky: drawing to double buffer

et rien qui s'affiche ....... j'ai du louper quelque chose tongue


Ubuntu_studio 14.04

Hors ligne

#2163 Le 14/12/2012, à 18:30

chepioq

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

maan a écrit :

@ Ragamatrix

Salut une ptite idée en voyant ton chrono ci-dessus, le truc c'est que n'y connaissant pas grand chose je n'arrive pas à le faire tourner roll

J'ai copier le script lua en le nommant chrono.lua, j'ai crée un Conkyrc_Chrono sans rien après "TEXT"

Il te faut au moins une ligne vide après TEXT...


Tout est dans tout et réciproquement....

Hors ligne

#2164 Le 14/12/2012, à 18:36

maan

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Merci Cheploq pour cette précision, donc j'ai mis deux lignes vide après "TEXT",  mais aucun changement ......


Ubuntu_studio 14.04

Hors ligne

#2165 Le 14/12/2012, à 18:46

chepioq

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Il te faut rajouter, dans ton conky,

lua_draw_hook_pre conky_main

juste après "lua_load ~/Public/essai_conky/chrono.lua"


Tout est dans tout et réciproquement....

Hors ligne

#2166 Le 14/12/2012, à 19:07

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

essaies ça :

 # To use #! in a conky use: ${exec echo '#!'}
# OB_topconky

own_window yes
own_window_type override
own_window_transparent yes
own_window_hints below,skip_taskbar,skip_pager,sticky
own_window_title breitling-time
own_window_class breitling-time

background yes
border_inner_margin 0
border_width 0
default_outline_color black
default_shade_color black
double_buffer yes
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
no_buffers yes
override_utf8_locale yes
pad_percents 2
short_units yes
stippled_borders 0
text_buffer_size 1028
uppercase no
use_spacer right
use_xft yes
xftfont White Rabbit:size=8
xftalpha 1.0

# Colors
default_color DCDCDC #Gainsboro
color0 FFFFF0 #Ivory
color1 FFA07A #LightSalmon
color2 FF8C00 #Darkorange
color3 7FFF00 #Chartreuse
color4 778899 #LightSlateGrey
color5 FFDEAD #NavajoWhite
color6 00BFFF #DeepSkyBlue
color7 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #Red

imlib_cache_size 0

update_interval 1
gap_x 0 # left &right
gap_y 0 # up & down
minimum_size 300 300 # width, height
alignment mm

# -- Lua load -- #
lua_load ~/développement/breitling.lua
lua_draw_hook_pre main

##lua_load ~/développement/draw_bg.lua

TEXT


 

breitling.lua:

 --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=150,150
--########################################################################################
--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(
150,--string or coodinate for clock center x
150,--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 ################################################################### 

Problème avec aiguilles corrigé

Dernière modification par ragamatrix (Le 14/12/2012, à 19:08)

Hors ligne

#2167 Le 15/12/2012, à 00:16

maan

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Ok c'est bon, merci chepioq,
il me manquait bien la ptite ligne la ptite ligne smile
Donc maintenant y'a plus qu'à bosser smile

EDIT : bon je l'ai customizer à mon idée (enfin surtout dans mes capacitées)
1355536459.png

Par contre comment je doit faire pour mettre le jour et le mois en français ??

Dernière modification par maan (Le 15/12/2012, à 03:00)


Ubuntu_studio 14.04

Hors ligne

#2168 Le 15/12/2012, à 07:16

chepioq

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

maan a écrit :

Par contre comment je doit faire pour mettre le jour et le mois en français ??

Ajoute cette ligne juste après TEXT

${time %t}

Et normalement tu devrais l'avoir en français...


Tout est dans tout et réciproquement....

Hors ligne

#2169 Le 16/12/2012, à 14:23

Didier-T

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@ ragamatrix,

aller un peut de déterrage,

donc le script horloge maya, en français.
avec les modifications que j'avais donné plus haut sa aurai du fonctionner, mais le passage en majuscule ne fonctionne pas a cause des accents, il sont donc neutralisé, pour les mois français.

  --[[mayancalander by mrpeachy . version5.18.11
changes
improved and shortened number_to_words and date_to_words functions
increased number of settings (settings begin on line 65)
call in conkyrc like so
lua_load /path to file/filename.lua
lua_draw_hook_pre draw_fig

note about color and alpha
to set colors use the following format
color={0xFFFFFF,1}
         ^      ^
       color  alpha
]]
require 'cairo'
-------------------------------------------------------------------
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end--of function
-------------------------------------------------------------------
function number_to_words(number)
--by mrpeachy 11-4-2012
number=tonumber(number)
local n_len=string.len(number)
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"un","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","dix sept","dix huit","dix neuf",}
n2_tab={"dix","vingt","trente","quarante","cinquante","soixante","soixante dix","quatre vingt","quatre vingt dix"}
if tu<20 and tu~=10 and number~=0 then 
	nout=n1_tab[tu]
elseif tu==10 then
	nout="dix"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	nout=n2_tab[t]..joinu..u
elseif number==0 then
nout="zero"
end
if number>99 and number~=100 then
	h=n1_tab[h]
	return h.." cent "..nout
elseif number==100 then
	return " cent "
elseif number<100 then
	return nout
end
end--function
---------------------------------------------------------------------
function date_to_words()
date=tonumber(os.date("%d"))
datecut=string.gsub(date, ".", "%1|")
datetable=string.split(datecut, "|")
d1_tab={d1="premier",d2="deux",d3="trois",d4="quatre",d5="cinq",d6="six",d7="sept",d8="huit",d9="neuf",d10="dix",d11="onze",d12="douze",d13="treize",d14="quatorze",d15="quinze",d16="seize",d17="dix sept",d18="dix huit",d19="dix neuf",d20="vingt",d30="trente"}
d2_tab={d2="vingt",d3="trente",}
if tonumber(date)<21 or tonumber(date)==30 then
return (d1_tab[tostring("d" .. date)])
elseif tonumber(date)>20 and tonumber(date)~=30 then
return (d2_tab[tostring("d" .. datetable[1])] .. " " .. d1_tab[tostring("d" .. datetable[2])])
end
end--function
----------------------------------------------------------------------
function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end
----------------------------------------------------------------------
function conky_draw_fig()
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>5 then
--#########################################################################################################
--#########################################################################################################
--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--
--center position
hx0,hy0=200,200
inner_radius=40
--line width
linew=1
--general settings to apply globally, can be altered/overriden for each section below
--line color and alpha
local global_line_color={0xFFFFFF,1}
--font
local font="mono"
--font size
local fsize=10
--text color and alpha
local global_text_color={0xFFFF00,1}
--gap under text
local tbg=3
--gap from indicator to text
local tig=6
--indicator circle width
local cw=10
--text circle width
local tcw=13
--indicator color and alpha
local global_indicator_color={0xFFFFFF,1}
--############################################
--settings for each section of calendar
--############################################
--MONTHS--------------------------------------
--line color and alpha
--eg month_line_color={0xFFFFFF,1}
local month_line_color=global_line_color
--text
local mfont=font
local mfsize=fsize
--text color and alpha
local month_text_color=global_text_color
--gap at bottom of text
local mtbg=tbg
--gap from indicator to text
local mtig=tig
--circle width
local mcw=cw
--text circle width
local mtcw=tcw
--indicator color and alpha
local month_indicator_color=global_indicator_color
--############################################
--DAYS----------------------------------------
--line color and alpha
--eg day_line_color={0xFFFFFF,1}
local day_line_color=global_line_color
--text
local dfont=font
local dfsize=fsize
--text color and alpha
local day_text_color=global_text_color
--gap at bottom of text
local dtbg=tbg
--gap from indicator to text
local dtig=tig
--circle width
local dcw=cw
--text circle width
local dtcw=tcw
--indicator color and alpha
local day_indicator_color=global_indicator_color
--############################################
--HOURS---------------------------------------
--line color and alpha
--eg hour_line_color={0xFFFFFF,1}
local hour_line_color=global_line_color
--text
local hfont=font
local hfsize=fsize
--text color
local hour_text_color=global_text_color
--gap at bottom of text
local htbg=tbg
--gap from indicator to text
local htig=tig
--indicator circle width
local hcw=cw
--text circle width
local htcw=tcw
--indicator color
local hour_indicator_color=global_indicator_color
--############################################
--MINUTES-------------------------------------
--line color and alpha
--eg min_line_color={0xFFFFFF,1}
local min_line_color=global_line_color
--text
local minfont=font
local minfsize=fsize
--text color and alpha
local min_text_color=global_text_color
--gap at bottom of text
local mintbg=tbg
--gap from indicator to text
local mintig=tig
--circle width
local mincw=cw
--text circle width
local mintcw=tcw
--indicator color and alpha
local min_indicator_color=global_indicator_color
--############################################
--SECONDS-------------------------------------
--line color and alpha
--eg sec_line_color={0xFFFFFF,1}
local sec_line_color=global_line_color
--text
local sfont=font
local sfsize=fsize
--text color and alpha
local sec_text_color=global_text_color
--gap at bottom of text
local stbg=tbg
--gap from indicator to text
local stig=tig
--circle width
local scw=cw
--text circle width
local stcw=tcw
--indicator color and alpha
local sec_indicator_color=global_indicator_color
--#################################################
--END OF SETTINGS--END OF SETTINGS--END OF SETTINGS
--#################################################
--months of the year---------------------------------------------------------------------------------------------------
mnrad1=inner_radius
mnrad2=mnrad1+mcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_line_color))
--draw circles
cairo_set_line_width (cr,linew)
cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
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))
yeardays=31+febdaynum+31+30+31+30+31+31+30+31+30+31
yearsec=(yeardays*24*60*60)
jan=31*24*60*60
feb=jan+(febdaynum*24*60*60)
mar=feb+(31*24*60*60)
apr=mar+(30*24*60*60)
may=apr+(31*24*60*60)
jun=may+(30*24*60*60)
jul=jun+(31*24*60*60)
aug=jul+(31*24*60*60)
sep=aug+(30*24*60*60)
oct=sep+(31*24*60*60)
nov=oct+(30*24*60*60)
dec=nov+(31*24*60*60)
secdays = {jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}
--circle indicator lines
for i=1,12 do
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx1=0+mnrad1*(math.sin(arc))
mny1=0-mnrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx2=0+mnrad2*(math.sin(arc))
mny2=0-mnrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
end
--indicator-----------------------------------------------------
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_indicator_color))
doy=tonumber(os.date("%j"))
yrsecs=((doy-1)*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mnrad3=mnrad2+mtcw
arc=(2*math.pi/360)*((360/yearsec)*(yrsecs))
mnx1=0+(mnrad2+linew)*(math.sin(arc))
mny1=0-(mnrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))+4)
mnx2=0+mnrad3*(math.sin(arc))
mny2=0-mnrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))-4)
mnx3=0+mnrad3*(math.sin(arc))
mny3=0-mnrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx3,hy0+mny3)
cairo_stroke (cr)
--circlewriting-------------------------------------------------
--text must be in quotes
local mois=conky_parse( '${exec date +%B}' ):gsub("é", "e"):gsub("û", "u")
text=((string.upper(mois)) .. " DEUX MILLE " .. string.upper(number_to_words(os.date('%y'))))
--text=((string.upper(os.date('%B'))) .. " DEUX MILLE " .. string.upper(number_to_words(os.date('%y'))))
start=((360/yearsec)*((yrsecs))+mtig)
slen2=string.len(text)
finish=start+270
circlewriting(text,mfont,mfsize,mnrad2+mtbg,hx0,hy0,month_text_color,start,finish)
--end of months around year-------------------------------------------------------------------------------------------------------------------------------
--##########################################################################################
--days around month----------------------------------------------------------------------
drad1=mnrad3
drad2=drad1+dcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,drad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,drad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
monthnum=(tonumber(os.date('%m')))
monthdays = { 31, febdaynum, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--drawin circle indicator lines
for i=1,monthdays[monthnum] do
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx1=0+drad1*(math.sin(arc))
dy1=0-drad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx2=0+drad2*(math.sin(arc))
dy2=0-drad2*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_indicator_color))
daynumsec=(tonumber(os.date('%d'))*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
monthnumsec=(monthdays[monthnum])*24*60*60
drad3=drad2+dtcw
arc=(2*math.pi/360)*((360/monthnumsec)*(daynumsec))
dx1=0+(drad2+linew)*(math.sin(arc))
dy1=0-(drad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))+4)
dx2=0+drad3*(math.sin(arc))
dy2=0-drad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))-4)
dx3=0+drad3*(math.sin(arc))
dy3=0-drad3*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx3,hy0+dy3)
cairo_stroke (cr)
--circlewriting
local jour=conky_parse( '${exec date +%A}' )
text=((string.upper(jour)) .. " LE " .. string.upper(date_to_words()))
--text=((string.upper(os.date('%A'))) .. " LE " .. string.upper(date_to_words()))
start=((360/monthnumsec)*(daynumsec)+dtig)
slen1=string.len(text)
finish=start+(7.5*slen1)
circlewriting(text,dfont,dfsize,drad2+dtbg,hx0,hy0,day_text_color,start,finish)
--end of days around month-------------------------------------------------------------------------------------------------------
--##########################################################################################
--hours around day ---------------------------------------------------------------------------------------------------------------------
hrad1=drad3
hrad2=hrad1+hcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_line_color))
--draw eings
cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
cairo_stroke (cr)
--draw ring indicator lines
for i=1,24 do
arc=((2*math.pi/360)*((360/24)*i))
hx1=0+hrad1*(math.sin(arc))
hy1=0-hrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/24)*i))
hx2=0+hrad2*(math.sin(arc))
hy2=0-hrad2*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_indicator_color))
hrsec=(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
hrad3=hrad2+htcw
arc=((2*math.pi/360)*((360/(24*60*60)*hrsec)))
hx1=0+(hrad2+linew)*(math.sin(arc))
hy1=0-(hrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)-4)
hx2=0+hrad3*(math.sin(arc))
hy2=0-hrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)+4)
hx3=0+hrad3*(math.sin(arc))
hy3=0-hrad3*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx3,hy0+hy3)
cairo_stroke (cr)
--circlewriting
hrnum=tonumber(os.date('%H'))
if hrnum==1 then hour="HEURE"
else hour="HEURES" end
text=((string.upper(number_to_words(hrnum))) .. " " .. hour)
start=((360/(24*60*60))*(hrsec)+htig)
slen4=string.len(text)
finish=start+(slen4*5)
circlewriting(text,hfont,hfsize,hrad2+htbg,hx0,hy0,hour_text_color,start,finish)
--end of hours around day----------------------------------------------------------------------------------------------------
--##########################################################################################
--minutes around hour--------------------------------------------------------------------------------------------------------------
minrad1=hrad3
minrad2=minrad1+mincw
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,minrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,minrad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
mx1=0+minrad1*(math.sin(arc))
my1=0-minrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
mx2=0+minrad2*(math.sin(arc))
my2=0-minrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_indicator_color))
minsec=(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
minrad3=minrad2+mintcw
arc=((2*math.pi/360)*((360/(60*60)*minsec)))
mx1=0+(minrad2+linew)*(math.sin(arc))
my1=0-(minrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)-4)
mx2=0+minrad3*(math.sin(arc))
my2=0-minrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)+4)
mx3=0+minrad3*(math.sin(arc))
my3=0-minrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx3,hy0+my3)
cairo_stroke (cr)
--circlewriting
min=tonumber(os.date('%M'))
if min==1 then minute="MINUTE"
else minute="MINUTES" end
text=((string.upper(number_to_words(min))) .. " " .. minute)
start=((360/(60*60))*(minsec)+mintig)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(text,minfont,minfsize,minrad2+mintbg,hx0,hy0,min_text_color,start,finish)
--end minutes around hour--------------------------------------------------------------------------------------
--##########################################################################################
--seconds of minute-------------------------------------------------------------------------------------------
srad1=minrad3
srad2=srad1+scw
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
sx1=0+srad1*(math.sin(arc))
sy1=0-srad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
sx2=0+srad2*(math.sin(arc))
sy2=0-srad2*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_indicator_color))
sec=(tonumber(os.date('%S')))
srad3=srad2+stcw
arc=((2*math.pi/360)*((360/(60)*sec)))
sx1=0+(srad2+linew)*(math.sin(arc))
sy1=0-(srad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))-4)
sx2=0+srad3*(math.sin(arc))
sy2=0-srad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))+4)
sx3=0+srad3*(math.sin(arc))
sy3=0-srad3*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx3,hy0+sy3)
cairo_stroke (cr)
--outer circle
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
cairo_arc (cr,hx0,hy0,srad3,0,2*math.pi)
cairo_stroke (cr)
--circlewriting
sec=tonumber(os.date('%S'))
if sec==1 then second="SECONDE"
else second="SECONDES" end
text=(string.upper(number_to_words(sec)) .. " " .. second)
start=((360/60)*((sec))+stig)
slen3=string.len(text)
finish=start+(slen3*5)
circlewriting(text,sfont,sfsize,srad2+stbg,hx0,hy0,sec_text_color,start,finish)
--end seconds of minute-----------------------------------------------------------------------------------------------------------------------------
--END OF CALENDAR
--#########################################################################################################
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
---------------------------------------------------------------------------
function circlewriting(text, font, fsize, radi, horiz, verti, text_color, start, finish)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,rgb_to_r_g_b(text_color));
local inum=string.len(text)
deg=(finish-start)/(inum-1)
degrads=(math.pi/180)
local textcut=string.gsub(text, ".", "%1|")
texttable=string.split(textcut, "|")
for i=1,inum do
interval=(degrads*(start+(deg*(i-1))))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval)
end
end--of function
--------------------------------------------------------------------------- 

Hors sujet : perso je n'aime pas trop le rendu de cette horloge, mais les goûts et les couleurs...

Hors ligne

#2170 Le 16/12/2012, à 14:35

Didier-T

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

@ maan,

la méthode donnée par chepioq fonctionne (ajout de ${time %t} après TEXT dans le conky), je connaissais pas, c'est excellent smile

il faudra cependant modifier la ligne n° 147 pour que tous fonctionne correctement
ceci

text({x=mcx,y=mcy-30,t=string.upper(os.date("%b")),hj="c",vj="m"})

devient ceci

text({x=mcx,y=mcy-30,t=string.upper(os.date("%b"):gsub("é", "e"):gsub("û", "u")),hj="c",vj="m"})

Edit : je trouve cette horloge très bien faite, toujours le bazar dans le script lua, mais très jolie rendu.

Dernière modification par Didier-T (Le 16/12/2012, à 14:37)

Hors ligne

#2171 Le 16/12/2012, à 17:02

chepioq

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Didier-T a écrit :

@ maan,

la méthode donnée par chepioq fonctionne (ajout de ${time %t} après TEXT dans le conky), je connaissais pas, c'est excellent smile

J'ai trouvé cela lors que j'ai fait un calendrier en lua, avec l'aide de wlourff (voir http://forum.ubuntu-fr.org/viewtopic.php?id=402081&p=1 , post #7)

Par contre, merci pour l'ajout qui empêche l'affichage du "é", je cherchais comment faire et je ne trouvais pas...


Tout est dans tout et réciproquement....

Hors ligne

#2172 Le 16/12/2012, à 17:26

Didier-T

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

C'est d’ailleurs dommage que wourlf ne participe plus sur la discutions, je suis certain qu'il aurait pleins de choses à nous apprendre.

Mais bon ont apprends de nos erreurs, et c'est très bien ainsi.

Hors ligne

#2173 Le 16/12/2012, à 21:59

maan

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

oui c'est ok c'est simple mais efficace merci chepioq tongue

oui je trouve que ce script lua est un peu perturbant pour moi ............. j'ai quand même réussi à travailler avec par contre là je but .....
L'idée serait d'entourer l'horloge d'un ring qui me fasse défiler les secondes sans faire apparaître d'aiguille (je sais tordu je suis tongue)

Mais je n'y arrive pas, j'ai essayer en faisant appel à un autre script lua paramétrer pour faire des rings mais l’accès échoue,
j'ai essayer de mettre dans le script lua de l'horloge mais sprout "nil value" je pense (mais je n'y connais rien) que se script n'est pas paramétré pour faire des rings !!!
je n'arrive même pas à faire apparaître l'aiguille des secondes car je n'arrive pas a trouver le bon argument à lui donner ......enfin voilà je bricole quoi  lol:lol:

Voilà ou j'en suis

1355691282.png 1355699860.png

et l'idée ça serait dans les ptit rectangle du tour les faires changer de couleur un par un secondes par secondes   tongue

EDIT: j'ai réussi a régler et mettre une aiguille pour les secondes mais c'est tout pas de rings (je me demandes si c'est possible d'ailleur ???)
j'ai rajouté une photos pour illustré

Dernière modification par maan (Le 17/12/2012, à 00:18)


Ubuntu_studio 14.04

Hors ligne

#2174 Le 17/12/2012, à 08:54

Didier-T

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Bonjour maan,

je ne suis pas certain de bien comprendre ce que tu souhaite obtenir, les rectangles sont vides, de plus ils se situe entre deux secondes, donc je suppose que tu nous parle des trais qui représente les minutes.
si c'est le cas avec ceci, sa devrait fonctionner.

comme je ne sais pas en quelle mesure tu as modifié le script d'origine, je me contenterais de donner la section à modifier et pas sa position.

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
seconds=tonumber(os.date("%S"))
cairo_set_line_width(cr,1)
for i=1,60 do
  if seconds==i-1 then
    hexcolor({c=0xccaa7a}) --couleur seconde actuelle
  else
    hexcolor({c=0xccaa7a}) --couleur normal
  end
  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)
  elseif seconds==i-1 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

Dernière modification par Didier-T (Le 17/12/2012, à 08:55)

Hors ligne

#2175 Le 17/12/2012, à 11:24

ragamatrix

Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes

Didier-T a écrit :

@ ragamatrix,

aller un peut de déterrage,

donc le script horloge maya, en français.
avec les modifications que j'avais donné plus haut sa aurai du fonctionner, mais le passage en majuscule ne fonctionne pas a cause des accents, il sont donc neutralisé, pour les mois français.

  --[[mayancalander by mrpeachy . version5.18.11
changes
improved and shortened number_to_words and date_to_words functions
increased number of settings (settings begin on line 65)
call in conkyrc like so
lua_load /path to file/filename.lua
lua_draw_hook_pre draw_fig

note about color and alpha
to set colors use the following format
color={0xFFFFFF,1}
         ^      ^
       color  alpha
]]
require 'cairo'
-------------------------------------------------------------------
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end--of function
-------------------------------------------------------------------
function number_to_words(number)
--by mrpeachy 11-4-2012
number=tonumber(number)
local n_len=string.len(number)
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"un","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","dix sept","dix huit","dix neuf",}
n2_tab={"dix","vingt","trente","quarante","cinquante","soixante","soixante dix","quatre vingt","quatre vingt dix"}
if tu<20 and tu~=10 and number~=0 then 
	nout=n1_tab[tu]
elseif tu==10 then
	nout="dix"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	nout=n2_tab[t]..joinu..u
elseif number==0 then
nout="zero"
end
if number>99 and number~=100 then
	h=n1_tab[h]
	return h.." cent "..nout
elseif number==100 then
	return " cent "
elseif number<100 then
	return nout
end
end--function
---------------------------------------------------------------------
function date_to_words()
date=tonumber(os.date("%d"))
datecut=string.gsub(date, ".", "%1|")
datetable=string.split(datecut, "|")
d1_tab={d1="premier",d2="deux",d3="trois",d4="quatre",d5="cinq",d6="six",d7="sept",d8="huit",d9="neuf",d10="dix",d11="onze",d12="douze",d13="treize",d14="quatorze",d15="quinze",d16="seize",d17="dix sept",d18="dix huit",d19="dix neuf",d20="vingt",d30="trente"}
d2_tab={d2="vingt",d3="trente",}
if tonumber(date)<21 or tonumber(date)==30 then
return (d1_tab[tostring("d" .. date)])
elseif tonumber(date)>20 and tonumber(date)~=30 then
return (d2_tab[tostring("d" .. datetable[1])] .. " " .. d1_tab[tostring("d" .. datetable[2])])
end
end--function
----------------------------------------------------------------------
function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end
----------------------------------------------------------------------
function conky_draw_fig()
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>5 then
--#########################################################################################################
--#########################################################################################################
--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--
--center position
hx0,hy0=200,200
inner_radius=40
--line width
linew=1
--general settings to apply globally, can be altered/overriden for each section below
--line color and alpha
local global_line_color={0xFFFFFF,1}
--font
local font="mono"
--font size
local fsize=10
--text color and alpha
local global_text_color={0xFFFF00,1}
--gap under text
local tbg=3
--gap from indicator to text
local tig=6
--indicator circle width
local cw=10
--text circle width
local tcw=13
--indicator color and alpha
local global_indicator_color={0xFFFFFF,1}
--############################################
--settings for each section of calendar
--############################################
--MONTHS--------------------------------------
--line color and alpha
--eg month_line_color={0xFFFFFF,1}
local month_line_color=global_line_color
--text
local mfont=font
local mfsize=fsize
--text color and alpha
local month_text_color=global_text_color
--gap at bottom of text
local mtbg=tbg
--gap from indicator to text
local mtig=tig
--circle width
local mcw=cw
--text circle width
local mtcw=tcw
--indicator color and alpha
local month_indicator_color=global_indicator_color
--############################################
--DAYS----------------------------------------
--line color and alpha
--eg day_line_color={0xFFFFFF,1}
local day_line_color=global_line_color
--text
local dfont=font
local dfsize=fsize
--text color and alpha
local day_text_color=global_text_color
--gap at bottom of text
local dtbg=tbg
--gap from indicator to text
local dtig=tig
--circle width
local dcw=cw
--text circle width
local dtcw=tcw
--indicator color and alpha
local day_indicator_color=global_indicator_color
--############################################
--HOURS---------------------------------------
--line color and alpha
--eg hour_line_color={0xFFFFFF,1}
local hour_line_color=global_line_color
--text
local hfont=font
local hfsize=fsize
--text color
local hour_text_color=global_text_color
--gap at bottom of text
local htbg=tbg
--gap from indicator to text
local htig=tig
--indicator circle width
local hcw=cw
--text circle width
local htcw=tcw
--indicator color
local hour_indicator_color=global_indicator_color
--############################################
--MINUTES-------------------------------------
--line color and alpha
--eg min_line_color={0xFFFFFF,1}
local min_line_color=global_line_color
--text
local minfont=font
local minfsize=fsize
--text color and alpha
local min_text_color=global_text_color
--gap at bottom of text
local mintbg=tbg
--gap from indicator to text
local mintig=tig
--circle width
local mincw=cw
--text circle width
local mintcw=tcw
--indicator color and alpha
local min_indicator_color=global_indicator_color
--############################################
--SECONDS-------------------------------------
--line color and alpha
--eg sec_line_color={0xFFFFFF,1}
local sec_line_color=global_line_color
--text
local sfont=font
local sfsize=fsize
--text color and alpha
local sec_text_color=global_text_color
--gap at bottom of text
local stbg=tbg
--gap from indicator to text
local stig=tig
--circle width
local scw=cw
--text circle width
local stcw=tcw
--indicator color and alpha
local sec_indicator_color=global_indicator_color
--#################################################
--END OF SETTINGS--END OF SETTINGS--END OF SETTINGS
--#################################################
--months of the year---------------------------------------------------------------------------------------------------
mnrad1=inner_radius
mnrad2=mnrad1+mcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_line_color))
--draw circles
cairo_set_line_width (cr,linew)
cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
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))
yeardays=31+febdaynum+31+30+31+30+31+31+30+31+30+31
yearsec=(yeardays*24*60*60)
jan=31*24*60*60
feb=jan+(febdaynum*24*60*60)
mar=feb+(31*24*60*60)
apr=mar+(30*24*60*60)
may=apr+(31*24*60*60)
jun=may+(30*24*60*60)
jul=jun+(31*24*60*60)
aug=jul+(31*24*60*60)
sep=aug+(30*24*60*60)
oct=sep+(31*24*60*60)
nov=oct+(30*24*60*60)
dec=nov+(31*24*60*60)
secdays = {jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}
--circle indicator lines
for i=1,12 do
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx1=0+mnrad1*(math.sin(arc))
mny1=0-mnrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx2=0+mnrad2*(math.sin(arc))
mny2=0-mnrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
end
--indicator-----------------------------------------------------
cairo_set_source_rgba (cr,rgb_to_r_g_b(month_indicator_color))
doy=tonumber(os.date("%j"))
yrsecs=((doy-1)*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mnrad3=mnrad2+mtcw
arc=(2*math.pi/360)*((360/yearsec)*(yrsecs))
mnx1=0+(mnrad2+linew)*(math.sin(arc))
mny1=0-(mnrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))+4)
mnx2=0+mnrad3*(math.sin(arc))
mny2=0-mnrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))-4)
mnx3=0+mnrad3*(math.sin(arc))
mny3=0-mnrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx3,hy0+mny3)
cairo_stroke (cr)
--circlewriting-------------------------------------------------
--text must be in quotes
local mois=conky_parse( '${exec date +%B}' ):gsub("é", "e"):gsub("û", "u")
text=((string.upper(mois)) .. " DEUX MILLE " .. string.upper(number_to_words(os.date('%y'))))
--text=((string.upper(os.date('%B'))) .. " DEUX MILLE " .. string.upper(number_to_words(os.date('%y'))))
start=((360/yearsec)*((yrsecs))+mtig)
slen2=string.len(text)
finish=start+270
circlewriting(text,mfont,mfsize,mnrad2+mtbg,hx0,hy0,month_text_color,start,finish)
--end of months around year-------------------------------------------------------------------------------------------------------------------------------
--##########################################################################################
--days around month----------------------------------------------------------------------
drad1=mnrad3
drad2=drad1+dcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,drad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,drad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
monthnum=(tonumber(os.date('%m')))
monthdays = { 31, febdaynum, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--drawin circle indicator lines
for i=1,monthdays[monthnum] do
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx1=0+drad1*(math.sin(arc))
dy1=0-drad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx2=0+drad2*(math.sin(arc))
dy2=0-drad2*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(day_indicator_color))
daynumsec=(tonumber(os.date('%d'))*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
monthnumsec=(monthdays[monthnum])*24*60*60
drad3=drad2+dtcw
arc=(2*math.pi/360)*((360/monthnumsec)*(daynumsec))
dx1=0+(drad2+linew)*(math.sin(arc))
dy1=0-(drad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))+4)
dx2=0+drad3*(math.sin(arc))
dy2=0-drad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))-4)
dx3=0+drad3*(math.sin(arc))
dy3=0-drad3*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx3,hy0+dy3)
cairo_stroke (cr)
--circlewriting
local jour=conky_parse( '${exec date +%A}' )
text=((string.upper(jour)) .. " LE " .. string.upper(date_to_words()))
--text=((string.upper(os.date('%A'))) .. " LE " .. string.upper(date_to_words()))
start=((360/monthnumsec)*(daynumsec)+dtig)
slen1=string.len(text)
finish=start+(7.5*slen1)
circlewriting(text,dfont,dfsize,drad2+dtbg,hx0,hy0,day_text_color,start,finish)
--end of days around month-------------------------------------------------------------------------------------------------------
--##########################################################################################
--hours around day ---------------------------------------------------------------------------------------------------------------------
hrad1=drad3
hrad2=hrad1+hcw
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_line_color))
--draw eings
cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
cairo_stroke (cr)
--draw ring indicator lines
for i=1,24 do
arc=((2*math.pi/360)*((360/24)*i))
hx1=0+hrad1*(math.sin(arc))
hy1=0-hrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/24)*i))
hx2=0+hrad2*(math.sin(arc))
hy2=0-hrad2*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(hour_indicator_color))
hrsec=(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
hrad3=hrad2+htcw
arc=((2*math.pi/360)*((360/(24*60*60)*hrsec)))
hx1=0+(hrad2+linew)*(math.sin(arc))
hy1=0-(hrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)-4)
hx2=0+hrad3*(math.sin(arc))
hy2=0-hrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)+4)
hx3=0+hrad3*(math.sin(arc))
hy3=0-hrad3*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx3,hy0+hy3)
cairo_stroke (cr)
--circlewriting
hrnum=tonumber(os.date('%H'))
if hrnum==1 then hour="HEURE"
else hour="HEURES" end
text=((string.upper(number_to_words(hrnum))) .. " " .. hour)
start=((360/(24*60*60))*(hrsec)+htig)
slen4=string.len(text)
finish=start+(slen4*5)
circlewriting(text,hfont,hfsize,hrad2+htbg,hx0,hy0,hour_text_color,start,finish)
--end of hours around day----------------------------------------------------------------------------------------------------
--##########################################################################################
--minutes around hour--------------------------------------------------------------------------------------------------------------
minrad1=hrad3
minrad2=minrad1+mincw
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,minrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,minrad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
mx1=0+minrad1*(math.sin(arc))
my1=0-minrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
mx2=0+minrad2*(math.sin(arc))
my2=0-minrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(min_indicator_color))
minsec=(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
minrad3=minrad2+mintcw
arc=((2*math.pi/360)*((360/(60*60)*minsec)))
mx1=0+(minrad2+linew)*(math.sin(arc))
my1=0-(minrad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)-4)
mx2=0+minrad3*(math.sin(arc))
my2=0-minrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)+4)
mx3=0+minrad3*(math.sin(arc))
my3=0-minrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx3,hy0+my3)
cairo_stroke (cr)
--circlewriting
min=tonumber(os.date('%M'))
if min==1 then minute="MINUTE"
else minute="MINUTES" end
text=((string.upper(number_to_words(min))) .. " " .. minute)
start=((360/(60*60))*(minsec)+mintig)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(text,minfont,minfsize,minrad2+mintbg,hx0,hy0,min_text_color,start,finish)
--end minutes around hour--------------------------------------------------------------------------------------
--##########################################################################################
--seconds of minute-------------------------------------------------------------------------------------------
srad1=minrad3
srad2=srad1+scw
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
--draw circles
cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
sx1=0+srad1*(math.sin(arc))
sy1=0-srad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
sx2=0+srad2*(math.sin(arc))
sy2=0-srad2*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
end
--indicator
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_indicator_color))
sec=(tonumber(os.date('%S')))
srad3=srad2+stcw
arc=((2*math.pi/360)*((360/(60)*sec)))
sx1=0+(srad2+linew)*(math.sin(arc))
sy1=0-(srad2+linew)*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))-4)
sx2=0+srad3*(math.sin(arc))
sy2=0-srad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))+4)
sx3=0+srad3*(math.sin(arc))
sy3=0-srad3*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx3,hy0+sy3)
cairo_stroke (cr)
--outer circle
cairo_set_source_rgba (cr,rgb_to_r_g_b(sec_line_color))
cairo_arc (cr,hx0,hy0,srad3,0,2*math.pi)
cairo_stroke (cr)
--circlewriting
sec=tonumber(os.date('%S'))
if sec==1 then second="SECONDE"
else second="SECONDES" end
text=(string.upper(number_to_words(sec)) .. " " .. second)
start=((360/60)*((sec))+stig)
slen3=string.len(text)
finish=start+(slen3*5)
circlewriting(text,sfont,sfsize,srad2+stbg,hx0,hy0,sec_text_color,start,finish)
--end seconds of minute-----------------------------------------------------------------------------------------------------------------------------
--END OF CALENDAR
--#########################################################################################################
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
---------------------------------------------------------------------------
function circlewriting(text, font, fsize, radi, horiz, verti, text_color, start, finish)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,rgb_to_r_g_b(text_color));
local inum=string.len(text)
deg=(finish-start)/(inum-1)
degrads=(math.pi/180)
local textcut=string.gsub(text, ".", "%1|")
texttable=string.split(textcut, "|")
for i=1,inum do
interval=(degrads*(start+(deg*(i-1))))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval)
end
end--of function
--------------------------------------------------------------------------- 

Hors sujet : perso je n'aime pas trop le rendu de cette horloge, mais les goûts et les couleurs...

Alors un grand merci; je viens de le modifier à la Française en incluant des "istances"rgb car il ne fonctionnait sinon pas avec "draw-bg"
MayanFR_Draw_bg_baro

Hors ligne