#1526 Le 06/06/2012, à 15:46
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bon comme je suis impatient ^^ j'ai activé le dépot precise-backports
Comme c'était la même version du paquet, j'ai été chercher là, et j'ai installé ça: http://packages.ubuntu.com/fr/precise-backports/conky
Et comme ça fonctionnait toujours pas j'ai pris ça: http://packages.ubuntu.com/quantal/conky-all
Et là ça fonctionne
Je sais c'est bancal comme solution mais au moins plus de problème
Merci pour ton aide !
Dernière modification par n1c0la5 (Le 06/06/2012, à 15:46)
Hors ligne
#1527 Le 06/06/2012, à 16:01
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
voila le résultat final avec ces réglages merci à vous deux
---------------------- PARAMETERS BEGIN HERE
local boxes_settings={
{x=0,y=50,w=200,h=57, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=195,w=200,h=57, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=320,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=410,w=200,h=83, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=529,w=200,h=25, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
}
---------------------------- PARAMETERS END HERE
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne
#1528 Le 06/06/2012, à 16:25
- enebre
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Pour le script conky3 ConkyRamCpu2,
Ca ne fonctionne pas correctement chez moi, j'ai donc adapté la correction en ceci :
Le passage wifi en eth0 s’effectue sans problème, le conky se réaligne automatiquement avec les nouvelles infos Net.
TEXT
${voffset 1}${offset 12}${font Ubuntu:pixelsize=16}${color FF7A2A}HD ${offset 9}${color aaaaaa}${fs_free /} / ${fs_size /}${offset 15}${color FF7A2A}RAM ${offset 9}${color aaaaaa}$mem / $memmax${offset 15}${color FF7A2A}CPU ${offset 9}${color aaaaaa}${cpu cpu0}%${offset 15}${color FF7A2A}GHZ ${offset 9}${color aaaaaa}${freq_g}${offset 15} ${color FF7A2A}${if_existing /proc/net/route eth0}eth0 ${color aaaaaa}${addr eth0} ${color FF7A2A}Down: ${color aaaaaa}${downspeed eth0} ${color FF7A2A}Up: ${color aaaaaa}${upspeed eth0}
${color FF7A2A}${else}${if_existing /proc/net/route wlan0}wifi ${color aaaaaa}${addr wlan0} ${color FF7A2A}AP: ${color aaaaaa}${wireless_essid wlan0} ${color FF7A2A}Speed: ${color aaaaaa}${wireless_bitrate wlan0} ${color FF7A2A}Mode: ${color aaaaaa}${wireless_mode wlan0} ${color FF7A2A}Quality:${color aaaaaa} ${wireless_link_qual_perc wlan0}% ${color FF7A2A}Down:${color aaaaaa}${downspeed wlan0} ${color FF7A2A}Up:${color aaaaaa}${upspeed wlan0} ${else} "Network Unavailable"
Et tout est sur une ligne dans la transparence du tableau de bord supérieur, tombe juste dans l'espace libre
Cliquez sur la miniature pour agrandir
le conkyRamCpu2 en plein écran :
ljere, j'aimerais beaucoup recevoir, si tu veux bien, le conkyrc de ton conky de droite s'il te plait.
Dernière modification par enebre (Le 06/06/2012, à 16:54)
Hors ligne
#1529 Le 06/06/2012, à 16:38
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
aucun souci c'est conkycore soit le conky 20 pour le lua j'ai rien modifié pour le conkyrc c'est:
# Conky settings #
background no
update_interval 1
own_window_argb_visual yes
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
#imlib_cache_size 0
temperature_unit fahrenheit
# Window specifications #
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
minimum_size 200 250
maximum_width 200
alignment tr
gap_x 35
gap_y 55
# Graphics settings #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# Text settings #
use_xft yes
xftfont caviar dreams:size=8
xftalpha 0.5
uppercase no
temperature_unit celsius
default_color FFFFFF
# Lua Load #
lua_load ~/.conky/conky20/clock_rings.lua
lua_draw_hook_pre clock_rings
TEXT
${voffset 8}${color FF6600}${font caviar dreams:size=16}${time %A}${font}${voffset -8}${alignr 50}${color FFFFFF}${font caviar dreams:size=38}${time %e}${font}
${color FFFFFF}${voffset -30}${color FFFFFF}${font caviar dreams:size=18}${time %b}${font}${voffset -3} ${color FFFFFF}${font caviar dreams:size=20}${time %Y}${font}${color FF6600}${hr}
${voffset 140}${font caviar dreams:size=10}${alignr}HOME${font}
${font caviar dreams:size=12}${color FFFFFF}${alignr}${weather http://weather.noaa.gov/pub/data/observations/metar/stations/ LQBK temperature temperature 30} °C${font}
${image ~/.conky/conky20/new-ubuntu-logo.png -p 64,125 -s 70x20}
${color FFFFFF}${goto 25}${voffset 35}${cpu cpu0}%
${color FF6600}${goto 25}CPU
${color FFFFFF}${goto 50}${voffset 23}${memperc}%
${color FF6600}${goto 50}RAM
${color FFFFFF}${goto 75}${voffset 23}${swapperc}%
${color FF6600}${goto 75}Swap
${color FFFFFF}${goto 100}${voffset 23}${fs_used_perc /}%
${color FF6600}${goto 100}Disk
${color FFFFFF}${goto 125}${voffset 25}${downspeed eth0}
${color FFFFFF}${goto 125}${upspeed eth0}
${color FF6600}${goto 125}Net
${color FFFFFF}${font caviar dreams:size=8}Uptime: ${uptime_short}
${color FFFFFF}${font caviar dreams:size=8}Processes: ${processes}
${color FFFFFF}${font caviar dreams:size=8}Running: ${running_processes}
${color FF6600}${font caviar dreams:size=8}${alignr}${nodename}
${color FF6600}${font caviar dreams:size=8}${alignr}${pre_exec cat /etc/issue.net} $machine
${color FF6600}${font caviar dreams:size=8}${alignr}Kernel: ${kernel}
je suppose que vous avez compris qu'il me sert pour monitorer mon serveur
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne
#1530 Le 06/06/2012, à 16:41
- enebre
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Ce serait pas le rc du conky de gauche ??
C'est que j'aime beaucoup les couleurs des barres d'infos, dans le conky à droite sur l'image
Oups c'est bon, j'avais pas vu que tu venais juste de le poster plus haut.
Merci les gars, voici ce que j'obtiens après légères modifications de dimensionnements et de fond, couleurs etc.
écran 1920x1080. L'ancien et le nouveau conky Le conky_8.lua et conky 19rc disponibles.
L'un travaillant avec l'autre. Le conky19rc utilise le lua du conky_8.lua pour les barres colorées. Donc faire bien attention à l'adressage de chaque élément, pour qu'ils se trouvent correctement. j'ai rajouté aussi le Calendrier, Clémentine et UpTime.
Pour l'ancien conky tout bete ici le fichier
Dernière modification par enebre (Le 06/06/2012, à 23:14)
Hors ligne
#1531 Le 06/06/2012, à 16:50
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
celui de droite il est ici
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne
#1532 Le 06/06/2012, à 16:54
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
bonjour j'ai donc commenté
# own_window_argb_visual yes
ce qui donne ce résultat
http://www.zimagez.com/miniature/capturedcran-06062012-153916.php
si j'ai bien compris je dois donc jouer avec le tableau pour avoir quelque chose de correct
c'est bien sa
Hors ligne
#1533 Le 07/06/2012, à 00:52
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
@ Didier-T
Un tres grand merci à toi pour avoir modifié le lua, je testerai cela demain, et j' etudierai tes modifications pour comprendre comment cela fonctionne.
Je suis un peu entre 2 chaises pour le moment, je fais un tuto sur un HP dl380 g5 et vmware esxi, xen.
Je reviendrai surement avec des questions sur les lua ^^, car j' ai fini le music player interactif dans conky, pour audacious, mais j' ai encore 2-3 choses à regarder, comme rajouter le bitrate et comprendre pourquoi les boutons ne changent pas de couleur quand on clic dessus, ou seulement une fois sur 20.
@ljere
dans le lua tu peux effacer si tu veux: operator="atop"
par exemple
{x=0,y=529,w=200,h=25, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
devient
{x=0,y=529,w=200,h=25, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} } } ,
atop ne sert à rien dans ce cas ci, c' etait un test de ma part et j ai oublié de le retirer, il sert quand par exemple 2 fenetres cairo transparantes, de couleur differente se chevauche, pour donner un effet, la 1ere fenetre est affichée, la 2 eme n' est affichée que sur la partie qui chevauche la 1ere.
CAIRO_OPERATOR_ATOP
This leaves the first object mostly intact, but mixes both objects in the overlapping area. The second object object is not drawn except there.
If you look closely, you will notice that the resulting color in the overlapping area is different from what the OVER operator produces. Any two operators produce different output in the overlapping area!
The output of the ATOP operator is the same for both bounded and unbounded source.
Resulting alpha (aR) Resulting color (xR)
aB xaA + xB·(1−aA)
http://cairographics.org/operators/
@ enebre
pour donner un effet "italique" aux barres j' ai rajouté:
cap="e"
dans le lua
si tu retires cela, tu redresses les barres, au cas ou tu en aurais envie.
Et aussi:
fg_colour={0x00ff00,1}, (couleur de depart)
mid_colour={{0.5,0xffff00,1}} (couleur intermediaire)
alarm_colour={0xff0000,1}, (couleur de fin)
alarm=80, (quand la couleur de fin apparait en %)
smooth=true, (pour faire une transition "douce" entre les 3 couleurs)
pour les couleurs c' est en hexadecimal, tu trouve la valeur hexa avec gimp ou sur un site web de ce genre: http://www.colorschemer.com/online.html
à et derniere petite chose, par exemple:
fg_colour={0x00ff00,1},
le 1 en rouge c' est la valeur alpha (la transparence) de 0 a 1 0 totalement transparent, 1 totalement opaque.
exemple: fg_colour={0x00ff00,0.4},
Dernière modification par caymus (Le 07/06/2012, à 01:41)
Hors ligne
#1534 Le 07/06/2012, à 06:52
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
merci c'est parfait
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne
#1535 Le 07/06/2012, à 09:52
- rpj
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Tu peut aussi faire des dégradés (dans un cercle ou un graph par ex):
bg_colour1={{0,0xa8cdcc,1}},
fg_colour1={{0,0xd58484,0.7},{0.5,0xd58484,0.5},{1,0xfff667,0.7}}, --[[ couleur mesure min--]]
fg_colour2={{0,0xe36704,0.7},{0.5,0xe36704,1.0},{1,0xfff667,0.7}}, --[[couleur mesure max--]]
},
La ligne de commande UNIX devrait être obligatoire dès la maternelle ! :-)
Debian, XFCE, FF, .
Android dev (éternel débutant)
Hors ligne
#1536 Le 07/06/2012, à 10:11
- enebre
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Merci - caymus - rpj - ljere - Didier - ça me fait bien progresser dans l'apprentissage de l'adaptation de lua
Dernière modification par enebre (Le 07/06/2012, à 10:42)
Hors ligne
#1537 Le 07/06/2012, à 17:18
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
@ Didier
C' est bien cette partie la que tu as ajouter?
if bars_settings[i].exist==nil then bars_settings[i].exist="" end
if bars_settings[i].exist~="" then
if conky_parse(bars_settings[i].exist)==Ok then
draw_multi_bar_graph(bars_settings[i])
end
Oubien j' ai loupé d' autres modification du code plus loin dans le script?
En tout cas un grand merci à toi,
PS: si je devais faire la meme chose pour le script "box" que j ai copié dans le meme lua en dessous du 1er script "rings", cela serait la meme methode à appliquer?
Je me doute que oui, mais dans le doute je prefere te demander
local boxes_settings=
donnerait pour la 2eme partie:
if boxes_settings[i].exist==nil then boxes_settings[i].exist="" end
if boxes_settings[i].exist~="" then
if conky_parse(boxes_settings[i].exist)==Ok then
draw_box(boxes_settings[i])
end
ici dedans?
if tonumber(conky_parse("$updates"))<5 then return end
for i in pairs(boxes_settings) do
draw_box (cr,boxes_settings[i])
Autre question, car je suis nul en progr, le Ok devra etre changer par ok dans le 2eme script pour eviter les conflits oubien cela ne posera pas de problems?
Dernière modification par caymus (Le 07/06/2012, à 17:19)
Hors ligne
#1538 Le 07/06/2012, à 17:56
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bonjour caymus,
Il faut faire attention a deux choses :
la première dans lua tous texte non entouré de " est considéré comme une variable.
la seconde comme dans conky tous test doit avoir une fin donc autant de end que de if.
Sinon j'ai l’impression que tu a bien compris les modifications apporté au script (n'oublie pas d'ajouté exist dans le tableau boxes_settings et de fermer chaque ligne par une virgule)
Pour le "Ok" sa n'a pas d'importance, car il s'agit du résultat du test effectué par conky.
Dernière modification par Didier-T (Le 07/06/2012, à 21:19)
Hors ligne
#1539 Le 07/06/2012, à 20:54
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Encore une fois meric à toi Didier-T, pour ta disponibilitée et tes conseils avisés.
Quand j aurai fini la modification du 2eme script, je mettrai à jour les conky sur gnome-look.
Sans toi, il ne m' aurait pas ete possible de faire cela dans le lua, car j' etais vraiment loin de la bonne solution.
Hors ligne
#1540 Le 07/06/2012, à 21:19
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Encore une fois meric à toi Didier-T, pour ta disponibilitée et tes conseils avisés.
Quand j aurai fini la modification du 2eme script, je mettrai à jour les conky sur gnome-look.
Sans toi, il ne m' aurait pas ete possible de faire cela dans le lua, car j' etais vraiment loin de la bonne solution.
Comme je dis souvent, parfois un regard extérieur apporte la solution
Hors ligne
#1541 Le 08/06/2012, à 15:23
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Re Didier,
C' est encore moi, excuse moi de te déranger j ai un truc qui me chiffone, je voudrais tes conseils eclairés la dessus:
box:
function conky_main_box()
if conky_window==nil then return end
---------------------- PARAMETERS BEGIN HERE
local boxes_settings={
--FIRST COLUMN
--default colour and corner
}
---------------------------- PARAMETERS END HERE
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse("$updates"))<5 then return end
for i in pairs(boxes_settings) do
if boxes_settings[i].exist==nil then boxes_settings[i].exist="" end
if boxes_settings[i].exist~="" then
if conky_parse(boxes_settings[i].exist)=="Ok" then
draw_box(boxes_settings[i])
end
else
draw_box (cr,boxes_settings[i])
end
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
Pourquoi ici je dois mettre 2 end en dessous de draw_box si non j' ai une erreur nil
alors que ici:
rings:
if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display,
conky_window.drawable,
conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
if rings_settings[i].exist==nil then rings_settings[i].exist="" end
if rings_settings[i].exist~="" then
if conky_parse(rings_settings[i].exist)=="Ok" then
draw_ring(rings_settings[i])
end
else
draw_ring(cr,rings_settings[i])
end
end
end
cairo_destroy(cr)
end
Je dois en mettre 3 en dessous de draw_ring
J arrive pas à compter
Hors ligne
#1542 Le 08/06/2012, à 16:49
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
@ caymus,
Pour rendre ton code plus lisible et éviter les erreurs, je te propose de faire ceci.
quand tu commence une boucle ou un test tous ce que tu met a l'intérieur tu y ajoute une tabulation.
Par Exemple :
if "test"
if "test2"
action si Ok
else
action si pas Ok
end
else
action si pas Ok
end
Comme sa ton code te parle visuellement
Hors ligne
#1543 Le 08/06/2012, à 17:51
- enebre
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
http://blacknegative.com/ +-la 7ème page "SANOFI" Si ce style de page pouvait être adaptée dans lua en mode dynamique ce serait waouh !
les rings suivent la souris, c'est ouf ça !
Dès que ça bouge, ça évolue... donc pourvu que ça puisse bouger. Car alors viendra la révolution du système. "et le Tube !" Nous sommes sur une wave içi, ça surf et ça roxxe. Je ne sais pas pour vous mais pour moi rien que de participer à votre forum, je la sent qui monte... la vague. Ceux qui ont fait du surf, body-surf, voile, vole-à-voile, savent bien ce que je veux dire. Il me semble que l'avenir de la commande-interface-homme-machine passera par cette voie. Car le clic de l'icône ne me semble pas assez élaboré pour rejoindre la nécessaire complexité de l'interface, capable de satisfaire longtemps les besoins de l'esprit humain, dans sa relation avec cette machine... qui mérite mieux que le clic et l'icône. Et comme l'écran semble s'orienter pour être un support transparent... Nous sommes ici au delà de l'icône et du clic, ou comment dire .. déjà ..+.. à l'intérieur de la machine. Un peu plus avancé sur l'onde. Non j'ai rien fumé, la moquette est intacte.
Dernière modification par enebre (Le 09/06/2012, à 23:27)
Hors ligne
#1544 Le 08/06/2012, à 21:21
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
@ caymus,
Bonsoir je suis sur mon PC, et peut donc prendre un peut plus de temps pour répondre à ta question.
Voici tes bout de code une fois toute la mise en page refaite.
box:
function conky_main_box()
if conky_window==nil then return end
---------------------- PARAMETERS BEGIN HERE
local boxes_settings={
--FIRST COLUMN
--default colour and corner
}
---------------------------- PARAMETERS END HERE
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse("$updates"))<5 then return end
for i in pairs(boxes_settings) do
if boxes_settings[i].exist==nil then boxes_settings[i].exist="" end
if boxes_settings[i].exist~="" then
if conky_parse(boxes_settings[i].exist)=="Ok" then
draw_box(boxes_settings[i])
end
else
draw_box (cr,boxes_settings[i])
end
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
rings:
if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display,
conky_window.drawable,
conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse('${updates}'))>3 then -- Après trois cycles conky faire
for i in pairs(rings_settings) do -- Boucle lecture variable
if rings_settings[i].exist==nil then rings_settings[i].exist="" end
if rings_settings[i].exist~="" then -- Si il y a un test l'effectuer
if conky_parse(rings_settings[i].exist)=="Ok" then -- Test retourne Ok alors
draw_ring(rings_settings[i])
end -- Fin Test retourne Ok
else
draw_ring(cr,rings_settings[i])
end -- Fin Si il y a un test l'effectuer
end -- Fin Boucle lecture variable
end -- Fin Après trois cycles conky faire
cairo_destroy(cr)
end
comme tu peut le constater c'est bien plus simple comme sa pour voir a qui appartient le end
J'ai commenté tous le second script pour plus de lisibilité
Dernière modification par Didier-T (Le 08/06/2012, à 21:26)
Hors ligne
#1545 Le 08/06/2012, à 21:35
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Merci infiniment Didier-T, c' est vraiment sympa de ta part. Je n' etais pas loin d' avoir le meme resultat que toi en ayant suivis tes conseils du post precedent à part que j avais utilisé la touche tab et que cela fesait de plus grands ecarts ce qui etait moins joli
Je vais prendre l' habitude d' utiliser la touche espace et aligner cela plus harmonieusement.
Encore milles merci pour ton aide.
Hors ligne
#1546 Le 08/06/2012, à 21:39
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Merci infiniment Didier-T, c' est vraiment sympa de ta part.
Je n' etais pas loin d' avoir le meme resultat que toi en ayant suivis tes conseils du post precedent à part que j avais utilisé la touche tab et que cela fesait de plus grands ecarts ce qui etait moins joli
Je vais prendre l' habitude d' utiliser la touche espace et aligner cela plus harmonieusement.
Encore milles merci pour ton aide.
En fait j'utilise la touche Tab mais le forum met des espace à la place, si tu utilise gedit tu peut définir la taille de tes tabulations dans Édition / Préférences (onglet Éditeur)
Hors ligne
#1547 Le 08/06/2012, à 22:30
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Merci beaucoup, tu viens de m apprendre encore une chose, je savais pas qu on pouvait regler la taille de la tabulation dans gedit.
Hors ligne
#1548 Le 09/06/2012, à 15:05
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Re Didier-T,
Le script marche tres bien pour les "Bars" script, J' ai pas encore essayé pour les "Boxs" script, et pour les "Rings" script je bute sur une erreur:
--[[ RINGS with SECTORS widget
v1.1 by wlourf (07 Jan. 2011)
edited by Caymus
add new function by Didier-T
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display,
for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable,
for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach,
for example for {$cpu cpu0}, just write max=100
Optional parameters:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
v1.0 (08 Aug. 2010) original release
v1.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"
text is parsed inside the function, not in the array of settings
v1.2 (09 Jun. 2012) Add exist parameter, tanks to "Didier-T"
-- 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 version 3 (GPLv3)
--
-- 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 Street, Fifth Floor, Boston,
-- MA 02110-1301, USA.
]]
require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
local rings_settings={
{
name="cpu",
arg="cpu1",
exist="",
max=100,
xc=60,
yc=100,
thickness=10,
radius=60,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="cpu",
arg="cpu2",
exist="",
max=100,
xc=60,
yc=100,
thickness=10,
radius=60,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="memperc",
arg="",
exist="",
max=100,
xc=200,
yc=100,
thickness=10,
radius=60,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="swapperc",
arg="",
exist="",
max=100,
xc=200,
yc=100,
thickness=10,
radius=60,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="fs_used_perc",
arg="/home",
exist="",
max=100,
xc=200,
yc=240,
thickness=10,
radius=60,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="fs_used_perc",
arg="/",
exist="",
max=100,
xc=200,
yc=240,
thickness=10,
radius=60,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="downspeedf",
arg="eth0",
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",
max=100,
xc=230,
yc=375,
thickness=5,
radius=30,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="upspeedf",
arg="eth0",
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",
max=100,
xc=230,
yc=375,
thickness=5,
radius=30,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="downspeedf",
arg="wlan0",
exist="${if_existing /proc/net/route eth0}Nil${else}${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}${endif}",
max=100,
xc=230,
yc=450,
thickness=5,
radius=30,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="upspeedf",
arg="wlan0",
exist="${if_existing /proc/net/route eth0}Nil${else}${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}${endif}",
max=100,
xc=230,
yc=450,
thickness=5,
radius=30,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
}
--END OF PARAMETERS HERE
--main function
if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
if rings_settings[i].exist==nil then rings_settings[i].exist="" end
if rings_settings[i].exist~="" then
if conky_parse(rings_settings[i].exist)=="Ok" then
draw_ring(rings_settings[i])
end
else
draw_ring(cr,rings_settings[i])
end
end
end
cairo_destroy(cr)
end
function draw_ring(cr, t)
local function rgba_to_r_g_b_a(tcolour)
local colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name'" +
" with 'arg' or only parameter 'arg' ")
return
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
--initialize table
setup(t)
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
local angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
local valueA = t.max/t.sectors
--first angle of a sector :
local lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
local tcolor
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
local b0,b1
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c, angle_d
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
local d0,d1
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
require 'cairo'
function conky_main_box()
if conky_window==nil then return end
---------------------- PARAMETERS BEGIN HERE
local boxes_settings={
--FIRST COLUMN
--default colour and corner
}
---------------------------- PARAMETERS END HERE
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse("$updates"))<5 then return end
for i in pairs(boxes_settings) do
if boxes_settings[i].exist==nil then boxes_settings[i].exist="" end
if boxes_settings[i].exist~="" then
if conky_parse(boxes_settings[i].exist)=="Ok" then
draw_box(boxes_settings[i])
end
else
draw_box (cr,boxes_settings[i])
end
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
function draw_box(cr,t)
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
local table_corners={"circle","curve","line"}
local t_operators={
clear = CAIRO_OPERATOR_CLEAR,
source = CAIRO_OPERATOR_SOURCE,
over = CAIRO_OPERATOR_OVER,
["in"] = CAIRO_OPERATOR_IN,
out = CAIRO_OPERATOR_OUT,
atop = CAIRO_OPERATOR_ATOP,
dest = CAIRO_OPERATOR_DEST,
dest_over = CAIRO_OPERATOR_DEST_OVER,
dest_in = CAIRO_OPERATOR_DEST_IN,
dest_out = CAIRO_OPERATOR_DEST_OUT,
dest_atop = CAIRO_OPERATOR_DEST_ATOP,
xor = CAIRO_OPERATOR_XOR,
add = CAIRO_OPERATOR_ADD,
saturate = CAIRO_OPERATOR_SATURATE,
}
function rgba_to_r_g_b_a(tc)
--tc={position,colour,alpha}
local colour = tc[2]
local alpha = tc[3]
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function table.copy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = {v[1],v[2]}
end
return t2
end
function draw_corner(num,t)
local shape=t[1]
local radius=t[2]
local x,y = t[3],t[4]
if shape=="line" then
if num == 1 then cairo_line_to(cr,radius,0)
elseif num == 2 then cairo_line_to(cr,x,radius)
elseif num == 3 then cairo_line_to(cr,x-radius,y)
elseif num == 4 then cairo_line_to(cr,0,y-radius)
end
end
if shape=="circle" then
local PI = math.pi
if num == 1 then cairo_arc(cr,radius,radius,radius,-PI,-PI/2)
elseif num == 2 then cairo_arc(cr,x-radius,y+radius,radius,-PI/2,0)
elseif num == 3 then cairo_arc(cr,x-radius,y-radius,radius,0,PI/2)
elseif num == 4 then cairo_arc(cr,radius,y-radius,radius,PI/2,-PI)
end
end
if shape=="curve" then
if num == 1 then cairo_curve_to(cr,0,radius ,0,0 ,radius,0)
elseif num == 2 then cairo_curve_to(cr,x-radius,0, x,y, x,radius)
elseif num == 3 then cairo_curve_to(cr,x,y-radius, x,y, x-radius,y)
elseif num == 4 then cairo_curve_to(cr,radius,y, x,y, 0,y-radius)
end
end
end
--check values and set default values
if t.x == nil then t.x = 0 end
if t.y == nil then t.y = 0 end
if t.w == nil then t.w = conky_window.width end
if t.h == nil then t.h = conky_window.height end
if t.radius == nil then t.radius = 0 end
if t.border == nil then t.border = 0 end
if t.colour==nil then t.colour={{1,0xFFFFFF,0.5}} end
if t.linear_gradient ~= nil then
if #t.linear_gradient ~= 4 then
t.linear_gradient = {t.x,t.y,t.width,t.height}
end
end
if t.angle==nil then t.angle = 0 end
if t.skew_x == nil then t.skew_x=0 end
if t.skew_y == nil then t.skew_y=0 end
if t.scale_x==nil then t.scale_x=1 end
if t.scale_y==nil then t.scale_y=1 end
if t.rot_x == nil then t.rot_x=0 end
if t.rot_y == nil then t.rot_y=0 end
if t.operator == nil then t.operator = "over" end
if (t_operators[t.operator]) == nil then
print ("wrong operator :",t.operator)
t.operator = "over"
end
if t.radial_gradient ~= nil then
if #t.radial_gradient ~= 6 then
t.radial_gradient = {t.x,t.y,0, t.x,t.y, t.width}
end
end
for i=1, #t.colour do
if #t.colour[i]~=3 then
print ("error in color table")
t.colour[i]={1,0xFFFFFF,1}
end
end
if t.corners == nil then t.corners={ {"line",0} } end
local t_corners = {}
local t_corners = table.copy(t.corners)
--don't use t_corners=t.corners otherwise t.corners is altered
--complete the t_corners table if needed
for i=#t_corners+1,4 do
t_corners[i]=t_corners[#t_corners]
local flag=false
for j,v in pairs(table_corners) do flag=flag or (t_corners[i][1]==v) end
if not flag then print ("error in corners table :",t_corners[i][1]);t_corners[i][1]="curve" end
end
--this way :
-- t_corners[1][4]=x
-- t_corners[2][3]=y
--doesn't work
t_corners[1]={t_corners[1][1],t_corners[1][2],0,0}
t_corners[2]={t_corners[2][1],t_corners[2][2],t.w,0}
t_corners[3]={t_corners[3][1],t_corners[3][2],t.w,t.h}
t_corners[4]={t_corners[4][1],t_corners[4][2],0,t.h}
t.no_gradient = (t.linear_gradient == nil ) and (t.radial_gradient == nil )
cairo_save(cr)
cairo_translate(cr, t.x, t.y)
if t.rot_x~=0 or t.rot_y~=0 or t.angle~=0 then
cairo_translate(cr,t.rot_x,t.rot_y)
cairo_rotate(cr,t.angle*math.pi/180)
cairo_translate(cr,-t.rot_x,-t.rot_y)
end
if t.scale_x~=1 or t.scale_y~=1 or t.skew_x~=0 or t.skew_y~=0 then
local matrix0 = cairo_matrix_t:create()
tolua.takeownership(matrix0)
cairo_matrix_init (matrix0, t.scale_x,math.pi*t.skew_y/180 , math.pi*t.skew_x/180 ,t.scale_y,0,0)
cairo_transform(cr,matrix0)
end
local tc=t_corners
cairo_move_to(cr,tc[1][2],0)
cairo_line_to(cr,t.w-tc[2][2],0)
draw_corner(2,tc[2])
cairo_line_to(cr,t.w,t.h-tc[3][2])
draw_corner(3,tc[3])
cairo_line_to(cr,tc[4][2],t.h)
draw_corner(4,tc[4])
cairo_line_to(cr,0,tc[1][2])
draw_corner(1,tc[1])
if t.no_gradient then
cairo_set_source_rgba(cr,rgba_to_r_g_b_a(t.colour[1]))
else
if t.linear_gradient ~= nil then
pat = cairo_pattern_create_linear (t.linear_gradient[1],t.linear_gradient[2],t.linear_gradient[3],t.linear_gradient[4])
elseif t.radial_gradient ~= nil then
pat = cairo_pattern_create_radial (t.radial_gradient[1],t.radial_gradient[2],t.radial_gradient[3],
t.radial_gradient[4],t.radial_gradient[5],t.radial_gradient[6])
end
for i=1, #t.colour do
cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgba_to_r_g_b_a(t.colour[i]))
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
cairo_set_operator(cr,t_operators[t.operator])
if t.border>0 then
cairo_close_path(cr)
if t.dash ~= nil then cairo_set_dash(cr, t.dash, 1, 0.0) end
cairo_set_line_width(cr,t.border)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
llua_do_call: function conky_main_rings execution failed: /home/user/.conky/conky_8a.lua:434: attempt to index local 't' (a nil value)
ligne 434:if t.draw_me == true then t.draw_me = nil end
ligne 435:if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
Je ne vois pas trop quoi faire non plus sur ce coup la.
PS:J ai mis ton pseudo dans les scripts car c' est toi qui as tout fait pour finir , si cela ne te dérange pas bien sur? Si non je le retirai.
Dernière modification par caymus (Le 09/06/2012, à 15:08)
Hors ligne
#1549 Le 09/06/2012, à 22:19
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
@ caymus,
Ton soucis vient de la ligne n°284, il manque la variable cr à ton appelle à draw_ring
Voici la ligne corrigée
draw_ring(cr,rings_settings[i])
Pour la présence de mon pseudo, pas de soucis sa ne me dérange pas.
Par contre ce serait intéressant d'indiquer le nom du forum.
Hors ligne
#1550 Le 11/06/2012, à 17:10
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
@ caymus,
si sa t'intéresse, j'ai modifié le conkyrc_8c (celui qui me plaisait le plus, dans ta collection).
Voici les scripts
conkyrc_8c
#==============================================================================
# conkyrc_8c
#
# author : CAYMUS
# version : v20120420-11
# license : Distributed under the terms of GNU GPL version 2 or later
#
#==============================================================================
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius
double_buffer yes
no_buffers yes
text_buffer_size 2048
gap_x 10
gap_y 60
minimum_size 320 0
#maximum_width 190
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment br
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
override_utf8_locale yes
use_xft yes
xftfont 6x10:size=8
xftalpha 0.5
uppercase no
default_color 666666
color1 888888
color2 AAAAAA
color3 DDDDDD
color4 CC3333
lua_load ~/.conky/conky25/conky_8c.lua
lua_draw_hook_pre main_box
lua_draw_hook_post main_rings
TEXT
${goto 65}${font 6x10:size=12,weight:bold}${color #F09000}$sysname ${font 6x10:size=7,weight:bold}${color}$kernel on $machine
${voffset 10}
${goto 60}${font 6x10:size=12,weight:bold}${color3}CPU
${goto 45}${font 6x10:size=7,weight:normal}${color2}core 1:${goto 90}${cpu cpu1}%
${goto 45}core 2:${goto 90}${cpu cpu2}%
${goto 45}${threads} process
${voffset -95}
${goto 218}${font 6x10:size=12,weight:bold}${color3}MEM
${goto 205}${font 6x10:size=7,weight:normal}${color2}RAM ${goto 240}$mem
${goto 205}SWAP ${goto 240}$swap
${voffset 82}
${goto 210}${font 6x10:size=12,weight:bold}${color3}DISKS
${goto 205}${font 6x10:size=7,weight:normal}${color2}/home${goto 245}${fs_used /home}
${goto 205}/${goto 245}${fs_used /}
${voffset -90}
${goto 5}${color3}TOP CPU
${goto 5}${color2}${top name 1}${goto 90}${top pid 1}${goto 125}${top cpu 1}%
${goto 5}${color}${top name 2}${goto 90}${top pid 2}${goto 125}${top cpu 2}%
${goto 5}${top name 3}${goto 90}${top pid 3}${goto 125}${top cpu 3}%
${goto 5}${color3}TOP MEM
${goto 5}${font 6x10:size=7,weight:normal}${color2}${top_mem name 1}${goto 90}${top_mem pid 1}${goto 125}${top_mem mem 1}%
${goto 5}${color}${top_mem name 2}${goto 90}${top_mem pid 2}${goto 125}${top_mem mem 2}%
${goto 5}${top_mem name 3}${goto 90}${top_mem pid 3}${goto 125}${top_mem mem 3}%
${if_existing /proc/net/route eth0}
${voffset 0}
${goto 5}${font 6x10:size=12,weight:bold}${color3}NET
${goto 5}${color1}${font 6x10:size=7,weight:bold}eth0 ${addr eth0}
${goto 5}${color}${font 6x10:size=7,weight:normal}Down: ${downspeed eth0}
${goto 5}Up: ${upspeed eth0}
${goto 5}Total Down: ${totaldown eth0}
${goto 5}Total Up: ${totalup eth0}
${endif}
${if_existing /proc/net/route wlan0}${goto 5}${color1}${font 6x10:size=7,weight:bold}wifi ${addr wlan0}
${goto 5}${color}${font 6x10:size=7,weight:normal}Down: ${downspeed wlan0}
${goto 5}Up: ${upspeed wlan0}
${goto 5}Total Down: ${totaldown wlan0}
${goto 5}Total Up: ${totalup wlan0}
${goto 5}AP: ${wireless_essid wlan0} ${goto 125}Speed: ${wireless_bitrate wlan0}
${goto 5}Mode: ${wireless_mode wlan0} ${goto 125}Quality: ${wireless_link_qual_perc wlan0}%
${endif}
${if_existing /proc/net/route wlan0}${goto 5}${font 6x10:size=7,weight:bold}${color}open ports: ${tcp_portmon 1 65535 count}
${goto 5}${offset 10}URL${goto 270}PORT
${goto 5}${font 6x10:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 0} ${goto 270} ${tcp_portmon 1 65535 rport 0}
${goto 5}${tcp_portmon 1 65535 rhost 1} ${goto 270} ${tcp_portmon 1 65535 rport 1}
${goto 5}${tcp_portmon 1 65535 rhost 2} ${goto 270} ${tcp_portmon 1 65535 rport 2}
${goto 5}${tcp_portmon 1 65535 rhost 3} ${goto 270} ${tcp_portmon 1 65535 rport 3}
${goto 5}${tcp_portmon 1 65535 rhost 4} ${goto 270} ${tcp_portmon 1 65535 rport 4}
${goto 5}${tcp_portmon 1 65535 rhost 5} ${goto 270} ${tcp_portmon 1 65535 rport 5}
${goto 5}${tcp_portmon 1 65535 rhost 6} ${goto 270} ${tcp_portmon 1 65535 rport 6}
${goto 5}${tcp_portmon 1 65535 rhost 7} ${goto 270} ${tcp_portmon 1 65535 rport 7}
${goto 5}${tcp_portmon 1 65535 rhost 8} ${goto 270} ${tcp_portmon 1 65535 rport 8}
${goto 5}${tcp_portmon 1 65535 rhost 9} ${goto 270} ${tcp_portmon 1 65535 rport 9}
${else}${if_existing /proc/net/route eth0}${goto 5}${font 6x10:size=7,weight:bold}${color}open ports: ${tcp_portmon 1 65535 count}
${goto 5}${offset 10}URL${goto 270}PORT
${goto 5}${font 6x10:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 0} ${goto 270} ${tcp_portmon 1 65535 rport 0}
${goto 5}${tcp_portmon 1 65535 rhost 1} ${goto 270} ${tcp_portmon 1 65535 rport 1}
${goto 5}${tcp_portmon 1 65535 rhost 2} ${goto 270} ${tcp_portmon 1 65535 rport 2}
${goto 5}${tcp_portmon 1 65535 rhost 3} ${goto 270} ${tcp_portmon 1 65535 rport 3}
${goto 5}${tcp_portmon 1 65535 rhost 4} ${goto 270} ${tcp_portmon 1 65535 rport 4}
${goto 5}${tcp_portmon 1 65535 rhost 5} ${goto 270} ${tcp_portmon 1 65535 rport 5}
${goto 5}${tcp_portmon 1 65535 rhost 6} ${goto 270} ${tcp_portmon 1 65535 rport 6}
${goto 5}${tcp_portmon 1 65535 rhost 7} ${goto 270} ${tcp_portmon 1 65535 rport 7}
${goto 5}${tcp_portmon 1 65535 rhost 8} ${goto 270} ${tcp_portmon 1 65535 rport 8}
${goto 5}${tcp_portmon 1 65535 rhost 9} ${goto 270} ${tcp_portmon 1 65535 rport 9}
${endif}${endif}
le conky_8c.lua
--[[ RINGS with SECTORS widget
v1.1 by wlourf (07 Jan. 2011)
edited by Caymus
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display,
for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable,
for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach,
for example for {$cpu cpu0}, just write max=100
Optional parameters:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
v1.0 (08 Aug. 2010) original release
v1.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"
text is parsed inside the function, not in the array of settings
-- 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 version 3 (GPLv3)
--
-- 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 Street, Fifth Floor, Boston,
-- MA 02110-1301, USA.
]]
require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
local rings_settings={
{
name="cpu",
arg="cpu1",
exist="",
max=100,
xc=80,
yc=100,
thickness=10,
radius=60,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="cpu",
arg="cpu2",
exist="",
max=100,
xc=80,
yc=100,
thickness=10,
radius=60,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="memperc",
arg="",
exist="",
max=100,
xc=240,
yc=100,
thickness=10,
radius=60,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="swapperc",
arg="",
exist="",
max=100,
xc=240,
yc=100,
thickness=10,
radius=60,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="fs_used_perc",
arg="/home",
exist="",
max=100,
xc=240,
yc=260,
thickness=10,
radius=60,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="fs_used_perc",
arg="/",
exist="",
max=100,
xc=240,
yc=260,
thickness=10,
radius=60,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="downspeedf",
arg="eth0",
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",
max=100,
xc=270,
yc=395,
thickness=5,
radius=30,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="upspeedf",
arg="eth0",
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",
max=100,
xc=270,
yc=395,
thickness=5,
radius=30,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="downspeedf",
arg="wlan0",
exist="${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}",
max=100,
xc=270,
yc=470,
thickness=5,
radius=30,
start_angle=5,
end_angle=175,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
{
name="upspeedf",
arg="wlan0",
exist="${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}",
max=100,
xc=270,
yc=470,
thickness=5,
radius=30,
start_angle=185,
end_angle=355,
sectors=20,
bg_colour1={{0,0xFFFFFF,0.1},{0.5,0xFFFFFF,0.4},{1,0xFFFFFF,0.1}},
fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1.0},{1,0x00FF00,0.1}},
fg_colour2={{0,0xFF0000,0.1},{0.5,0xFF0000,1.0},{1,0xFF0000,0.1}},
},
}
--END OF PARAMETERS HERE
--main function
if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display,
conky_window.drawable,
conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
if rings_settings[i].exist==nil then rings_settings[i].exist="" end
if rings_settings[i].exist~="" then
if conky_parse(rings_settings[i].exist)=="Ok" then
draw_ring(cr,rings_settings[i])
end
else
draw_ring(cr,rings_settings[i])
end
end
end
cairo_destroy(cr)
end
function draw_ring(cr, t)
local function rgba_to_r_g_b_a(tcolour)
local colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name'" +
" with 'arg' or only parameter 'arg' ")
return
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
--initialize table
setup(t)
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
local angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
local valueA = t.max/t.sectors
--first angle of a sector :
local lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
local tcolor
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
local b0,b1
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c, angle_d
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
local d0,d1
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
require 'cairo'
function conky_main_box()
if conky_window==nil then return end
---------------------- PARAMETERS BEGIN HERE
local boxes_settings={
--FIRST COLUMN
--default colour and corner
{x=0, y=0, w=320, h=700,
exist="${if_existing /proc/net/route eth0}${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}${else}Nil${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {0,0,0,0},
corners={ {"circle",20}} },
{x=0, y=0, w=320, h=600,
exist="${if_existing /proc/net/route eth0}${if_existing /proc/net/route wlan0}Nil${else}Ok${endif}${else}Nil${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {0,0,0,0},
corners={ {"circle",20}} },
{x=0, y=0, w=320, h=600,
exist="${if_existing /proc/net/route wlan0}${if_existing /proc/net/route eth0}Nil${else}Ok${endif}${else}Nil${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {0,0,0,0},
corners={ {"circle",20}} },
{x=0, y=0, w=320, h=350,
exist="${if_existing /proc/net/route wlan0}Nil${else}${if_existing /proc/net/route eth0}Nil${else}Ok${endif}${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {0,0,0,0},
corners={ {"circle",20}} },
{x=10, y=30, w=140, h=140,
exist="",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {140,140,10,10} ,
corners={ {"circle",70} }, },
{x=20, y=40, w=120, h=120,
exist="",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {20,20,120,120} ,
corners={ {"circle",60} }, },
{x=170, y=30, w=140, h=140,
exist="",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {140,140,10,10} ,
corners={ {"circle",70} }, },
{x=180, y=40, w=120, h=120,
exist="",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {20,20,120,120} ,
corners={ {"circle",60} }, },
{x=170, y=190, w=140, h=140,
exist="",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {140,140,10,10} ,
corners={ {"circle",70} }, },
{x=180, y=200, w=120, h=120,
exist="",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {20,20,120,120} ,
corners={ {"circle",60} }, },
{x=235, y=360, w=70, h=70,
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {70,70,10,10} ,
corners={ {"circle",35} }, },
{x=240, y=365, w=60, h=60,
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {20,20,60,60} ,
corners={ {"circle",30} }, },
{x=235, y=435, w=70, h=70,
exist="${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {70,70,10,10} ,
corners={ {"circle",35} }, },
{x=240, y=440, w=60, h=60,
exist="${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}",
colour={{0,0x858585,0.5}, {1,0x000000,0.5}}, linear_gradient= {20,20,60,60} ,
corners={ {"circle",30} }, },
}
---------------------------- PARAMETERS END HERE
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse("$updates"))<5 then return end
for i in pairs(boxes_settings) do
if boxes_settings[i].exist==nil then boxes_settings[i].exist="" end
if boxes_settings[i].exist~="" then
if conky_parse(boxes_settings[i].exist)=="Ok" then
draw_box(cr,boxes_settings[i])
end
else
draw_box (cr,boxes_settings[i])
end
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
function draw_box(cr,t)
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
local table_corners={"circle","curve","line"}
local t_operators={
clear = CAIRO_OPERATOR_CLEAR,
source = CAIRO_OPERATOR_SOURCE,
over = CAIRO_OPERATOR_OVER,
["in"] = CAIRO_OPERATOR_IN,
out = CAIRO_OPERATOR_OUT,
atop = CAIRO_OPERATOR_ATOP,
dest = CAIRO_OPERATOR_DEST,
dest_over = CAIRO_OPERATOR_DEST_OVER,
dest_in = CAIRO_OPERATOR_DEST_IN,
dest_out = CAIRO_OPERATOR_DEST_OUT,
dest_atop = CAIRO_OPERATOR_DEST_ATOP,
xor = CAIRO_OPERATOR_XOR,
add = CAIRO_OPERATOR_ADD,
saturate = CAIRO_OPERATOR_SATURATE,
}
function rgba_to_r_g_b_a(tc)
--tc={position,colour,alpha}
local colour = tc[2]
local alpha = tc[3]
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function table.copy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = {v[1],v[2]}
end
return t2
end
function draw_corner(num,t)
local shape=t[1]
local radius=t[2]
local x,y = t[3],t[4]
if shape=="line" then
if num == 1 then cairo_line_to(cr,radius,0)
elseif num == 2 then cairo_line_to(cr,x,radius)
elseif num == 3 then cairo_line_to(cr,x-radius,y)
elseif num == 4 then cairo_line_to(cr,0,y-radius)
end
end
if shape=="circle" then
local PI = math.pi
if num == 1 then cairo_arc(cr,radius,radius,radius,-PI,-PI/2)
elseif num == 2 then cairo_arc(cr,x-radius,y+radius,radius,-PI/2,0)
elseif num == 3 then cairo_arc(cr,x-radius,y-radius,radius,0,PI/2)
elseif num == 4 then cairo_arc(cr,radius,y-radius,radius,PI/2,-PI)
end
end
if shape=="curve" then
if num == 1 then cairo_curve_to(cr,0,radius ,0,0 ,radius,0)
elseif num == 2 then cairo_curve_to(cr,x-radius,0, x,y, x,radius)
elseif num == 3 then cairo_curve_to(cr,x,y-radius, x,y, x-radius,y)
elseif num == 4 then cairo_curve_to(cr,radius,y, x,y, 0,y-radius)
end
end
end
--check values and set default values
if t.x == nil then t.x = 0 end
if t.y == nil then t.y = 0 end
if t.w == nil then t.w = conky_window.width end
if t.h == nil then t.h = conky_window.height end
if t.radius == nil then t.radius = 0 end
if t.border == nil then t.border = 0 end
if t.colour==nil then t.colour={{1,0xFFFFFF,0.5}} end
if t.linear_gradient ~= nil then
if #t.linear_gradient ~= 4 then
t.linear_gradient = {t.x,t.y,t.width,t.height}
end
end
if t.angle==nil then t.angle = 0 end
if t.skew_x == nil then t.skew_x=0 end
if t.skew_y == nil then t.skew_y=0 end
if t.scale_x==nil then t.scale_x=1 end
if t.scale_y==nil then t.scale_y=1 end
if t.rot_x == nil then t.rot_x=0 end
if t.rot_y == nil then t.rot_y=0 end
if t.operator == nil then t.operator = "over" end
if (t_operators[t.operator]) == nil then
print ("wrong operator :",t.operator)
t.operator = "over"
end
if t.radial_gradient ~= nil then
if #t.radial_gradient ~= 6 then
t.radial_gradient = {t.x,t.y,0, t.x,t.y, t.width}
end
end
for i=1, #t.colour do
if #t.colour[i]~=3 then
print ("error in color table")
t.colour[i]={1,0xFFFFFF,1}
end
end
if t.corners == nil then t.corners={ {"line",0} } end
local t_corners = {}
local t_corners = table.copy(t.corners)
--don't use t_corners=t.corners otherwise t.corners is altered
--complete the t_corners table if needed
for i=#t_corners+1,4 do
t_corners[i]=t_corners[#t_corners]
local flag=false
for j,v in pairs(table_corners) do flag=flag or (t_corners[i][1]==v) end
if not flag then print ("error in corners table :",t_corners[i][1]);t_corners[i][1]="curve" end
end
--this way :
-- t_corners[1][4]=x
-- t_corners[2][3]=y
--doesn't work
t_corners[1]={t_corners[1][1],t_corners[1][2],0,0}
t_corners[2]={t_corners[2][1],t_corners[2][2],t.w,0}
t_corners[3]={t_corners[3][1],t_corners[3][2],t.w,t.h}
t_corners[4]={t_corners[4][1],t_corners[4][2],0,t.h}
t.no_gradient = (t.linear_gradient == nil ) and (t.radial_gradient == nil )
cairo_save(cr)
cairo_translate(cr, t.x, t.y)
if t.rot_x~=0 or t.rot_y~=0 or t.angle~=0 then
cairo_translate(cr,t.rot_x,t.rot_y)
cairo_rotate(cr,t.angle*math.pi/180)
cairo_translate(cr,-t.rot_x,-t.rot_y)
end
if t.scale_x~=1 or t.scale_y~=1 or t.skew_x~=0 or t.skew_y~=0 then
local matrix0 = cairo_matrix_t:create()
tolua.takeownership(matrix0)
cairo_matrix_init (matrix0, t.scale_x,math.pi*t.skew_y/180 , math.pi*t.skew_x/180 ,t.scale_y,0,0)
cairo_transform(cr,matrix0)
end
local tc=t_corners
cairo_move_to(cr,tc[1][2],0)
cairo_line_to(cr,t.w-tc[2][2],0)
draw_corner(2,tc[2])
cairo_line_to(cr,t.w,t.h-tc[3][2])
draw_corner(3,tc[3])
cairo_line_to(cr,tc[4][2],t.h)
draw_corner(4,tc[4])
cairo_line_to(cr,0,tc[1][2])
draw_corner(1,tc[1])
if t.no_gradient then
cairo_set_source_rgba(cr,rgba_to_r_g_b_a(t.colour[1]))
else
if t.linear_gradient ~= nil then
pat = cairo_pattern_create_linear (t.linear_gradient[1],t.linear_gradient[2],t.linear_gradient[3],t.linear_gradient[4])
elseif t.radial_gradient ~= nil then
pat = cairo_pattern_create_radial (t.radial_gradient[1],t.radial_gradient[2],t.radial_gradient[3],
t.radial_gradient[4],t.radial_gradient[5],t.radial_gradient[6])
end
for i=1, #t.colour do
cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgba_to_r_g_b_a(t.colour[i]))
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
cairo_set_operator(cr,t_operators[t.operator])
if t.border>0 then
cairo_close_path(cr)
if t.dash ~= nil then cairo_set_dash(cr, t.dash, 1, 0.0) end
cairo_set_line_width(cr,t.border)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
Une petite vidéo pour illustrer, bien sure comme je ne dispose pas de connexion wifi elle n'aparait pas.
Hors ligne