Contenu | Rechercher | Menus

Annonce

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

À propos de l'équipe du forum.

#201 Le 01/06/2011, à 20:46

shamen456

Re : Postez vos scripts Lua pour Conky !

Bonjour a tous...
...premier essai de conky utilisant des anneaux. c'est plus du bidouillage d'un script existant qu'une véritable 'création'...

Je me suis basé sur le conky_grey.lua et conkyrc_grey de SLK trouvé sur webupd8 (je n'ai d'ailleurs pas encore eut le temps de "nettoyer" les fichiers, j’espère avoir le temps de le faire prochainement...ce qui me permettra de voir un peu comment ça fonctionne vraiment)

deux parties sont actives : System et Network

conkyrc_grey2

#==============================================================================
#                                 conkyrc_grey
#
#  author  : SLK
#  version : v2011011601
#  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 0
gap_y 35
minimum_size 15 50
maximum_width 190
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment tr

draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no


override_utf8_locale yes
use_xft yes
xftfont caviar dreams:size=8
xftalpha 0.5
uppercase no

default_color FFFFFF
color1 D2CBC1
color2 ED7F77
color3 6B6860
color4 B1ADA7
color5 7B7870

lua_load ~/.conky/conky_grey2.lua
lua_draw_hook_post main

TEXT
${image ./pix/bigpanel2.png  -s 120x375 -p +85,-10}${voffset -4}${goto 100}${font Ubuntu:size=7,weight:bold}${color}System ${hr 1}
#${goto 90}${font Ubuntu:size=7,weight:normal}${color1}${top name 1}${alignr}${top cpu 1}%
#${goto 90}${font Ubuntu:size=7,weight:normal}${color2}${top name 2}${alignr}${top cpu 2}%
#${goto 90}${font Ubuntu:size=7,weight:normal}${color3}${top name 3}${alignr}${top cpu 3}%
${goto 100}${font Ubuntu:size=7,weight:normal}${color}${threads} process${goto 159}${font Ubuntu:size=7,weight:bold}
${goto 159}${voffset -2}RAM
${voffset -1}${goto 155}${font Ubuntu:size=7,weight:normal}
${voffset -2}${goto 159}${font Ubuntu:size=7,weight:bold}CPU
${voffset -10}${goto 154}${cpugraph 15,35 D2CBC1 ED7F77}
${goto 145}${font Ubuntu:size=14,weight:normal}${hwmon 0 temp 1} °C
${voffset 5}${goto 155}${color2}${hr 7}${font Ubuntu:size=7,weight:normal}
${voffset -5}${goto 155}${color2}${hr 7}
${voffset -18}${goto 158}${color}${font Ubuntu:size=6,weight:bold}CPU 1
${voffset -2}${goto 158}${font Ubuntu:size=6,weight:bold}CPU 2
${voffset 12}${goto 155}${color3}${hr 20}
${color}${voffset -15}${goto 159}${font Ubuntu:size=6,weight:bold}${mem}
${voffset -1}${goto 155}${font Ubuntu:size=6,weight:bold}/${memmax}
${goto 100}${voffset 5}${font Ubuntu:size=7,weight:bold}${color}Network ${hr 1}
${font Ubuntu:size=6,weight:bold}${goto 100}${alignr}${wireless_essid wlan0}  
${goto 155}${voffset 9}${color4}${hr 10}
${color}${voffset -9}${alignr}${wireless_bitrate wlan0}
${goto 148}${voffset -2}${font Ubuntu:size=6,weight:bold}U${alignr}${totalup wlan0}
${goto 154}${voffset -4}${upspeedgraph wlan0 28,35 BBB8B2 ED7F77}
${alignr}${voffset -8}${font Ubuntu:size=6,weight:bold}${upspeed wlan0}/s
${alignr}${voffset 10}${font Ubuntu:size=6,weight:bold}${downspeed wlan0}/s
${goto 154}${voffset -4}${downspeedgraph wlan0 28,35 BBB8B2 ED7F77}
${goto 148}${voffset -9}${font Ubuntu:size=6,weight:bold}D${alignr}${totaldown wlan0}
${goto 155}${voffset -2}${color5}${hr 10}
${color}${voffset -9}${font Ubuntu:size=6,weight:bold}${alignr}Signal   
${color}${voffset }${font Ubuntu:size=6,weight:bold}${alignr}${addr wlan0}
${alignr}${texeci 3600 wget -O - http://ip.tupeux.com | tail}

conky_grey2.lua

--==============================================================================
--                                 conky_grey.lua
--
--  author  : SLK
--  version : v2011011001
--  license : Distributed under the terms of GNU GPL version 2 or later
--
--==============================================================================

require 'cairo'

--------------------------------------------------------------------------------
--                                                                    clock DATA
-- HOURS
clock_h = {
}
-- MINUTES
clock_m = {
}
-- SECONDS
clock_s = {
}

--------------------------------------------------------------------------------
--                                                                    gauge DATA
gauge = {

{
    name='cpu',                    arg='cpu1',                  max_value=100,
    x=155,                          y=80,
    graph_radius=26,
    graph_thickness=7,
    graph_start_angle=180,
    graph_unit_angle=1.8,          graph_unit_thickness=2.7,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.6,
    graph_fg_colour=0xff0000,      graph_fg_alpha=0.3,
    hand_fg_colour=0x4F4B41,       hand_fg_alpha=0.3,
    txt_radius=14,
    txt_weight=0,                  txt_size=12.0,
    txt_fg_colour=0xffffff,        txt_fg_alpha=0.0,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},
{
    name='cpu',                    arg='cpu2',                  max_value=100,
    x=155,                          y=80,
    graph_radius=34,
    graph_thickness=7,
    graph_start_angle=180,
    graph_unit_angle=1.8,          graph_unit_thickness=2.7,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.6,
    graph_fg_colour=0xff0000,      graph_fg_alpha=0.3,
    hand_fg_colour=0x4F4B41,       hand_fg_alpha=0.3,
    txt_radius=46,
    txt_weight=0,                  txt_size=12.0,
    txt_fg_colour=0xff0000,        txt_fg_alpha=0.0,
    graduation_radius=33,
    graduation_thickness=12,        graduation_mark_thickness=1,
    graduation_unit_angle=18,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.8,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},
{
    name='cpu',                    arg='cpu0',                  max_value=100,
    x=155,                          y=80,
    graph_radius=30,
    graph_thickness=15,
    graph_start_angle=180,
    graph_unit_angle=1.8,          graph_unit_thickness=1,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.,
    graph_fg_colour=0xff0000,      graph_fg_alpha=0.0,
    hand_fg_colour=0x4F4B41,       hand_fg_alpha=1.0,
    txt_radius=45,
    txt_weight=0,                  txt_size=10.0,
    txt_fg_colour=0xffffff,        txt_fg_alpha=1,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.8,
},
{
    name='memperc',                arg='',                      max_value=100,
    x=155,                          y=80,
    graph_radius=54,
    graph_thickness=10,
    graph_start_angle=180,
    graph_unit_angle=1.8,          graph_unit_thickness=3.5,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.6,
    graph_fg_colour=0x4F4B41,      graph_fg_alpha=0.5,
    hand_fg_colour=0xff0000,       hand_fg_alpha=0.5,
    txt_radius=66,
    txt_weight=0,                  txt_size=10.0,
    txt_fg_colour=0xffffff,        txt_fg_alpha=1,
    graduation_radius=56,
    graduation_thickness=8,        graduation_mark_thickness=2,
    graduation_unit_angle=18,
    graduation_fg_colour=0x4F4B41, graduation_fg_alpha=0.6,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},
{
    name='wireless_link_qual_perc',                arg='wlan0',                      max_value=100,
    x=155,                          y=240,
    graph_radius=54,
    graph_thickness=10,
    graph_start_angle=180,
    graph_unit_angle=1.8,          graph_unit_thickness=2,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.5,
    graph_fg_colour=0x4F4B41,      graph_fg_alpha=0.5,
    hand_fg_colour=0x000000,       hand_fg_alpha=0.5,
    txt_radius=66,
    txt_weight=0,                  txt_size=10.0,
    txt_fg_colour=0xffffff,        txt_fg_alpha=1,
    graduation_radius=56,
    graduation_thickness=8,        graduation_mark_thickness=2,
    graduation_unit_angle=18,
    graduation_fg_colour=0x4F4B41, graduation_fg_alpha=0.6,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},
{
    name='downspeedf',                    arg='',                  max_value=100,
    x=155,                          y=241,
    graph_radius=28,
    graph_thickness=27,
    graph_start_angle=180,
    graph_unit_angle=.9,          graph_unit_thickness=.3,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.5,
    graph_fg_colour=0x5B544A,      graph_fg_alpha=0.1,
    hand_fg_colour=0x4F4B41,       hand_fg_alpha=0.3,
    txt_radius=46,
    txt_weight=0,                  txt_size=10.0,
    txt_fg_colour=0x4F4B41,        txt_fg_alpha=0.,
    graduation_radius=30,
    graduation_thickness=10,        graduation_mark_thickness=1,
    graduation_unit_angle=22.5,
    graduation_fg_colour=0x4F4B41, graduation_fg_alpha=0.8,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},{
    name='downspeedf',                    arg='wlan0',                  max_value=1800,
    x=155,                          y=241,
    graph_radius=28,
    graph_thickness=27,
    graph_start_angle=270,
    graph_unit_angle=-.05,          graph_unit_thickness=.3,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.0,
    graph_fg_colour=0x5B544A,      graph_fg_alpha=0.1,
    hand_fg_colour=0x4F4B41,       hand_fg_alpha=0.3,
    txt_radius=44,
    txt_weight=0,                  txt_size=10.0,
    txt_fg_colour=0x4F4B41,        txt_fg_alpha=0.,
    graduation_radius=33,
    graduation_thickness=12,        graduation_mark_thickness=1,
    graduation_unit_angle=18,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},

{
    name='upspeedf',                    arg='wlan0',                  max_value=256,
    x=155,                          y=240,
    graph_radius=28,
    graph_thickness=27,
    graph_start_angle=270,
    graph_unit_angle=.35,          graph_unit_thickness=.5,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.5,
    graph_fg_colour=0xff0000,      graph_fg_alpha=0.3,
    hand_fg_colour=0x4F4B41,       hand_fg_alpha=0.3,
    txt_radius=44,
    txt_weight=0,                  txt_size=10.0,
    txt_fg_colour=0xff0000,        txt_fg_alpha=0.
,
    graduation_radius=30,
    graduation_thickness=10,        graduation_mark_thickness=1,
    graduation_unit_angle=22.5,
    graduation_fg_colour=0x4F4B41, graduation_fg_alpha=0.8,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},
}

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

screenshot : screenshot conky_grey2

Hors ligne

#202 Le 17/07/2011, à 22:08

Swiss_Knight

Re : Postez vos scripts Lua pour Conky !

salut tout le monde,

petite question à 5 sous : est-ce possible de faire des barres pour le trafic réseau (up/down) ?
si oui comment faire ? j'ai tenté naïvement de rajouter un "eth0" qui caractérise mon interface dans le nom d'une barre mais sans succès apparemment.

Si vous avez des idées je suis preneur = )
Merci beaucoup.


