Vos Conky
Postez ici vos conkys ou des petits bouts et demandes d'aide.
Discussions Libres

Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
Reprise du message précédent
Pascaller :
Pour obtenir la version de KDE :
${color3}KDE : ${color2} ${execi 1 kde4-config --version | grep KDE | sed -e 's/.*: //'}
Pour obtenir la version de KDE :
${color3}KDE : ${color2} ${execi 1 kde4-config --version | grep KDE | sed -e 's/.*: //'}
Ah oui, plus simple que
Code BASH :
${exec expr `konsole -v | grep KDE | cut -d":" -f2 | sed s/" "/""/`}

Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


Aranud Membre non connecté
-
- Voir le profil du membre Aranud
- Inscrit le : 06/11/2010
- Groupes :
http://forum.pcinpact.com/topic/97542-tuto-conky/
un petit renseignement sur
execi / exec
On dis qu'il utilise pas mal de charge... hors là :
${color3}KDE : ${color2} ${execi 1 kde4-config --version | grep KDE | sed -e 's/.*: //'}
rafraichissement toutes les 1 seconde... pour une version KDE pas besoin...
j'ai donc mis équivalent de 24h...
Mais adrien tu utilises exec expr qu'elle est la différence, tu la connait ? je n'arrive pas à trouver son explication ?
Merci

Édité par Aranud Le 02/11/2013 à 08h06

Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
Parfois l'une ne fonctionne pas, alors j'utilise l'autre

Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


Aranud Membre non connecté
-
- Voir le profil du membre Aranud
- Inscrit le : 06/11/2010
- Groupes :


