Didier-T a écrit@ Phyllinux,
tu pourrais mettre les script en entier, avec une vue global ce serait plus simple.
mais à priori.
les 11 paquets de lignes de code commençant par name='eval', servent a tracer les cercles et les points qui ne bougent pas.
Je ne suis pas sure de ce que j'avance, sa dépens du reste du code.
En tous cas le rendu est sympa 🙂
Voici les scripts dans leur intégralité :
clock_rings.lua
--[[
Clock Rings by londonali1010 (2009)
This script draws percentage meters as rings, and also draws clock hands if you want! It is fully customisable; all options are described in the script. This script is based off a combination of my clock.lua script and my rings.lua 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 near the end of the script 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/clock_rings-v1.1.1.lua
lua_draw_hook_pre clock_rings
Changelog:
+ v1.1.1 -- Fixed minor bug that caused the script to crash if conky_parse() returns a nil value (20.10.2009)
+ v1.1 -- Added colour option for clock hands (07.10.2009)
+ v1.0 -- Original release (30.09.2009)
]]
settings_table = {
{
-- Edit this table to customise your rings.
-- You can create more rings simply by adding more elements to settings_table.
-- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
name='time',
-- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
arg='%I.%M',
-- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
max=12,
-- "bg_colour" is the colour of the base ring.
bg_colour=0xFFFFFF,
-- "bg_alpha" is the alpha value of the base ring.
bg_alpha=0.1,
-- "fg_colour" is the colour of the indicator part of the ring.
fg_colour=0xFFFFFF,
-- "fg_alpha" is the alpha value of the indicator part of the ring.
fg_alpha=0.5,
-- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
x=150, y=150,
-- "radius" is the radius of the ring.
radius=135,
-- "thickness" is the thickness of the ring, centred around the radius.
thickness=4,
-- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
start_angle=0,
-- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
end_angle=360
},
{
name='time',
arg='%M.%S',
max=60,
bg_colour=0xFFFFFF,
bg_alpha=0.1,
fg_colour=0x00FF00,
fg_alpha=0.3,
x=150, y=150,
radius=140,
thickness=4,
start_angle=0,
end_angle=360
},
{
name='time',
arg='%S',
max=60,
bg_colour=0xFFFFFF,
bg_alpha=0.1,
fg_colour=0x00FF00,
fg_alpha=0.5,
x=150, y=150,
radius=145,
thickness=4,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0x000000,
bg_alpha=0.1,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=150,
radius=66,
thickness=130,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0xFFFFFF,
bg_alpha=1.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=150,
radius=1,
thickness=10,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0xFFFFFF,
bg_alpha=1.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=85, y=150,
radius=30,
thickness=1,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0x000000,
bg_alpha=0.3,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=85, y=150,
radius=15,
thickness=27,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0xFFFFFF,
bg_alpha=1.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=85, y=150,
radius=1,
thickness=2,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0xFFFFFF,
bg_alpha=1.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=215, y=150,
radius=30,
thickness=1,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0x000000,
bg_alpha=0.3,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=215, y=150,
radius=15,
thickness=27,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0xFFFFFF,
bg_alpha=1.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=215, y=150,
radius=1,
thickness=2,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0xFFFFFF,
bg_alpha=1.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=75,
radius=25,
thickness=1,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0x000000,
bg_alpha=0.3,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=75,
radius=13,
thickness=22,
start_angle=0,
end_angle=360
},
{
name='eval',
arg='1',
max=1,
bg_colour=0xFFFFFF,
bg_alpha=1.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=75,
radius=1,
thickness=2,
start_angle=0,
end_angle=360
},
}
-- Use these settings to define the origin and extent of your clock.
clock_r=127
-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.
clock_x=150
clock_y=150
-- Colour & alpha of the clock hands
clock_colour=0x556B2F
clock_alpha=1
-- Do you want to show the seconds hand?
show_seconds=true
require 'cairo'
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function draw_ring(cr,t,pt)
local w,h=conky_window.width,conky_window.height
local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
local angle_0=sa*(2*math.pi/360)-math.pi/2
local angle_f=ea*(2*math.pi/360)-math.pi/2
local t_arc=t*(angle_f-angle_0)
-- Draw background ring
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
cairo_set_line_width(cr,ring_w)
cairo_stroke(cr)
-- Draw indicator ring
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
cairo_stroke(cr)
end
function draw_clock_hands(cr,xc,yc)
local secs,mins,hours,secs_arc,mins_arc,hours_arc
local xh,yh,xm,ym,xs,ys
secs=os.date("%S")
mins=os.date("%M")
hours=os.date("%I")
secs_arc=(2*math.pi/60)*secs
mins_arc=(2*math.pi/60)*mins+secs_arc/60
hours_arc=(2*math.pi/12)*hours+mins_arc/12
-- Draw hour hand
xh=xc+0.7*clock_r*math.sin(hours_arc)
yh=yc-0.7*clock_r*math.cos(hours_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xh,yh)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr,5)
cairo_set_source_rgba(cr,rgb_to_r_g_b(clock_colour,clock_alpha))
cairo_stroke(cr)
-- Draw minute hand
xm=xc+clock_r*math.sin(mins_arc)
ym=yc-clock_r*math.cos(mins_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xm,ym)
cairo_set_line_width(cr,3)
cairo_stroke(cr)
-- Draw seconds hand
if show_seconds then
xs=xc+clock_r*math.sin(secs_arc)
ys=yc-clock_r*math.cos(secs_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xs,ys)
cairo_set_line_width(cr,1)
cairo_stroke(cr)
end
end
function conky_clock_rings()
local function setup_rings(cr,pt)
local str=''
local value=0
str=string.format('${%s %s}',pt['name'],pt['arg'])
str=conky_parse(str)
value=tonumber(str)
if value == nil then value = 0 end
pct=value/pt['max']
draw_ring(cr,pct,pt)
end
-- Check that Conky has been running for at least 5s
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)
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num>5 then
for i in pairs(settings_table) do
setup_rings(cr,settings_table[i])
end
end
draw_clock_hands(cr,clock_x,clock_y)
end
multi-rings.lua
--==============================================================================
-- multi_rings.lua
--
-- author : SLK
-- version : v2011011601
-- license : Distributed under the terms of GNU GPL version 2 or later
--
--==============================================================================
require 'cairo'
--------------------------------------------------------------------------------
-- clock DATA
-- HOURS
clock_h = {
{
name='time', arg='%H', max_value=12,
x=150, y=150,
graph_radius=140,
graph_thickness=3,
graph_unit_angle=30, graph_unit_thickness=5,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
txt_radius=100,
txt_weight=1, txt_size=10.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=125,
graduation_thickness=10, graduation_mark_thickness=2,
graduation_unit_angle=30,
graduation_fg_colour=0x00FF00, graduation_fg_alpha=0.5,
},
}
-- MINUTES
clock_m = {
{
name='time', arg='%M', max_value=60,
x=150, y=150,
graph_radius=100,
graph_thickness=3,
graph_unit_angle=6, graph_unit_thickness=3,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
txt_radius=100,
txt_weight=0, txt_size=9.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=57,
graduation_thickness=0, graduation_mark_thickness=2,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
},
}
-- SECONDS
clock_s = {
{
name='time', arg='%S', max_value=60,
x=150, y=150,
graph_radius=50,
graph_thickness=3,
graph_unit_angle=6, graph_unit_thickness=3,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
txt_radius=100,
txt_weight=0, txt_size=12.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=0,
graduation_thickness=0, graduation_mark_thickness=0,
graduation_unit_angle=0,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
},
}
--------------------------------------------------------------------------------
-- gauge DATA
gauge = {
{
name='cpu', arg='cpu0', max_value=100,
x=85, y=150,
graph_radius=14,
graph_thickness=27,
graph_start_angle=0,
graph_unit_angle=3.5, graph_unit_thickness=3.0,
graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
hand_fg_colour=0x00CFB3, hand_fg_alpha=1.0,
txt_radius=1,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=27,
graduation_thickness=4, graduation_mark_thickness=4,
graduation_unit_angle=30,
graduation_fg_colour=0x00FF00, graduation_fg_alpha=1.0,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
},
{
name='memperc', arg='', max_value=100,
x=215, y=150,
graph_radius=14,
graph_thickness=27,
graph_start_angle=0,
graph_unit_angle=3.5, graph_unit_thickness=3.0,
graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
hand_fg_colour=0x00CFB3, hand_fg_alpha=1.0,
txt_radius=1,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=27,
graduation_thickness=4, graduation_mark_thickness=4,
graduation_unit_angle=30,
graduation_fg_colour=0x00FF00, graduation_fg_alpha=1.0,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
},
{
name='fs_used_perc', arg='/', max_value=100,
x=150, y=75,
graph_radius=10,
graph_thickness=23,
graph_start_angle=0,
graph_unit_angle=3.5, graph_unit_thickness=3.0,
graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
hand_fg_colour=0x00CFB3, hand_fg_alpha=1.0,
txt_radius=1,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=22,
graduation_thickness=4, graduation_mark_thickness=4,
graduation_unit_angle=30,
graduation_fg_colour=0x00FF00, graduation_fg_alpha=1.0,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
},
}
-------------------------------------------------------------------------------
-- rgb_to_r_g_b
-- converts color in hexa to decimal
--
function rgb_to_r_g_b(colour, alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
-------------------------------------------------------------------------------
-- angle_to_position
-- convert degree to rad and rotate (0 degree is top/north)
--
function angle_to_position(start_angle, current_angle)
local pos = current_angle + start_angle
return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end
-------------------------------------------------------------------------------
-- draw_clock_ring
-- displays clock
--
function draw_clock_ring(display, data, value)
local max_value = data['max_value']
local x, y = data['x'], data['y']
local graph_radius = data['graph_radius']
local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
local graph_unit_angle = data['graph_unit_angle']
local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
-- background ring
cairo_arc(display, x, y, graph_radius, 0, 2 * math.pi)
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
cairo_set_line_width(display, graph_thickness)
cairo_stroke(display)
-- arc of value
local val = (value % max_value)
local i = 1
while i <= val do
cairo_arc(display, x, y, graph_radius,( ((graph_unit_angle * i) - graph_unit_thickness)*(2*math.pi/360) )-(math.pi/2),((graph_unit_angle * i) * (2*math.pi/360))-(math.pi/2))
cairo_set_source_rgba(display,rgb_to_r_g_b(graph_fg_colour,graph_fg_alpha))
cairo_stroke(display)
i = i + 1
end
local angle = (graph_unit_angle * i) - graph_unit_thickness
-- graduations marks
local graduation_radius = data['graduation_radius']
local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
local graduation_unit_angle = data['graduation_unit_angle']
local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
local nb_graduation = 360 / graduation_unit_angle
local i = 1
while i <= nb_graduation do
cairo_set_line_width(display, graduation_thickness)
cairo_arc(display, x, y, graduation_radius, (((graduation_unit_angle * i)-(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2),(((graduation_unit_angle * i)+(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2))
cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
cairo_stroke(display)
cairo_set_line_width(display, graph_thickness)
i = i + 1
end
end
-- text
local txt_radius = data['txt_radius']
local txt_weight, txt_size = data['txt_weight'], data['txt_size']
local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
local movex = txt_radius * (math.cos((angle * 2 * math.pi / 360)-(math.pi/2)))
local movey = txt_radius * (math.sin((angle * 2 * math.pi / 360)-(math.pi/2)))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight);
cairo_set_font_size (display, txt_size);
cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha));
cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3);
cairo_show_text (display, value);
cairo_stroke (display);
end
-------------------------------------------------------------------------------
-- draw_gauge_ring
-- displays gauges
--
function draw_gauge_ring(display, data, value)
local max_value = data['max_value']
local x, y = data['x'], data['y']
local graph_radius = data['graph_radius']
local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
local graph_start_angle = data['graph_start_angle']
local graph_unit_angle = data['graph_unit_angle']
local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
local graph_end_angle = (max_value * graph_unit_angle) % 360
-- background ring
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
cairo_set_line_width(display, graph_thickness)
cairo_stroke(display)
-- arc of value
local val = value % (max_value + 1)
local start_arc = 0
local stop_arc = 0
local i = 1
while i <= val do
start_arc = (graph_unit_angle * i) - graph_unit_thickness
stop_arc = (graph_unit_angle * i)
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
cairo_stroke(display)
i = i + 1
end
local angle = start_arc
-- hand
start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2)
stop_arc = (graph_unit_angle * val)
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
cairo_stroke(display)
-- graduations marks
local graduation_radius = data['graduation_radius']
local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
local graduation_unit_angle = data['graduation_unit_angle']
local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
local nb_graduation = graph_end_angle / graduation_unit_angle
local i = 0
while i < nb_graduation do
cairo_set_line_width(display, graduation_thickness)
start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
cairo_stroke(display)
cairo_set_line_width(display, graph_thickness)
i = i + 1
end
end
-- text
local txt_radius = data['txt_radius']
local txt_weight, txt_size = data['txt_weight'], data['txt_size']
local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight)
cairo_set_font_size (display, txt_size)
cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
cairo_show_text (display, value)
cairo_stroke (display)
-- caption
local caption = data['caption']
local caption_weight, caption_size = data['caption_weight'], data['caption_size']
local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight);
cairo_set_font_size (display, caption_size)
cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
cairo_move_to (display, x + tox + 5, y + toy + 1)
-- bad hack but not enough time !
if graph_start_angle < 105 then
cairo_move_to (display, x + tox - 30, y + toy + 1)
end
cairo_show_text (display, caption)
cairo_stroke (display)
end
-------------------------------------------------------------------------------
-- go_clock_rings
-- loads data and displays clock
--
function go_clock_rings(display)
local function load_clock_rings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
value = tonumber(str)
draw_clock_ring(display, data, value)
end
for i in pairs(clock_h) do
load_clock_rings(display, clock_h[i])
end
for i in pairs(clock_m) do
load_clock_rings(display, clock_m[i])
end
for i in pairs(clock_s) do
load_clock_rings(display, clock_s[i])
end
end
-------------------------------------------------------------------------------
-- go_gauge_rings
-- loads data and displays gauges
--
function go_gauge_rings(display)
local function load_gauge_rings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
value = tonumber(str)
draw_gauge_ring(display, data, value)
end
for i in pairs(gauge) do
load_gauge_rings(display, gauge[i])
end
end
-------------------------------------------------------------------------------
-- MAIN
function conky_main()
if conky_window == nil then
return
end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local display = cairo_create(cs)
local updates = conky_parse('${updates}')
update_num = tonumber(updates)
if update_num > 5 then
go_clock_rings(display)
go_gauge_rings(display)
end
end
Un petit script qui fait clignoter les 3 LED bleues
blinkingLED
${image ~/conky/weather+clock/images/Blank.png -p 129, 241 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image ~/conky/weather+clock/images/Blue.png -p 129, 241 -s 40x40}${endif}
${image ~/conky/weather+clock/images/Blank.png -p 19, 129 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image ~/conky/weather+clock/images/Blue.png -p 19, 129 -s 40x40}${endif}
${image ~/conky/weather+clock/images/Blank.png -p 240, 129 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image ~/conky/weather+clock/images/Blue.png -p 240, 129 -s 40x40}${endif}
Et, pour ceux que cela intéresse, le conkyrc qui va avec :
# — Conky settings — #
background yes
update_interval 1
total_run_times 0
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
imlib_cache_size 0
temperature_unit celcius
# — Window specifications — #
#own_window_class Conky
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
border_inner_margin 0
border_outer_margin 0
minimum_size 300 300
maximum_width 300
alignment top_left
gap_x 80
gap_y 75
# — Graphics settings — #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# — Text settings — #
use_xft yes
xftfont hooge 05_53:size=6
xftalpha 0.5
default_color FFFFFF
uppercase no
use_spacer right
color0 white
color1 orange
color2 green
color3 yellow
# -- Declaration template -- #
template1 ${lua Meteo_\1 \2 \3 \4 \5 \6} # -- gestion météo --#
template2 ${lua_parse Meteo_\1 \2 \3 \4 60 \5} # -- icones météo -- \2=repertoir icones \3=position \4=taille \5=jour (pour les prévisions) #
# — Lua Load — #
lua_load ~/conky/script/meteo.lua
lua_startup_hook init ~/conky/script/meteo.cfg
lua_load ~/conky/script/clock_rings.lua
lua_draw_hook_pre clock_rings
lua_load ~/conky/script/multi_rings.lua
lua_draw_hook_post main
TEXT
${template1 Maj}
${voffset 29}${offset 120}${color3}BAT:
${voffset 17}${goto 65}${font hooge 05_53:size=12}${color1}${time %H:%M}${font}${goto 185}UPTIME:
${voffset 2}${goto 65}${time %a %d %b}${goto 185}${uptime}
${voffset 2}${goto 65}${time %Y}
${voffset -6}${goto 145}${color3}HD
${voffset 12}${alignc}${color1}$fs_free}/${fs_size}
${voffset 36}${goto 91}${cpu cpu0}%${goto 221}${memperc}%
${voffset 10}${goto 76}${color3}CPU${goto 205}MEM
${voffset 20}${goto 90}${font hooge 05_53:size=14}${color1}${template1 TempAct}°${font}${voffset -12}${goto 185}${template1 CondMeteo1se}${voffset 8}${goto 185}VENT:${template1 VentDirP} ${template1 VentForce}km/h${voffset 8}${goto 185}Pluie:${template1 QPrec}mm${font}${voffset 40}${goto 84}${template1 Jour_Temp 2}°/${template1 Nuit_Temp 2}°${goto 140}${template1 Jour_Temp 3}°/${template1 Nuit_Temp 3}°${goto 190}${template1 Jour_Temp 4}°/${template1 Nuit_Temp 4}°${voffset 7}${goto 85}${template1 Jour %a 2}${goto 140}${template1 Jour %a 3}${goto 190}${template1 Jour %a 4}
${if_match ${battery_percent BAT1}>0}${if_match ${battery_percent BAT1}<=15}${image $HOME/conky/weather+clock/images/Red.png -p 129,18 -s 40x40}${endif}${endif}
${if_match ${battery_percent BAT1}>15}${if_match ${battery_percent BAT1}<=20}${image $HOME/conky/weather+clock/images/Orange.png -p 129,18 -s 40x40}${endif}${endif}
${if_match ${battery_percent BAT1}>20}${if_match ${battery_percent BAT1}<=35}${image $HOME/conky/weather+clock/images/Yellow.png -p 129,18 -s 40x40}${endif}${endif}
${if_match ${battery_percent BAT1}>35}${if_match ${battery_percent BAT1}<=100}${image $HOME/conky/weather+clock/images/Dark_Green.png -p 129,18 -s 40x40}${endif}${endif}
${execpi 1 cat ~/conky/script/blinkingLED}
###Affichages Icônes###
${template2 IconeM ~/conky/meteo+lune/icones/base 95,150 110x66}
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base 62,205 70x42 2}
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base 115,205 70x42 3}
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base 168,205 70x42 4}
###Affichages Proba Pluie###
${font hooge 05_53:style=Bold:size=9}${voffset -152}${goto 143}${color red}${template1 Jour_ProbOrage 1}%
${font hooge 05_53:style=Bold:size=6}${voffset 30}${goto 92}${color red}${template1 Jour_ProbOrage 2}%${goto 146}${template1 Jour_ProbOrage 3}%${goto 200}${template1 Jour_ProbOrage 4}%
Nota : Pour un affichage correct, la police hooge 05_53 est nécessaire.
Merci de votre aide 😃