xuniL

Hors ligne

#203 Le 20/07/2011, à 15:52

spikiq

Re : Postez vos scripts Lua pour Conky !

Bonjour à tous, je suis tombé sur le cul en voyant tous ces codes, à la base je suis pas fan de "codage " ou programmation, mais en voyant tous vos posts je me suis dit "woaaaah ca donne ça ! C'est juste énorme !" donc voilà, j'ai décidé de me lancer dans le Conky et le Lua, pour essayer d'avoir un bureau simple, sans souris obligatoire (raccourcis plus pratiques non? smile )
Quelles connaissances sont à acquérir pour s'en sortir? Langages de programmation? Bon de l'imagination certes pour la mise en forme mais bon ça, c'est pas un problème big_smile (je suis fan et adepte de l'art digital, l'imagination ça me connait big_smile, ouais on s'en fou je sais....bref) .
Donc voilà, je compte sur vous et votre sympathie pour me guider sur la/les bonne(s) voie(s) smile

PS: je ne suis pas là pour flooder, donc si je propose de créer un topic pour l'apprentissage du Conky et du Lua? (ou autres, avec des liens guides etc....) ?

Dernière modification par spikiq (Le 20/07/2011, à 15:54)

Hors ligne

#204 Le 20/07/2011, à 15:57

spikiq

Re : Postez vos scripts Lua pour Conky !

Salut Swiss-Knight, en fouinant un peu sur google et les blogs, je suis tombé sur un code qui m'avait donné une interface avec des "barres de up et down" comme tu veux, là je suis au boulot, j'éditerais le message quand j'aurais retrouvé le lien dans mon historique chez moi et je te filerais la source wink

EDIT: Finalement, ce n'était pas ça ^^ donc je l'ai fait à la mano pour m'entrainer !

Pour le download:
${downspeedgraph eth0}

Pour le upload:
${upspeedgraph eth0}

EDIT:

Ou mieux !

${downspeed eth0} ${downspeedgraph eth0}
en bit/seconde exprimé par le graph, tu peux changer la couleur du graph et la taille (en hauteur) ainsi:
${downspeed eth0} ${downspeedgraph 25(taille) 50(couleur, ici bleu) eth0}

Dernière modification par spikiq (Le 20/07/2011, à 18:35)

Hors ligne

#205 Le 20/07/2011, à 16:07

Fenouille84

Re : Postez vos scripts Lua pour Conky !

spikiq a écrit :

Bonjour à tous
...
Quelles connaissances sont à acquérir pour s'en sortir? Langages de programmation?

PS: je ne suis pas là pour flooder, donc si je propose de créer un topic pour l'apprentissage du Conky et du Lua? (ou autres, avec des liens guides etc....) ?

Pour conky, ces 2 pages sont LA bible !! Pour la partie pré-TEXT et pour les variables (partie post-TEXT).

Pour le Lua, Google est ton ami... roll
Je n'ai pas les adresses sous la main, mais tu peux trouver facilement de très bon tuto.


Bon courage en tout cas wink


Ma page Deviant Art : conky inside ;-)
.
-- DropBox (online backup) : 2Go + 250 Mo pour vous et moi par parrainage --

Hors ligne

#206 Le 20/07/2011, à 17:45

spikiq

Re : Postez vos scripts Lua pour Conky !

Merci smile

Par contre, à moins que je n'ai pas compris la doc Conky, il n'est pas expliqué quels signes il faut mettre et ou... genre les {} etc.... je galère un peu a trouver comment ça marche en autodidacte ^^

Hors ligne

#207 Le 20/07/2011, à 19:14

Fenouille84

Re : Postez vos scripts Lua pour Conky !

spikiq a écrit :

Merci smile

Par contre, à moins que je n'ai pas compris la doc Conky, il n'est pas expliqué quels signes il faut mettre et ou... genre les {} etc.... je galère un peu a trouver comment ça marche en autodidacte ^^

+1

Pour voir la construction d'un fichier type, tu as la doc conky.

Sinon, ces topics sont très bien fournis en fichier de config et résolution de divers problèmes :
=> Conky (1) / Conky (2) / Conky (3) (topics fermés, mais encore consultables)

=> Conky (4) : encore actif pour toute question, problème, idée, inspiration, etc.


Bonne lecture... tongue


Ma page Deviant Art : conky inside ;-)
.
-- DropBox (online backup) : 2Go + 250 Mo pour vous et moi par parrainage --

Hors ligne

#208 Le 20/07/2011, à 20:11

spikiq

Re : Postez vos scripts Lua pour Conky !

Mmmmh j'hésite quand même a me tirer une balle big_smile
Bon, c'est maintenant ou jamais!
Allez zou ! Et merci pour les liens (même si j'avais déjà consulté les topics conky, tous big_smile) !

Hors ligne

#209 Le 02/09/2011, à 12:09

shamen456

Re : Postez vos scripts Lua pour Conky !

Bonjour à tous...

une question pour les pro de lua
je désire créer un graph avec lua afin d'afficher une série de valeurs contenues dans un fichier texte (chaque ligne contient une valeur et le fichier ne contient que ça)

est-il possible de passer une liste de valeurs comme arguments pour les scripts repris au post #121 (les graphes de wlourf)

bon conky à tous

Hors ligne

#210 Le 02/09/2011, à 14:39

nbi

Re : Postez vos scripts Lua pour Conky !

salut,
jai récupéré l'archive russe (1ère page), effectué les modifs et ça tourne. Par contre j'ai un fond semi transparent, comment l'intégrer complètement?

et sinon, je n'ai pas saisi quelques trucs : les ronds au dessus et en dessous de l'anneau indiquent quoi (le traffic réseau?), les deux aiguilles un peu plus claires et la toute petite trotteuse indiquent quoi également?

Merci

Hors ligne

#211 Le 04/09/2011, à 11:57

wlourf

Re : Postez vos scripts Lua pour Conky !

shamen456 a écrit :

Bonjour à tous...

une question pour les pro de lua
je désire créer un graph avec lua afin d'afficher une série de valeurs contenues dans un fichier texte (chaque ligne contient une valeur et le fichier ne contient que ça)

est-il possible de passer une liste de valeurs comme arguments pour les scripts repris au post #121 (les graphes de wlourf)

bon conky à tous

Salut,
le plus simple serait peut-être de créer ton graph avec gnuplot, exporter le graph en png puis afficher ce png dans conky, par exemple ;-)

Sinon, si tu tiens à utiliser mon script, voici une petite modif :
remplace ce bloc :

    if updates > updates_gap then
        for i in pairs(graph_settings) do
            if graph_settings[i].draw_me==true then graph_settings[i].draw_me = nil end
            if (graph_settings[i].draw_me==nil or conky_parse(tostring(graph_settings[i].draw_me)) == "1") then 
                local nb_values=graph_settings[i].nb_values
                graph_settings[i].automax=0
                for j =1, nb_values do
                    if graph_settings[i].values[j+1]==nil then 
                        graph_settings[i].values[j+1]=0 
                    end
                
                    graph_settings[i].values[j]=graph_settings[i].values[j+1]
                    if j==nb_values then
                        --store value
                        if graph_settings[i].name=="" then
                            value=graph_settings[i].arg
                        else
                            value=tonumber(conky_parse('${' .. 
                                graph_settings[i].name .. " " ..
                                graph_settings[i].arg ..'}'))
                        end
                        graph_settings[i].values[nb_values]=value
                    end
                    graph_settings[i].automax=math.max(graph_settings[i].automax,
                                                       graph_settings[i].values[j])
                    --should stop weird glitches at beginning when no values reported yet for upspeed or diskio
                    if graph_settings[i].automax == 0 then graph_settings[i].automax = 1 end 
                end
                   draw_graph(graph_settings[i])
            end
        end
    end

par celui-ci :

    if updates > updates_gap then
        for i in pairs(graph_settings) do
            if graph_settings[i].draw_me==true then graph_settings[i].draw_me = nil end
            if graph_settings[i].fichier ==nil then
                if (graph_settings[i].draw_me==nil or conky_parse(tostring(graph_settings[i].draw_me)) == "1") then 
                    local nb_values=graph_settings[i].nb_values
                    graph_settings[i].automax=0
                    for j =1, nb_values do
                        if graph_settings[i].values[j+1]==nil then 
                            graph_settings[i].values[j+1]=0 
                        end
                    
                        graph_settings[i].values[j]=graph_settings[i].values[j+1]
                        if j==nb_values then
                            --store value
                            if graph_settings[i].name=="" then
                                value=graph_settings[i].arg
                            else
                                value=tonumber(conky_parse('${' .. 
                                    graph_settings[i].name .. " " ..
                                    graph_settings[i].arg ..'}'))
                            end
                            graph_settings[i].values[nb_values]=value
                        end
                        graph_settings[i].automax=math.max(graph_settings[i].automax,
                                                           graph_settings[i].values[j])
                        --should stop weird glitches at beginning when no values reported yet for upspeed or diskio
                        if graph_settings[i].automax == 0 then graph_settings[i].automax = 1 end 
                    end
                    draw_graph(graph_settings[i])
                end
            else

                if (graph_settings[i].draw_me==nil or conky_parse(tostring(graph_settings[i].draw_me)) == "1") then 
                    --commenter la ligne ci-dessous pour avoir un affichage progressif au démarrage du conky
                    updates=graph_settings[i].nb_values+updates_gap
                    local nb_values=graph_settings[i].nb_values
                    graph_settings[i].automax=0
                    j=0
                    for line in io.lines(graph_settings[i].fichier) do
                        j=j+1
                        if line=="" then line=0 end
                        graph_settings[i].values[j]= tonumber(line)
                        graph_settings[i].automax=math.max(graph_settings[i].automax,
                                                           graph_settings[i].values[j])
                        --should stop weird glitches at beginning when no values reported yet for upspeed or diskio
                        if graph_settings[i].automax == 0 then graph_settings[i].automax = 1 end 
                    end
                    draw_graph(graph_settings[i])
                end
            end
        end
    end

ce bloc permet de conserver l'affichage du script original ou de lire les valeurs d'un fichier texte (donc une valeur par ligne, les lignes vides sont remplacées par zéro).

et dans la table des paramètres, il faut indiquer le chemin du fichier en absolu (sans utiliser ~ ou $HOME) et le nombre de valeurs à afficher qui doit correspondre au nombre de lignes du fichier texte ou moins, par exemple

        {
        name="cpu",         --valeur bidon, ne sera pas traité
        arg="",
        max=60,
        autoscale=true,
        y=100,
        width=250,
        height=75,
        draw_me=true,
        nb_values=32,               --nombre de lignes du fichier à afficher, en commençant par le début du fichier
        fichier="/home/wlourf/tmp/valeurs.txt" -- fichier à traiter
        },

Donc lorsque le fichier texte est modifié, la modif apparaîtra à la prochaine mise à jour du conky.

Merci pour l'idée, je l'intègrerai dans une prochaine version ;-)

Hors ligne

#212 Le 09/09/2011, à 16:56

shamen456

Re : Postez vos scripts Lua pour Conky !

@wlourf : merci, j’essaierai ça un de ces jours...pour le moment l'option de gnuplot est la plus facile à mettre en œuvre et Levi59 nous a pondu un petit script bien efficace....(voir forum conky au post #974

...je posterai le résultat des que j'en serai satisfait (encore quelques détails à régler..)


Bon conky à tous...

Hors ligne

#213 Le 09/09/2011, à 21:29

Levi59

Re : Postez vos scripts Lua pour Conky !

Je mets le lien du post pour ceux qui mettent plus de messages par page (je n'ai pas de page 39 ^^)
./viewtopic.php?pid=6064281#p6064281

Hors ligne

#214 Le 10/09/2011, à 09:49

egoz

Re : Postez vos scripts Lua pour Conky !

Hello,

Je me lance dans les scripts Lua, je me suis basé sur un modèle existant pour commencer, mais impossible de rajouter des cercles dans ma settings-table.... Du coup j'ai voulu faire un bête copier/coller de l'un deux ce qui ne fonctionne pas non plus yikes

Ci-dessous le code que j'utilise :

--[[
Clock Rings by Linux Mint (2011) reEdited by despot77

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 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/clock_rings.lua
    lua_draw_hook_pre clock_rings
    
Changelog:
+ v1.0 -- Original release (30.09.2009)
   v1.1p -- Jpope edit londonali1010 (05.10.2009)
*v 2011mint -- reEdit despot77 (18.02.2011)
]]

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=0xFF6600,
        -- "fg_alpha" is the alpha value of the indicator part of the ring.
        fg_alpha=0.2,
        -- "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=100, y=150,
        -- "radius" is the radius of the ring.
        radius=50,
        -- "thickness" is the thickness of the ring, centred around the radius.
        thickness=5,
        -- "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=0xFF6600,
        fg_alpha=0.4,
        x=100, y=150,
        radius=56,
        thickness=5,
        start_angle=0,
        end_angle=360
    },
    {
        name='time',
        arg='%S',
        max=60,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0xFF6600,
        fg_alpha=0.6,
        x=100, y=150,
        radius=62,
        thickness=5,
        start_angle=0,
        end_angle=360
    },
    {
        name='time',
        arg='%d',
        max=31,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0xFF6600,
        fg_alpha=0.8,
        x=100, y=150,
        radius=70,
        thickness=5,
        start_angle=-90,
        end_angle=90
    },
    {
        name='time',
        arg='%m',
        max=12,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0xFF6600,
        fg_alpha=1,
        x=100, y=150,
        radius=76,
        thickness=5,
        start_angle=-90,
        end_angle=90
    },
    {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xFF6600,
        fg_alpha=0.8,
        x=50, y=300,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xFF6600,
        fg_alpha=0.8,
        x=75, y=350,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
    {
        name='swapperc',
        arg='',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xFF6600,
        fg_alpha=0.8,
        x=100, y=400,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
    {
        name='swapperc',
        arg='/',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xFF6600,
        fg_alpha=0.8,
        x=125, y=450,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
        {
        name='downspeedf',
        arg='eth0',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x339900,
        fg_alpha=0.8,
        x=150, y=500,
        radius=25,
        thickness=4,
        start_angle=-90,
        end_angle=180
    },
        {
        name='upspeedf',
        arg='eth0',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xff6600,
        fg_alpha=0.8,
        x=150, y=500,
        radius=20,
        thickness=4,
        start_angle=-90,
        end_angle=180
    },  ------------------------------ci-dessous la portion de code que j'ajoute pour avoir un cercle supplémentaire -----------------------------
    {
        name='memperc',
        arg='/',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xFF6600,
        fg_alpha=0.8,
        x=50, y=500,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    }, -------------------------------------------------------------------------------------------------------------
    
}

-- Use these settings to define the origin and extent of your clock.

clock_r=65

-- "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=100
clock_y=150

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,1.0,1.0,1.0,1.0)
    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)
        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

Je présume que j'ai oublié de rajouter quelque chose quelque part et que c'est tout bête mais je n'arrive pas à trouver sad...

Hors ligne

#215 Le 10/09/2011, à 13:21

wlourf

Re : Postez vos scripts Lua pour Conky !

En lançant ton conky dans un terminal, quel est le message d'erreur ?

Hors ligne

#216 Le 10/09/2011, à 16:52

egoz

Re : Postez vos scripts Lua pour Conky !

Salut,

egoz@ubuntu-desktop:~$ conky -d -c .conky/conkyrc 
Conky: forked to background, pid is 1793
egoz@ubuntu-desktop:~$ 
Conky: desktop window (10000be) is subwindow of root window (bb)
Conky: window type - override
Conky: drawing to created window (0x3800001)
Conky: drawing to double buffer

Le conky se lance normalement, il manque juste le cercle que j'ai ajouté en fait hmm

Hors ligne

#217 Le 10/09/2011, à 18:42

wlourf

Re : Postez vos scripts Lua pour Conky !

egoz a écrit :

Le conky se lance normalement, il manque juste le cercle que j'ai ajouté en fait hmm

Bizarre, car chez moi, avec ton code copié, il s'affiche avec un petit message d'erreur (attempt to perform arithmetic on local 'value' (a nil value)) que j'ai supprimé en ajoutant

if value == nil then value =0 end

  après la ligne

value=tonumber(str)

donc là, je ne vois pas d'où vient ton problème d'affichage sad Ta fenêtre conky est assez grande? diminue le y de ton cercle au cas où ...

Hors ligne

#218 Le 10/09/2011, à 19:08

egoz

Re : Postez vos scripts Lua pour Conky !

Ben en fait, je viens de faire un autre test, même en changeant les paramètres des cercles existants, ça faisait rien.

Du coup j'ai vérifié, et je viens de percuter que je modifiais pas le fichier lua auquel le conky faisait appel, mais un autre qui ne sert a rien lol tongue roll

Dernière modification par egoz (Le 10/09/2011, à 19:09)

Hors ligne

#219 Le 15/09/2011, à 23:12

rpj

Re : Postez vos scripts Lua pour Conky !

Bonjour à tous, je me lance dans lua et voici mon 1º probleme:
Certains cercles ne s'affichent pas (swapp et disk).
voici mon conkyrc:

# Conky settings #
background no
update_interval 1

cpu_avg_samples 2
net_avg_samples 2