loutch Membre non connecté
-
- Voir le profil du membre loutch
- Inscrit le : 07/07/2010
- Groupes :
.gif)
Un leger sur le chaudron
le conkyrc:
Caché :
background yes
use_xft yes
xftfont Sans:size=8
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent no
own_window_color 000000
own_window_argb_visual yes
own_window_argb_value 0
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 1000
maximum_width 1000
text_buffer_size 1024
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_outline_color white
alignment top_left
gap_x 360
gap_y 0
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
color white
lua_load ~/.conky/blanc/tous.lua
lua_draw_hook_post main_rings
TEXT
${goto 10}cpu 1 ${goto 80}cpu 2 ${goto 150}cpu3 ${goto 220}cpu4 ${goto 290}ram ${goto 360}swap ${goto 430}/ ${goto 500}/home ${goto 570}/down ${goto 640} /Up ${goto 714}${time %I} h ${goto 784}${time %M} m ${goto 854}${time %S} s
${goto 10}${cpu cpu0}% ${goto 80}${cpu cpu1}% ${goto 150}${cpu cpu2}% ${goto 220}${cpu cpu2}% ${goto 290}$memperc% ${goto 360}$swapperc% ${goto 430}${fs_size /} ${goto 500}${fs_size /home} ${goto 570}${downspeedf wlan0}k/s ${goto 640}${upspeedf wlan0}k/s
${goto 10}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp1_input` / 1000}°C ${goto 80}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp2_input` / 1000}°C ${goto 150}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp3_input` / 1000}°C ${goto 220}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp1_input` / 1000}°C ${goto 430}${fs_used_perc /}% ${goto 500}${fs_used_perc /home}% ${goto 570}${totaldown wlan0} ${goto 640}${totalup wlan0} ${goto 730}${time %A %d %B}
background yes
use_xft yes
xftfont Sans:size=8
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent no
own_window_color 000000
own_window_argb_visual yes
own_window_argb_value 0
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 1000
maximum_width 1000
text_buffer_size 1024
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_outline_color white
alignment top_left
gap_x 360
gap_y 0
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
color white
lua_load ~/.conky/blanc/tous.lua
lua_draw_hook_post main_rings
TEXT
${goto 10}cpu 1 ${goto 80}cpu 2 ${goto 150}cpu3 ${goto 220}cpu4 ${goto 290}ram ${goto 360}swap ${goto 430}/ ${goto 500}/home ${goto 570}/down ${goto 640} /Up ${goto 714}${time %I} h ${goto 784}${time %M} m ${goto 854}${time %S} s
${goto 10}${cpu cpu0}% ${goto 80}${cpu cpu1}% ${goto 150}${cpu cpu2}% ${goto 220}${cpu cpu2}% ${goto 290}$memperc% ${goto 360}$swapperc% ${goto 430}${fs_size /} ${goto 500}${fs_size /home} ${goto 570}${downspeedf wlan0}k/s ${goto 640}${upspeedf wlan0}k/s
${goto 10}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp1_input` / 1000}°C ${goto 80}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp2_input` / 1000}°C ${goto 150}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp3_input` / 1000}°C ${goto 220}${exec expr `cat /sys/class/hwmon/hwmon1/device/temp1_input` / 1000}°C ${goto 430}${fs_used_perc /}% ${goto 500}${fs_used_perc /home}% ${goto 570}${totaldown wlan0} ${goto 640}${totalup wlan0} ${goto 730}${time %A %d %B}
le lua :
Caché :
--[[
Ring Meters by londonali1010 (2009)
This script draws percentage meters as rings. It is fully customisable; all options are described in the script.
IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 145 uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num>5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num>3; conversely if you update Conky every 0.5s, you should use update_num>10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.
To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
lua_load ~/scripts/rings-v1.2.lua
lua_draw_hook_pre ring_stats
Changelog:
+ v1.2 -- Added option for the ending angle of the rings (07.10.2009)
+ v1.1 -- Added options for the starting angle of the rings, and added the "max" variable, to allow for variables that output a numerical value rather than a percentage (29.09.2009)
+ v1.0 -- Original release (28.09.2009)
]]
require 'cairo'
function conky_main_rings()
if (os.date("%l"))=='12' then
heure=(os.date("%M")/60)
else
heure=(os.date("%l"))+(os.date("%M")/60)
end
-- START PARAMETERS HERE
local rings_settings={
{
name="cpu",
arg="cpu0",
max=100,
xc=25,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp1_input` / 1000",
max=100,
xc=25,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="cpu",
arg="cpu1",
max=100,
xc=95,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp2_input` / 1000",
max=100,
xc=95,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="cpu",
arg="cpu2",
max=100,
xc=165,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp3_input` / 1000",
max=100,
xc=165,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="cpu",
arg="cpu3",
max=100,
xc=235,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp2_input` / 1000",
max=100,
xc=235,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="memperc",
arg="",
max=100,
xc=305,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="swapperc",
arg="",
max=100,
xc=375,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="fs_used_perc",
arg="/",
max=100,
xc=445,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="fs_used_perc",
arg="/home",
max=100,
xc=515,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="downspeedf",
arg="wlan0",
max=500,
xc=585,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="upspeedf",
arg="wlan0",
max=100,
xc=655,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="",
arg=heure,
max=11.99,
xc=725,
yc=30,
radius=25,
thickness=2.5,
gap_sectors=0,
sectors=12,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
},
{
name="",
arg=(os.date("%M"))+(os.date("%S")/60),
max=59.99,
xc=795,
yc=30,
radius=25,
thickness=2.5,
gap_sectors=0,
sectors=12,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
},
{
name="time",
arg="%S",
max=60,
xc=865,
yc=30,
radius=25,
thickness=2.5,
gap_sectors=0,
sectors=12,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,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
draw_ring(cr,rings_settings[i])
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]]
--[[
Ring Meters by londonali1010 (2009)
This script draws percentage meters as rings. It is fully customisable; all options are described in the script.
IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 145 uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num>5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num>3; conversely if you update Conky every 0.5s, you should use update_num>10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.
To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
lua_load ~/scripts/rings-v1.2.lua
lua_draw_hook_pre ring_stats
Changelog:
+ v1.2 -- Added option for the ending angle of the rings (07.10.2009)
+ v1.1 -- Added options for the starting angle of the rings, and added the "max" variable, to allow for variables that output a numerical value rather than a percentage (29.09.2009)
+ v1.0 -- Original release (28.09.2009)
]]
require 'cairo'
function conky_main_rings()
if (os.date("%l"))=='12' then
heure=(os.date("%M")/60)
else
heure=(os.date("%l"))+(os.date("%M")/60)
end
-- START PARAMETERS HERE
local rings_settings={
{
name="cpu",
arg="cpu0",
max=100,
xc=25,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp1_input` / 1000",
max=100,
xc=25,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="cpu",
arg="cpu1",
max=100,
xc=95,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp2_input` / 1000",
max=100,
xc=95,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="cpu",
arg="cpu2",
max=100,
xc=165,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp3_input` / 1000",
max=100,
xc=165,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="cpu",
arg="cpu3",
max=100,
xc=235,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="exec",
arg="exec expr `cat /sys/class/hwmon/hwmon1/device/temp2_input` / 1000",
max=100,
xc=235,
yc=30,
radius=20,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="memperc",
arg="",
max=100,
xc=305,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="swapperc",
arg="",
max=100,
xc=375,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="fs_used_perc",
arg="/",
max=100,
xc=445,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="fs_used_perc",
arg="/home",
max=100,
xc=515,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="downspeedf",
arg="wlan0",
max=500,
xc=585,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="upspeedf",
arg="wlan0",
max=100,
xc=655,
yc=30,
radius=25,
thickness=2,
gap_sectors=0,
sectors=10,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
bd_colour1={{0,0XFFffff,1},{0.5,0xFFffff,1}, {1,0xFFffff,1}},
},
{
name="",
arg=heure,
max=11.99,
xc=725,
yc=30,
radius=25,
thickness=2.5,
gap_sectors=0,
sectors=12,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
},
{
name="",
arg=(os.date("%M"))+(os.date("%S")/60),
max=59.99,
xc=795,
yc=30,
radius=25,
thickness=2.5,
gap_sectors=0,
sectors=12,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
},
{
name="time",
arg="%S",
max=60,
xc=865,
yc=30,
radius=25,
thickness=2.5,
gap_sectors=0,
sectors=12,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
fg_colour2={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,1}},
bd_colour1={{0,0Xffffff,1},{0.5,0xffffff,1}, {1,0xffffff,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
draw_ring(cr,rings_settings[i])
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]]
et l'image:

.gif)
Édité par loutch Le 02/11/2013 à 10h21
Linuxmint 24.02 Xia - Mageia 9 xfce et plasma sur ssd sur HP Pavilion g7
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX

Aranud Membre non connecté
-
- Voir le profil du membre Aranud
- Inscrit le : 06/11/2010
- Groupes :
c'est un fake (écriture / photo) ou un terminal réel ?
j'arrive pas à mettre mains dessus :/
ah priori celui là (mais il y en n'a sans bordure, juste le texte) : http://www.zoringroup.com/forum/viewtopic.php?f=6&t=3631
Édité par Aranud Le 02/11/2013 à 19h50

loutch Membre non connecté
-
- Voir le profil du membre loutch
- Inscrit le : 07/07/2010
- Groupes :
Je crois que tu parle de tilda voir ici :
http://ubunnux.wordpress.com/2011/04/20/tilda/
( pas vu dans le CCM sur Mageia 2]
le mien sur elementaryOS avec un sensors

ou un htop

.gif)
Édité par loutch Le 02/11/2013 à 22h22
Linuxmint 24.02 Xia - Mageia 9 xfce et plasma sur ssd sur HP Pavilion g7
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX

Aranud Membre non connecté
-
- Voir le profil du membre Aranud
- Inscrit le : 06/11/2010
- Groupes :

http://asher256.tuxfamily.org/index.php?2006/01/20/30-tilda-le-nouvel-ami-de-mon-bureau
http://sourceforge.net/projects/tilda/files/
Bon je tenterai de me l'installer