override_utf8_locale yes 

double_buffer yes
no_buffers yes

text_buffer_size 2048
#imlib_cache_size 0

temperature_unit fahrenheit

# Window specifications #

own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below

border_inner_margin 0
border_outer_margin 0

minimum_size 400 450
maximum_width 400

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 ~/.lua/scripts/clock_rings.lua
lua_draw_hook_pre clock_rings
 
TEXT

${voffset 2}${color 800000}${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 D60650}${hr}
 

${font Caviar Dreams:size=10}
${color FFFFFF}${goto 125}${voffset 105}${downspeed ppp0}${color D60650}${goto 25}ppp0 down
${color FFFFFF}${goto 125}${upspeed ppp0}${color D60650}${goto 25}ppp0 up


${color FFFFFF}${goto 0}${voffset 35}${cpu cpu1}${color FFFFFF}${goto 25}${voffset 0}${cpu cpu2}
${color D60650}${goto 0}CPU 1+2
${color FFFFFF}${goto 165}${voffset -50}${memperc}%

${color D60650}${goto 165}RAM

${color FFFFFF}${goto 150}${voffset 60}${fs_used_perc /}%

${color D60650}${goto 150}Disk
${color FFFFFF}${goto 150}${voffset 60}${swapperc}%
${color D60650}${goto 150}Swap
${font Caviar Dreams:size=10}

et mon  clocks_ring.lua :

--[[
Clock Rings by Linux Mint (2011) reEdited by despot77

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 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/clock_rings.lua
    lua_draw_hook_pre clock_rings
    
Changelog:
+ v1.0 -- Original release (30.09.2009)
   v1.1p -- Jpope edit londonali1010 (05.10.2009)
*v 2011mint -- reEdit despot77 (18.02.2011)
]]

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=0xf4c507,
        -- "fg_alpha" is the alpha value of the indicator part of the ring.
        fg_alpha=0.2,
        -- "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=100, y=150,
        -- "radius" is the radius of the ring.
        radius=50,
        -- "thickness" is the thickness of the ring, centred around the radius.
        thickness=5,
        -- "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=1,
        fg_colour=0xf4c507,
        fg_alpha=1,
        x=100, y=150,
        radius=56,
        thickness=15,
        start_angle=0,
        end_angle=360
    },
    {
        name='time',
        arg='%S',
        max=60,
        bg_colour=0xffffff,
        bg_alpha=0,5,
        fg_colour=0xf4c507,
        fg_alpha=1,
        x=100, y=150,
        radius=62,
        thickness=5,
        start_angle=0,
        end_angle=360
    },
    {
        name='time',
        arg='%d',
        max=31,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0xf4c507,
        fg_alpha=0.8,
        x=100, y=150,
        radius=70,
        thickness=5,
        start_angle=-90,
        end_angle=90
    },
    {
        name='time',
        arg='%m',
        max=12,
        bg_colour=0xffffff,
        bg_alpha=0,
        fg_colour=0xefe9e9,
        fg_alpha=1,
        x=100, y=150,
        radius=76,
        thickness=5,
        start_angle=-90,
        end_angle=90
    },
    {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=1,
        fg_colour=0xD60650,
        fg_alpha=0.8,
        x=50, y=320,
        radius=45,
        thickness=8,
        start_angle=-90,
        end_angle=90
    },
        {
        name='cpu',
        arg='cpu2',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=1,
        fg_colour=0xD60650,
        fg_alpha=0.8,
        x=50, y=320,
        radius=25,
        thickness=8,
        start_angle=-90,
        end_angle=90
    },
    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=1,
        fg_colour=0xD60650,
        fg_alpha=0.8,
        x=180, y=320,
        radius=45,
        thickness=8,
        start_angle=-90,
        end_angle=90,
    },
    {
        name='swapperc',
        arg='',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=1,
        fg_colour=0xD60650,
        fg_alpha=0.8,
        x=180, y=300,
        radius=25,
        thickness=8,
        start_angle=-90,
        end_angle=90,
    },
    {
        name='fs_used_perc',
        arg='/',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=1,
        fg_colour=0xD60650,
        fg_alpha=0.8,
        x=180, y=800,
        radius=45,
        thickness=8,
        start_angle=-90,
        end_angle=90,
    },
        {
        name='upspeedf',
        arg='ppp0',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=1,
        fg_colour=0xD60650,
        fg_alpha=0.8,
        x=250, y=300,
        radius=20,
        thickness=4,
        start_angle=-90,
        end_angle=180
    },
        {
        name='acpitemp',
        arg='',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=1,
        fg_colour=0xD60650,
        fg_alpha=0.8,
        x=180, y=500,
        radius=25,
        thickness=8,
        start_angle=-90,
        end_angle=90
    },
}

-- Use these settings to define the origin and extent of your clock.

clock_r=65

-- "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=50
clock_y=50

show_seconds=true

require 'cairo'

function rgb_to_r_g_b(colour,alpha)
    return ((colour / 0xf4c507) % 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,1.0,1.0,1.0,1.0)
    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)
        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

Je suis sous LMDE et voici ce qu'il s'affiche :
1316124684.png

Merci d'avance à ceux qui pourrons m'aider.

Dernière modification par rpj (Le 15/09/2011, à 23:22)


La ligne de commande UNIX devrait être obligatoire dès la maternelle ! :-)
Debian, XFCE,  FF, .
Android dev (éternel débutant)

Hors ligne

#220 Le 16/09/2011, à 18:43

rpj

Re : Postez vos scripts Lua pour Conky !

Salut, j'ai une autre question : quand conky se lance je vois les aiguilles pendant 3 ou 4 secondes et ensuite quand le lua se charge les cercles cachent les aiguilles .
Comment faire pour que lua se charge avant conky ?
J'ai essayé différents trucs (tâtonnements) mais rien.
Qqun a une idée ?
Merci d'avance


La ligne de commande UNIX devrait être obligatoire dès la maternelle ! :-)
Debian, XFCE,  FF, .
Android dev (éternel débutant)

Hors ligne

#221 Le 16/09/2011, à 19:36

chepioq

Re : Postez vos scripts Lua pour Conky !

rpj a écrit :

Salut, j'ai une autre question : quand conky se lance je vois les aiguilles pendant 3 ou 4 secondes et ensuite quand le lua se charge les cercles cachent les aiguilles .
Comment faire pour que lua se charge avant conky ?
J'ai essayé différents trucs (tâtonnements) mais rien.
Qqun a une idée ?
Merci d'avance

Essaye en changeant la ligne

lua_draw_hook_pre clock_rings

par

lua_draw_hook_post clock_rings

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

Hors ligne

#222 Le 17/09/2011, à 08:20

rpj

Re : Postez vos scripts Lua pour Conky !

Salut chepioq, oui ça j'ai déjà essayé sans résultats. J'ai aussi changé le lua de place je l'est mis dans le même dossier que le rc pour qu'il soit juste à coté même résultat.
On dirait un problème de layout , comme c
çi la couche des cercles recouvrait la couche conky.
Je vais essayé de déplacer les cercles pour voir si il y a les aiguilles dessous.

Dernière modification par rpj (Le 17/09/2011, à 08:21)


La ligne de commande UNIX devrait être obligatoire dès la maternelle ! :-)
Debian, XFCE,  FF, .
Android dev (éternel débutant)

Hors ligne

#223 Le 17/09/2011, à 08:48

rpj

Re : Postez vos scripts Lua pour Conky !

Bon en déplaçant les cercles il n'y a rien dessous je pense que c'est une fausse transparence.
J'ai essayé d'autres conky "tout près" et aucuns n'était correct , ou les cercles ne s'affichait pas ou il manquait la moitié du conky.
Problème carte graphique ? (nvidia G force)
Système op (Linux mint debian) ?
J'ai aussi lu qqpart qu'avec "cpu" dans le conky il pouvait y avoir un bug.
Qu'en pense tu ?

Dernière modification par rpj (Le 17/09/2011, à 08:52)


La ligne de commande UNIX devrait être obligatoire dès la maternelle ! :-)
Debian, XFCE,  FF, .
Android dev (éternel débutant)

Hors ligne

#224 Le 17/09/2011, à 12:20

rpj

Re : Postez vos scripts Lua pour Conky !

Résolut:
trouvé une astuce de wlouf #217 qui a résolut tout les pb que j'avais ( post 219 a 223)
Ça fait 2 jours que  je lis que des trucs sur lua et ça commence à s’éclaircir.


La ligne de commande UNIX devrait être obligatoire dès la maternelle ! :-)
Debian, XFCE,  FF, .
Android dev (éternel débutant)

Hors ligne

#225 Le 18/09/2011, à 10:22

rpj

Re : Postez vos scripts Lua pour Conky !

Salut à tous, cette fois çi j'ai voulu utiliser les "sectors" pioché ici:
http://u-scripts.blogspot.com/2010/08/r … dgets.html
mais voila aucuns sector ne s'affichent.
.lua

    },
 rings_settings={ 
{
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=0x21cdb3,
        bg_alpha=1,
        fg_colour=0x062bcb,
        fg_alpha=1,
        xc=599, yc=210,
        radius=35,
        thickness=10,
        start_angle=-180,
        end_angle=0
}
}   

conkyrc

${color FFFFFF}${goto 554}${voffset 55}${cpu cpu1}

J'ia oublié qqchose ?
Merci d'avance


La ligne de commande UNIX devrait être obligatoire dès la maternelle ! :-)
Debian, XFCE,  FF, .
Android dev (éternel débutant)

Hors ligne