gunera Membre non connecté
-
- Voir le profil du membre gunera
- Inscrit le : 02/12/2008
- Groupes :
Louch,Merci pour ton tuto qui m'a permis d'installer un conky sur mes 2 pc (Perso et travail).

J'aime beaucoup le wallpapper avec les continents en couleurs sur le tuto.
Où puis-je le trouver?
S'il est libre bien sur.
![:]](/images/smileys/8.gif)
Merci.

Lotherath Membre non connecté
-
- Voir le profil du membre Lotherath
- Inscrit le : 21/11/2011
- Groupes :
pour Tilda, j'ai récupéré un paquetage Mandriva 2011 (oui , je sais, c'est pas bien

Par contre, il me semble que tilda n'est plus maintenu

Mon PC: tour assemblée maison avec carte mère Asus, dual-core Amd athlon 5500 plus (avec ventirad Zalman pour refroidir la bête), 4 Go de ram, carte graphique MSI GT 630, disque dur 500 Go - 100 % Mageia avec KDE.

loutch Membre non connecté
-
- Voir le profil du membre loutch
- Inscrit le : 07/07/2010
- Groupes :
Citation :
Louch,Merci pour ton tuto qui m'a permis d'installer un conky sur mes 2 pc (Perso et travail).
De rien.
Citation :
J'aime beaucoup le wallpapper avec les continents en couleurs sur le tuto.
Où puis-je le trouver?
S'il est libre bien sur.
Où puis-je le trouver?
S'il est libre bien sur.
Désolé


.gif)
Linuxmint 24.02 Xia - Mageia 9 xfce et plasma sur ssd sur HP Pavilion g7
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX

loutch Membre non connecté
-
- Voir le profil du membre loutch
- Inscrit le : 07/07/2010
- Groupes :
je viens de trouvé l'adresse du wall
http://hqwide.com/multicolor-digital-art-world-map-wallpaper-26856/
Linuxmint 24.02 Xia - Mageia 9 xfce et plasma sur ssd sur HP Pavilion g7
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX
Xubuntu 18.04 LTS et 24.04 en xfce sur ASUS Rog STRIX

gunera Membre non connecté
-
- Voir le profil du membre gunera
- Inscrit le : 02/12/2008
- Groupes :

Aranud Membre non connecté
-
- Voir le profil du membre Aranud
- Inscrit le : 06/11/2010
- Groupes :
Lotherath :
Bonsoir,
pour Tilda, j'ai récupéré un paquetage Mandriva 2011 (oui , je sais, c'est pas bien
).
Par contre, il me semble que tilda n'est plus maintenu
.
pour Tilda, j'ai récupéré un paquetage Mandriva 2011 (oui , je sais, c'est pas bien

Par contre, il me semble que tilda n'est plus maintenu

Et ça fonctionne ?
Car je vois que Rosa 2012 là aussi ainsi que opensuse :
http://pkgs.org/search/?keyword=tilda

Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
Aranud :
Et ça fonctionne ?
Car je vois que Rosa 2012 là aussi ainsi que opensuse :
http://pkgs.org/search/?keyword=tilda
Lotherath :
Bonsoir,
pour Tilda, j'ai récupéré un paquetage Mandriva 2011 (oui , je sais, c'est pas bien
).
Par contre, il me semble que tilda n'est plus maintenu
.
pour Tilda, j'ai récupéré un paquetage Mandriva 2011 (oui , je sais, c'est pas bien

Par contre, il me semble que tilda n'est plus maintenu

Et ça fonctionne ?
Car je vois que Rosa 2012 là aussi ainsi que opensuse :
http://pkgs.org/search/?keyword=tilda
Si vous me laissez un petit temps, il y a peut être moyen qu'il se retrouve dans les dépôts MLO

Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


Aranud Membre non connecté
-
- Voir le profil du membre Aranud
- Inscrit le : 06/11/2010
- Groupes :

Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie