Fedora-Fr - Communauté francophone Fedora - Linux

Communauté francophone des utilisateurs de la distribution Linux Fedora.

  

Dernière news : Arrêt de maintenance pour Fedora 28

#326 26/05/2011 18:10:48

chepioq
FEDORA FOR EVER
Lieu : a l'est de marseille
Inscription : 07/06/2006
Messages : 7 286

Re : Conky - Partage de scripts

titimoi a écrit :

oui ça passe, il y a un sujet dessus déjà ;) la seule différence c'est "window type normal" à changer, mais ma mémoire peut être fausse

Non ta mémoire est bonne, il faut mettre window à normal

own_windows_type normal

Tout est dans tout... et réciproquement...
C'est quoi un chalumeau??? C'est un dromaludaire à deux bosses...
Quand le sage montre la lune l'imbécile regarde le doigt...
1277887812.gif

Hors ligne

#327 11/06/2011 03:20:52

teutates
Membre
Lieu : Pyrénées
Inscription : 11/05/2006
Messages : 292
Site Web

Re : Conky - Partage de scripts

Bonjour,

J'ai presque fini de me constituer mon fichier conky mais, malgré 3 jours complets de recherches et d'essais, je bloque sur un point : les données réseaux ! Je parviens à récupérer mon adresse publique via un script mais si j'utilise la ligne ci dessous, j'obtiens un "no address" :
${color grey}IP eth0 $color${alignc}${addr eth0}
Pourtant je suis en ethernet sur eth0 !

Cette absence d'adresse explique aussi, en passant, le fait que tous mes chiffres, Reception comme Envoi, soit continuellement égaux à zéro !

Voici l'extrait fonctionnel du fichier que j'utilise :

${color #00BFFF}${font bold:size=13}Réseau:${font}
${color white}Passerelle : ${color green}${alignr}${gw_ip}
${color white}Publique : ${color green}$alignr${execi 3600 wget -O - http://ip.tupeux.com | tail}

Et ceci, c'est la suite qui ne fonctionne pas, la dernière ligne étant un doublon de contrôle temporaire :

${color grey}Reçu:    ${color red}${downspeed eth0}kb/s ${color grey}${alignr}Total:$color${totaldown eth0} ${downspeedgraph eth0 8,80 ffffff orange}
${color grey}Envoyé:  ${color red}${upspeed eth0}kb/s ${color grey}${alignr}Total:$color${totalup eth0} ${upspeedgraph eth0 8,80 ffffff orange}
${color grey}IP eth0 $color${alignc}${addr eth0}

Une idée ? Merci par avance wink


CM Asus P8Z68-V/GEN3 - CPU Intel i72700k - RAM G-Skill 4x4 Go PC 12800 - CG Gainward Geforce GTX 560 2 Go
DD Western Digital Velociraptor 300 Go Sata 3 + SSD 500 Go Sata 3 + Seagate Barracuda 2 To Sata 3 (x4) - Graveur DVD Asus DRW-24B3LT
Fedora 29 Plasma - Debian 9 Stretch Plasma

Hors ligne

#328 11/06/2011 03:28:33

DiEOrLivE
Fedora Addict
Lieu : [fedora@quebec ~]$
Inscription : 29/10/2010
Messages : 544

Re : Conky - Partage de scripts

Si tu es sous F15 c'est em1 maintenant x)


4 x Intel® Core™ i5 CPU 750 @ 2.67GHz - 7968MB ram - fc18.x86_64 - Xfce 4.10

1323030803.png

Hors ligne

#329 11/06/2011 07:25:31

chepioq
FEDORA FOR EVER
Lieu : a l'est de marseille
Inscription : 07/06/2006
Messages : 7 286

Re : Conky - Partage de scripts

@teutates
Si tu lances ton conky en ligne de commande, est-ce que tu as des messages d'erreurs ?


Tout est dans tout... et réciproquement...
C'est quoi un chalumeau??? C'est un dromaludaire à deux bosses...
Quand le sage montre la lune l'imbécile regarde le doigt...
1277887812.gif

Hors ligne

#330 11/06/2011 14:16:13

teutates
Membre
Lieu : Pyrénées
Inscription : 11/05/2006
Messages : 292
Site Web

Re : Conky - Partage de scripts

DiEOrLivE a écrit :

Si tu es sous F15 c'est em1 maintenant x)

em1 remplace quelle valeur ? J'ai remplacé eth0 par em1 (j'ai aussi testé dans le doute em0) mais c'est toujours pareil.

chepioq a écrit :

@teutates
Si tu lances ton conky en ligne de commande, est-ce que tu as des messages d'erreurs ?

Je n'ai pas vraiment de message d'erreur :

[Fedora@localhost ~]$ conky -c ~/.conky/conkyrc
Conky: desktop window (100001d) is subwindow of root window (15d)
Conky: window type - desktop
Conky: drawing to created window (0x3800001)
Conky: drawing to single buffer
--2011-06-11 14:11:56--  http://ip.tupeux.com/
Résolution de ip.tupeux.com... 88.191.122.240
Connexion vers ip.tupeux.com|88.191.122.240|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 10 [text/html]
Sauvegarde en : «STDOUT»

100%[============================================================================>] 10          --.-K/s   ds 0s      

2011-06-11 14:11:57 (541 KB/s) - envoi vers sortie standard [10/10]

CM Asus P8Z68-V/GEN3 - CPU Intel i72700k - RAM G-Skill 4x4 Go PC 12800 - CG Gainward Geforce GTX 560 2 Go
DD Western Digital Velociraptor 300 Go Sata 3 + SSD 500 Go Sata 3 + Seagate Barracuda 2 To Sata 3 (x4) - Graveur DVD Asus DRW-24B3LT
Fedora 29 Plasma - Debian 9 Stretch Plasma

Hors ligne

#331 11/06/2011 19:39:56

teutates
Membre
Lieu : Pyrénées
Inscription : 11/05/2006
Messages : 292
Site Web

Re : Conky - Partage de scripts

teutates a écrit :
DiEOrLivE a écrit :

Si tu es sous F15 c'est em1 maintenant x)

em1 remplace quelle valeur ? J'ai remplacé eth0 par em1 (j'ai aussi testé dans le doute em0) mais c'est toujours pareil.

chepioq a écrit :

@teutates
Si tu lances ton conky en ligne de commande, est-ce que tu as des messages d'erreurs ?

Je n'ai pas vraiment de message d'erreur :

[Fedora@localhost ~]$ conky -c ~/.conky/conkyrc
Conky: desktop window (100001d) is subwindow of root window (15d)
Conky: window type - desktop
Conky: drawing to created window (0x3800001)
Conky: drawing to single buffer
--2011-06-11 14:11:56--  http://ip.tupeux.com/
Résolution de ip.tupeux.com... 88.191.122.240
Connexion vers ip.tupeux.com|88.191.122.240|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 10 [text/html]
Sauvegarde en : «STDOUT»

100%[============================================================================>] 10          --.-K/s   ds 0s      

2011-06-11 14:11:57 (541 KB/s) - envoi vers sortie standard [10/10]

J'ai trouvé ! J'ai d'abord cherché de la doc sur le nouveau nommage remplaçant ethx mais ce ne sont que des généralités. Par contre, en allant se balader du côté de system-config-network (le module pour paramétrer le réseau), on trouve le petit nom réel de eth0. Chez moi, le port Ethernet eth0 s'appelle p16p1. Il suffit alors de remplacer eth0 par p16p1.

Cependant, ${addr p16p1} me renvoie une adresse de la box. Pas la publique.


CM Asus P8Z68-V/GEN3 - CPU Intel i72700k - RAM G-Skill 4x4 Go PC 12800 - CG Gainward Geforce GTX 560 2 Go
DD Western Digital Velociraptor 300 Go Sata 3 + SSD 500 Go Sata 3 + Seagate Barracuda 2 To Sata 3 (x4) - Graveur DVD Asus DRW-24B3LT
Fedora 29 Plasma - Debian 9 Stretch Plasma

Hors ligne

#332 11/06/2011 20:35:56

coRe
Membre
Lieu : Lyon/Bordeaux
Inscription : 24/11/2007
Messages : 152

Re : Conky - Partage de scripts

Pour mon bureau

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

# Window specifications #

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

border_inner_margin 0
border_outer_margin 0

minimum_size 200 250
maximum_width 200

alignment tr
gap_x 35
gap_y 55

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

# Text settings #
use_xft yes
xftfont caviar dreams:size=8
xftalpha 0.5

uppercase no

temperature_unit celsius


default_color FFFFFF

# Lua Load  #
lua_load ~/.lua/scripts/clock_rings.lua
lua_draw_hook_pre clock_rings

TEXT
${voffset 8}${color 0066FF}${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 0066FF}${hr}
${voffset 150}${font caviar dreams:size=8}${alignr}Fedora ${machine}${font}
${image ~/.conky/fedora-logo.png -p 58,115 -s 80x35}

${color FFFFFF}${goto 38}${voffset 32}${battery_percent BAT0}%
${color 0066FF}${goto 22}POWER
${color FFFFFF}${goto 64}${voffset 24}${memperc}%
${color 0066FF}${goto 48}RAM
${color FFFFFF}${goto 88}${voffset 24}${swapperc}%
${color 0066FF}${goto 72}SWAP
${color FFFFFF}${goto 114}${voffset 24}${fs_used_perc /}%
${color 0066FF}${goto 98}DISK
${color FFFFFF}${goto 94}${voffset 24}${cpu cpu0}%${goto 142}${cpu cpu1}%
${color 0066FF}${goto 126}CPU]

Pour lua (gedit .lua/scripts/clock_rings.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=0x0066FF,
        -- "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=0x0066FF,
        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=0x0066FF,
        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=0x0066FF,
        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=0x0066FF,
        fg_alpha=1,
        x=100, y=150,
        radius=76,
        thickness=5,
        start_angle=-90,
        end_angle=90
    },
    {
        name='battery_percent',
        arg='BAT0',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x0066FF,
        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=0x0066FF,
        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=0x0066FF,
        fg_alpha=0.8,
        x=100, y=400,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
    {
        name='fs_used_perc',
        arg='/',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x0066FF,
        fg_alpha=0.8,
        x=125, y=450,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
        {
        name='cpu',
        arg='cpu0',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x0066FF,
        fg_alpha=0.8,
        x=150, y=500,
        radius=25,
        thickness=4,
        start_angle=-90,
        end_angle=180
    },
        {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x0066FF,
        fg_alpha=0.8,
        x=150, y=500,
        radius=20,
        thickness=4,
        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

voilou pour modifier lua cf la doc

Dernière modification par coRe (11/06/2011 20:37:45)


Fedora_x64 sur ASUS A8Sc 14"

Hors ligne

#333 11/06/2011 20:37:25

DiEOrLivE
Fedora Addict
Lieu : [fedora@quebec ~]$
Inscription : 29/10/2010
Messages : 544

Re : Conky - Partage de scripts

Salut teutates! Pour l'ip public je crois qu'il n'y a pas de variable. J'ais mis cela ->

${texeci 25000 dig +short myip.opendns.com @resolver1.opendns.com}

4 x Intel® Core™ i5 CPU 750 @ 2.67GHz - 7968MB ram - fc18.x86_64 - Xfce 4.10

1323030803.png

Hors ligne

#334 11/06/2011 21:16:17

teutates
Membre
Lieu : Pyrénées
Inscription : 11/05/2006
Messages : 292
Site Web

Re : Conky - Partage de scripts

DiEOrLivE a écrit :

Salut teutates! Pour l'ip public je crois qu'il n'y a pas de variable. J'ais mis cela ->

${texeci 25000 dig +short myip.opendns.com @resolver1.opendns.com}

Je viens aussi de m'en rendre compte. J'abandonne cet aspect (qui ne constituait qu'un raccourci pour moi).

Voici donc une première capture de mon bureau sous Gnome3, avec AWN et Conky :
1307819241.png

Le conky de droite est quasi terminé ( une ou deux ch'tites retouches mineures à trouver). A gauche, je cherche à mettre un calendrier et la météo mais, outre que je dois tout faire côté météo, le trait en dessous du calendrier existant ne veut pas s'afficher. Mauvais script !

Le conky de droite :

# Installer conky
# Par défaut, le fichier de configuration est dans /etc/conky/*
# La commande "conky" lancera ce fichier de configuration non personnalisé.
# Copier dans /home/user sous le nom de .conkyrc
# Lancer manuellement en console avec : conky -c ~/.conky/conkyrc
# Régler les préférences des programmes démarrés automatiquement

# Position
alignment top_right
#alignment top_left
#alignment bottom_left
#alignment bottom_right
#alignment none
gap_x 72 # Espace par rapport au bord droit ou gauche
gap_y 40 # Espace par rapport au bord haut ou bas
minimum_size 350 800 # Largeur
maximum_width 500 1000 # Hauteur maxi

# Couleurs
default_color red
default_outline_color white
default_shade_color white
#7FFFD4 #Aquamarine
#CD5C5C #IndianRed 
#00CED1 DarkTurquoise 
#FFA07A LightSalmon 
#00FFFF Cyan 
#FF8C00 #Darkorange 
#D2691E #Chocolate
#7FFF00 #Chartreuse
#778899 #LightSlateGrey
#FFDEAD #NavajoWhite
#00BFFF #DeepSkyBlue        
#48D1CC #MediumTurquoise
#FFFF00 #Yellow
#FF0000 #Red

# Police
xftfont DejaVu Sans Mono:size=12
use_xft yes
uppercase no

#Type de fenetre
own_window yes
own_window_class Conky
own_window_transparent yes
own_window_type desktop
#own_window_type normal

# Arriere plan
background no

# Bordures
border_width 1
draw_borders no
draw_graph_borders yes
stippled_borders 0

# Ajout d'espaces pour éviter de laisser bouger des objets
# Ne fonctionne qu'avec la police monospace
use_spacer none


extra_newline no

# Contours
draw_outline no

# Ombre
draw_shades no

# Aspect graphes
show_graph_scale no
show_graph_range no

# Système
cpu_avg_samples 2
net_avg_samples 2
out_to_console no
out_to_stderr no

# Raffraichissement en seconde
update_interval 5

# Eviter le clignotement
no_buffers yes


TEXT
${color white}$hr
#$color  ${Time %a %d %b %Y}  ${color grey}| $color${Time %k:%M:%S}
#
#${alignc}${color #11B3F8}${curl http://www.fetedujour.fr/api/text 240}
#${color white}$hr
${color #00BFFF}${font bold:size=13}Système:${font}
${color grey}$sysname $kernel}$color
${color grey}Démarré depuis:$color $uptime
${color grey}Batterie:$color $battery_percent % - $acpiacadapter   ${color red}$battery_bar
#${alignc}${color red}$battery_time
${color white}$hr
${color #00BFFF}${font bold:size=13}Processeur:${font}
${color grey}Fréquence (MHz):$color $freq / ${color grey}(GHz):$color $freq_g
${color grey}CPU Usage:$color $cpu% ${cpubar 8}
${color red}${cpugraph red yellow}
${color grey}Température CPU: $color${hwmon temp 1} C°
#${color #FFFFFF}Core 1:${cpu cpu1}% ${cpubar cpu1 8,50}  ${color #FFFFFF}${alignr}Core 2:${cpu cpu2}% ${cpubar cpu2 8,50}
#${color #FFFFFF}Core 3:${cpu cpu3}% ${cpubar cpu3 8,50}  ${color #FFFFFF}${alignr}Core 4:${cpu cpu4}% ${cpubar cpu4 8,50}
#${color #FFFFFF}Core 5:${cpu cpu5}% ${cpubar cpu5 8,50}  ${color #FFFFFF}${alignr}Core 6:${cpu cpu6}% ${cpubar cpu6 8,50}
#${color #FFFFFF}Core 7:${cpu cpu7}% ${cpubar cpu7 8,50}  ${color #FFFFFF}${alignr}Core 8:${cpu cpu8}% ${cpubar cpu8 8,50}
${color white}$hr
${color #00BFFF}${font bold:size=13}Mémoire:${font}
${color grey}RAM Usage:$color $mem/$memmax  - ${alignr}$memperc%
${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}
${color grey}Processus:$color $processes  ${color grey}${alignr}En cours:$color $running_processes
${color white}$hr
${color #00BFFF}${font bold:size=13}Espace disques (Utilisé / Total):${font}
${color grey} /             ${color white}${font bold:size=10}${fs_used /} / ${fs_size /}${alignr}${fs_used_perc /}%${font} 
$color${fs_bar 4 /}
${color grey} Home          ${color white}${font bold:size=10}${fs_used /home} / ${fs_size /home}${alignr} ${fs_used_perc /home}%${font} 
$color${fs_bar 4 /home}
${color grey} Passerelle    ${color white}${font bold:size=10}${fs_used /media/Passerelle} / ${fs_size /media/Passerelle}${alignr} ${fs_used_perc /media/Passerelle}%${font} 
$color${fs_bar 4 /media/Passerelle}
${color grey} Data1         ${color white}${font bold:size=10}${fs_used /media/DATA1} / ${fs_size /media/DATA1} ${alignr}${fs_used_perc /media/DATA1}%${font} 
$color${fs_bar 4 /media/DATA1}
${color grey} Data2         ${color white}${font bold:size=10}${fs_used /media/DATA2} / ${fs_size /media/DATA2} ${alignr}${fs_used_perc /media/DATA2}%${font} 
$color${fs_bar 4 /media/DATA2}
#${color grey}Home       $color${fs_used /home}  ${color white}/ ${fs_size /home}  $color${fs_bar 6 /home}
#${color grey}Passerelle $color${fs_used  /media/Passerelle}  ${color white}/ ${fs_size /media/Passerelle} $color${fs_bar 6 /media/Passerelle}
#${color grey}Data1      $color${fs_used /media/DATA1}  ${color white}/ ${fs_size /media/DATA1}  $color${fs_bar 6 /media/DATA1}
#${color grey}Data2      $color${fs_used /media/DATA2}  ${color white}/ ${fs_size /media/DATA2}  $color${fs_bar 6 /media/DATA2}
${color white}$hr
${color #00BFFF}${font bold:size=13}Processus:     ${alignr}PID       ${alignr}CPU%   ${alignr}MEM%${font}
${color #ff4500} ${font size=6}${top name 1} ${alignr}${top pid 1}     ${alignr}${top cpu 1}     ${alignr}${top mem 1}${font}
${color yellow} ${font size=6}${top name 2} ${alignr}${top pid 2}     ${alignr}${top cpu 2}     ${alignr}${top mem 2}${font}
${color #FFA07A} ${font size=6}${top name 3} ${alignr}${top pid 3}     ${alignr}${top cpu 3}     ${alignr}${top mem 3}${font}
${color orange} ${font size=6}${top name 4} ${alignr}${top pid 4}     ${alignr}${top cpu 4}     ${alignr}${top mem 4}${font}
${color #CD5C5C} ${font size=6}${top name 5} ${alignr}${top pid 5}     ${alignr}${top cpu 5}     ${alignr}${top mem 5}${font}
${color white}$hr
${color #00BFFF}${font bold:size=13}En mémoire:    ${alignr}PID       ${alignr}CPU%   ${alignr}MEM%${font}
${color #ff4500} ${font size=6} ${top_mem name 1} ${alignr}${top_mem pid 1}    ${alignr}${top_mem cpu 1}      ${alignr}${top_mem mem 1}${font}
${color yellow} ${font size=6} ${top_mem name 2} ${alignr}${top_mem pid 2}    ${alignr}${top_mem cpu 2}      ${alignr}${top_mem mem 2}${font}
${color #CD5C5C} ${font size=6} ${top_mem name 3} ${alignr}${top_mem pid 3}    ${alignr}${top_mem cpu 3}      ${alignr}${top_mem mem 3}${font}
${color white}$hr
${color #00BFFF}${font bold:size=13}Réseau:${font}
#${color white}Passerelle : ${color green}${alignr}${gw_ip}
${color white}Publique : ${color green}$alignr${execi 3600 wget -O - http://ip.tupeux.com | tail}
${color grey}Reçu:   ${color red}${downspeed p16p1}kb/s ${alignr}${downspeedgraph p16p1 12,150 ffffff yellow}
${color grey}Envoyé: ${color red}${upspeed p16p1}kb/s ${alignr}${upspeedgraph p16p1 12,150 ffffff yellow}
${color white}${hr 4}
${alignc}${color #11B3F8}Conky $conky_version

Le conky de gauche (à modifier) :

# Installer conky
# Copier dans /home/user sous le nom de .conkyrc
# Lancer manuellement en console avec : conky -c ~/.conky/conkyrc2
# Régler les préférences des programmes démarrés automatiquement

# Position
#alignment top_right
alignment top_left
#alignment bottom_left
#alignment bottom_right
#alignment none
gap_x 72 # Espace par rapport au bord droit ou gauche
gap_y 40 # Espace par rapport au bord haut ou bas
minimum_size 350 800 # Largeur
maximum_width 500 1000 # Hauteur maxi

# Couleurs
default_color red
default_outline_color white
default_shade_color white
#7FFFD4 #Aquamarine
#CD5C5C #IndianRed 
#00CED1 DarkTurquoise 
#FFA07A LightSalmon 
#00FFFF Cyan 
#FF8C00 #Darkorange 
#D2691E #Chocolate
#7FFF00 #Chartreuse
#778899 #LightSlateGrey
#FFDEAD #NavajoWhite
#00BFFF #DeepSkyBlue        
#48D1CC #MediumTurquoise
#FFFF00 #Yellow
#FF0000 #Red

# Police
xftfont DejaVu Sans Mono:size=12
font2 DejaVu Sans Mono:size=15
use_xft yes
uppercase no

#Type de fenetre
own_window yes
own_window_class Conky
own_window_transparent yes
own_window_type desktop
#own_window_type normal

# Arriere plan
background no

# Bordures
border_width 1
draw_borders no
draw_graph_borders yes
stippled_borders 0

# Ajout d'espaces pour éviter de laisser bouger des objets
# Ne fonctionne qu'avec la police monospace
use_spacer none


extra_newline no

# Contours
draw_outline no

# Ombre
draw_shades no

# Aspect graphes
show_graph_scale no
show_graph_range no

# Système
cpu_avg_samples 2
net_avg_samples 2
out_to_console no
out_to_stderr no

# Raffraichissement en seconde
update_interval 5

# Eviter le clignotement
no_buffers yes


TEXT
${color white}$hr
${alignc}$color  ${Time %a %d %b %Y}  ${color grey}| $color${Time %k:%M:%S}

${alignc}${color #11B3F8}${curl http://www.fetedujour.fr/api/text 240}
${color white}$hr
${color #11B3F8}${font Bitstream Vera Sans Mono:size=18}
${execpi 60 DJS=`date +%_d`; cal | sed '/./!d' | sed 's/$/                     /' | fold -w 21 | sed -n '/^.\{21\}/p' | sed 's/^/${alignc} /' | sed /" $DJS "/s/" $DJS "/" "'${color   tan2}'"$DJS"'${color #11B3F8}'

${color white}$hr

Dernière modification par teutates (11/06/2011 21:48:22)


CM Asus P8Z68-V/GEN3 - CPU Intel i72700k - RAM G-Skill 4x4 Go PC 12800 - CG Gainward Geforce GTX 560 2 Go
DD Western Digital Velociraptor 300 Go Sata 3 + SSD 500 Go Sata 3 + Seagate Barracuda 2 To Sata 3 (x4) - Graveur DVD Asus DRW-24B3LT
Fedora 29 Plasma - Debian 9 Stretch Plasma

Hors ligne

#335 11/06/2011 23:38:09

teutates
Membre
Lieu : Pyrénées
Inscription : 11/05/2006
Messages : 292
Site Web

Re : Conky - Partage de scripts

Je n'ai pas trouvé comment lancer automatiquement conky sous Gnome3 automatiquement ; je n'ai pas trouvé d'accès aux programmes auto-démarrés.

J'ai créé le lanceur ci dessous :

#!/bin/sh
sleep 0
killall conky
env DISPLAY=:0.0 conky -c ~/.conky/conkyrc&

mais, outre que ce n'est pas automatique, l'effet n'est pas immédiat. ... Et ce n'est pas pratique sad

Dernière modification par teutates (12/06/2011 00:05:22)


CM Asus P8Z68-V/GEN3 - CPU Intel i72700k - RAM G-Skill 4x4 Go PC 12800 - CG Gainward Geforce GTX 560 2 Go
DD Western Digital Velociraptor 300 Go Sata 3 + SSD 500 Go Sata 3 + Seagate Barracuda 2 To Sata 3 (x4) - Graveur DVD Asus DRW-24B3LT
Fedora 29 Plasma - Debian 9 Stretch Plasma

Hors ligne

#336 12/06/2011 01:44:22

DiEOrLivE
Fedora Addict
Lieu : [fedora@quebec ~]$
Inscription : 29/10/2010
Messages : 544

Re : Conky - Partage de scripts

@teutates

$ gnome-session-properties

4 x Intel® Core™ i5 CPU 750 @ 2.67GHz - 7968MB ram - fc18.x86_64 - Xfce 4.10

1323030803.png

Hors ligne

#337 12/06/2011 18:37:20

teutates
Membre
Lieu : Pyrénées
Inscription : 11/05/2006
Messages : 292
Site Web

Re : Conky - Partage de scripts

DiEOrLivE a écrit :

@teutates

$ gnome-session-properties

C'est bon, à force !
Pour ceux qui chercheraient encore :
1) Ouvrir (depuis une console puisque non listé dans le menu des applications) : gnome-session-properties
2) Ajouter conky mais avec le chemin vers votre fichier personnalisé avec la syntaxe conky -c /home/user/.conky/conkyrc
Chez moi, ca donne : conky -c /home/Fedora/.conky/conkyrc

Pour lancer plusieurs instances de fichiers personnalisés, il faut créer un lanceur (lanceur.sh) avec des droits d'exécutables. Ce lanceur rassemblant tous les fichiers personnalisés. Et c'est le chemin vers ce lanceur qui devra être spécifié dans le chemin du programme ajouté au démarrage automatique.

Merci cool


CM Asus P8Z68-V/GEN3 - CPU Intel i72700k - RAM G-Skill 4x4 Go PC 12800 - CG Gainward Geforce GTX 560 2 Go
DD Western Digital Velociraptor 300 Go Sata 3 + SSD 500 Go Sata 3 + Seagate Barracuda 2 To Sata 3 (x4) - Graveur DVD Asus DRW-24B3LT
Fedora 29 Plasma - Debian 9 Stretch Plasma

Hors ligne

#338 13/06/2011 11:47:17

diarchen22
Membre
Inscription : 26/01/2011
Messages : 16

Re : Conky - Partage de scripts

ou bien il ya aussi une autre manière de lancer son conky . C'est de mettre par exemple conky -c /home/user/.conky/conkyrc dans le  .bash_profile

Hors ligne

#339 13/06/2011 11:55:23

coRe
Membre
Lieu : Lyon/Bordeaux
Inscription : 24/11/2007
Messages : 152

Re : Conky - Partage de scripts

Bonjour,
j'aurai des questions concernant l'utilisation objet NVIDIA dans conky:
j'ai commencé par installer la  libXNVCtrl:

 yum install libXNVCtrl.x86_64
Modules complémentaires chargés : langpacks, presto, refresh-packagekit, remove-
                                : with-leaves
Configuration du processus d'installation
Résolution des dépendances
--> Lancement de la transaction de test
---> Package libXNVCtrl.x86_64 0:169.12-5.fc15 will be installé
--> Résolution des dépendances terminée

Dépendances résolues

================================================================================
 Paquet             Architecture   Version                 Dépôt          Taille
================================================================================
Installation:
 libXNVCtrl         x86_64         169.12-5.fc15           fedora          20 k

Résumé de la transaction
================================================================================
Installation de     1 paquet(s)

Taille totale des téléchargements : 20 k
Taille d'installation : 40 k
Est-ce correct [o/N] : o
Téléchargement des paquets :
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 20 k
libXNVCtrl-169.12-5.fc15.x86_64.rpm                      |  20 kB     00:00     
Lancement de rpm_check_debug
Lancement de la transaction de test
Transaction de test réussie
Lancement de la transaction
  Installation  : libXNVCtrl-169.12-5.fc15.x86_64                           1/1 

Installé:
  libXNVCtrl.x86_64 0:169.12-5.fc15  

mais quand j'aoujoute une ligne pour afficher la température du GPU :

${color 0066FF}${nvidia temp}°

je n'est rien qui s'affiche.... qu'elle est la syntax pour appeller les données nvidia ?
Et une autre question pour la route, c'est pour le réseaux: Puis-je avoir l'ensemble des interfaces sur le même 'graph'/'compteur' comme sur le moniteur-system ??

Dernière modification par coRe (13/06/2011 12:05:26)


Fedora_x64 sur ASUS A8Sc 14"

Hors ligne

#340 13/06/2011 12:00:53

chepioq
FEDORA FOR EVER
Lieu : a l'est de marseille
Inscription : 07/06/2006
Messages : 7 286

Re : Conky - Partage de scripts

comment as tu installé le paquet conky ?
Si c'est par yum, ce paquet n'a pas l'option nvidia, pour l'avoir il faut le compiler à partir des sources avec l'option --enable nvidia.


Tout est dans tout... et réciproquement...
C'est quoi un chalumeau??? C'est un dromaludaire à deux bosses...
Quand le sage montre la lune l'imbécile regarde le doigt...
1277887812.gif

Hors ligne

#341 13/06/2011 12:07:52

coRe
Membre
Lieu : Lyon/Bordeaux
Inscription : 24/11/2007
Messages : 152

Re : Conky - Partage de scripts

@chepioq
Installer avec yum install, j'avais pas trop envie de me le compiler en fait !!
Donc s'il faut j'abandone l'idée de la temp. nvidia mais si je veux celle du processeur il me renvoit 0° ou N/A°...

${color 0066FF}${acpitemp}°

là il me renvoit 0°

${color 0066FF}${apcupsd_temp}°

et ici N/A°

Dernière modification par coRe (13/06/2011 12:11:57)


Fedora_x64 sur ASUS A8Sc 14"

Hors ligne

#342 13/06/2011 17:24:08

teutates
Membre
Lieu : Pyrénées
Inscription : 11/05/2006
Messages : 292
Site Web

Re : Conky - Partage de scripts

coRe a écrit :

@chepioq
Installer avec yum install, j'avais pas trop envie de me le compiler en fait !!
Donc s'il faut j'abandone l'idée de la temp. nvidia mais si je veux celle du processeur il me renvoit 0° ou N/A°...

${color 0066FF}${acpitemp}°

là il me renvoit 0°

${color 0066FF}${apcupsd_temp}°

et ici N/A°

Pour la température du CPU, j'ai utilisé :
${color grey}Température CPU: $color${hwmon temp 1} C°


CM Asus P8Z68-V/GEN3 - CPU Intel i72700k - RAM G-Skill 4x4 Go PC 12800 - CG Gainward Geforce GTX 560 2 Go
DD Western Digital Velociraptor 300 Go Sata 3 + SSD 500 Go Sata 3 + Seagate Barracuda 2 To Sata 3 (x4) - Graveur DVD Asus DRW-24B3LT
Fedora 29 Plasma - Debian 9 Stretch Plasma

Hors ligne

#343 13/06/2011 18:38:38

coRe
Membre
Lieu : Lyon/Bordeaux
Inscription : 24/11/2007
Messages : 152

Re : Conky - Partage de scripts

teutates a écrit :
coRe a écrit :

@chepioq
Installer avec yum install, j'avais pas trop envie de me le compiler en fait !!
Donc s'il faut j'abandone l'idée de la temp. nvidia mais si je veux celle du processeur il me renvoit 0° ou N/A°...

${color 0066FF}${acpitemp}°

là il me renvoit 0°

${color 0066FF}${apcupsd_temp}°

et ici N/A°

Pour la température du CPU, j'ai utilisé :
${color grey}Température CPU: $color${hwmon temp 1} C°

@teutates
yes, çà fonctionne merci. Donc à ma sauce çà donne:
${color 0066FF}${font Caviar Dreams:size=8}Température CPU: ${color FFFFFF}${hwmon temp 1} C°


Fedora_x64 sur ASUS A8Sc 14"

Hors ligne

#344 13/06/2011 20:12:37

chepioq
FEDORA FOR EVER
Lieu : a l'est de marseille
Inscription : 07/06/2006
Messages : 7 286

Re : Conky - Partage de scripts

Pour la température de ta carte nvidia, est ce que tu utilises les drivers nvidia ?
Dans ce cas tu peux récupérer la température avec nvidia-settings;

nvidia-settings -q GPUCoreTemp -t

Cela te renverra la température de ta carte, chez moi cela donne :

[dominique@localhost ~]$ nvidia-settings -q GPUCoreTemp -t
67

Dernière modification par chepioq (14/06/2011 06:31:32)


Tout est dans tout... et réciproquement...
C'est quoi un chalumeau??? C'est un dromaludaire à deux bosses...
Quand le sage montre la lune l'imbécile regarde le doigt...
1277887812.gif

Hors ligne

#345 14/06/2011 14:10:20

coRe
Membre
Lieu : Lyon/Bordeaux
Inscription : 24/11/2007
Messages : 152

Re : Conky - Partage de scripts

oui j'utilise le akmod-nvidia donc cette commande fonctionne très bien dans le terminal!
j'ai trouver pour l'intégrer à conky:
${color 0066FF}${font Caviar Dreams:size=8}Température GPU: ${color FFFFFF}${exec nvidia-settings -q GPUCoreTemp -t} C°

Et en plus c'est beau !!! hammer

Du coup merci bien !! pint Santé !! big_smile

Dernière modification par coRe (14/06/2011 14:14:52)


Fedora_x64 sur ASUS A8Sc 14"

Hors ligne

#346 14/06/2011 17:50:44

chepioq
FEDORA FOR EVER
Lieu : a l'est de marseille
Inscription : 07/06/2006
Messages : 7 286

Re : Conky - Partage de scripts

coRe a écrit :

${color 0066FF}${font Caviar Dreams:size=8}Température GPU: ${color FFFFFF}${exec nvidia-settings -q GPUCoreTemp -t} C°

Bon je pinaille surement (c'est du à mon passage dans l'équipe de traduction de fedora...), mais en français il y a un espace insécable avant les deux points... (et après aussi d’ailleurs.).
On m'en a fait la remarque tellement souvent, que je ne pouvais pas le laisser passer... lol lol lol


Tout est dans tout... et réciproquement...
C'est quoi un chalumeau??? C'est un dromaludaire à deux bosses...
Quand le sage montre la lune l'imbécile regarde le doigt...
1277887812.gif

Hors ligne

#347 19/06/2011 17:18:13

Tuny
Membre
Lieu : Mondonville (31)
Inscription : 23/11/2010
Messages : 329

Re : Conky - Partage de scripts

Ca c'est Shaiton qui t'as marqué lol


Python + Linux = power!!
"La plus grande source de bugs se trouve entre la chaise et le clavier" (à méditer)

Hors ligne

#348 20/06/2011 11:22:05

PapsOu
Developpeur PHP7 Symfony3
Rédacteur Wiki
Lieu : Quimper
Inscription : 27/11/2009
Messages : 1 849
Site Web

Re : Conky - Partage de scripts

Petit conky fait vite-fait :
1308561603.png

Le conky_rc :

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

own_window true
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,sticky,skip_taskbar,skip_pager,below

border_inner_margin 0
border_outer_margin 0
stippled_borders 0

minimum_size 1920 1080
maximum_width 1920
 
alignment top_right
gap_x 0
gap_y 0

draw_shades yes
default_shade_color 000000
draw_outline no
draw_borders no
draw_graph_borders no

use_xft yes
xftfont Geosans Light:size=10
xftalpha 0.4

lua_load ~/.conky/conky_PapsOu/conky.lua
lua_load ~/.conky/conky_PapsOu/conky_text.lua

lua_draw_hook_pre main_rings
lua_draw_hook_post draw_text

TEXT
${image ~/.conky/conky_PapsOu/bg.png -p 0,0 -f 86400}

Les anneaux lua :

require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={

    {
    --cpu1
    name="cpu",
    arg="cpu1",
    max=100,
    xc=100,
    yc=100,
    radius=25,
    thickness=5,
    start_angle=0,
    end_angle=360,
    sectors=20,
    inverse_arc=false,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },
    
    {
    --cpu2
    name="cpu",
    arg="cpu2",
    max=100,
    xc=150,
    yc=100,
    radius=25,
    thickness=5,
    start_angle=0,
    end_angle=360,
    sectors=20,
    inverse_arc=false,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },

    {
    --cpu3
    name="cpu",
    arg="cpu3",
    max=100,
    xc=100,
    yc=150,
    radius=25,
    thickness=5,
    start_angle=0,
    end_angle=360,
    sectors=20,
    inverse_arc=false,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },

    {
    --cpu4
    name="cpu",
    arg="cpu4",
    max=100,
    xc=150,
    yc=150,
    radius=25,
    thickness=5,
    start_angle=0,
    end_angle=360,
    sectors=20,
    inverse_arc=false,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },
    {
    --ram
    name="memperc",
    arg="",
    max=100,
    xc=125,
    yc=300,
    radius=50,
    thickness=10,
    start_angle=0,
    end_angle=360,
    sectors=20,
    inverse_arc=false,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },

    {
    --fs_used
    name="fs_used_perc",
    arg="/",
    max=100,
    xc=100,
    yc=450,
    radius=25,
    thickness=5,
    start_angle=0,
    end_angle=360,
    sectors=20,
    inverse_arc=false,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },

    {
    --fs_used
    name="fs_used_perc",
    arg="/home",
    max=100,
    xc=150,
    yc=450,
    radius=25,
    thickness=5,
    start_angle=0,
    end_angle=360,
    sectors=20,
    inverse_arc=false,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },
    {
    --download speed
    name="downspeedf",
    arg="p10p1",
    max=300,
    xc=120,
    yc=550,
    radius=50,
    thickness=10,
    start_angle=0,
    end_angle=-180,
    sectors=10,
    fill_sector=false,
    inverse_arc=true,
    gap_sectors=1,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },
    
    
    {
    --upload speed
    name="upspeedf",
    arg="p10p1",
    max=40,
    xc=130,
    yc=550,
    radius=50,
    thickness=10,
    start_angle=0,
    end_angle=180,
    sectors=10,
    fill_sector=false,
    gap_sectors=1,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },

    {
    --Top cpu 1
    name="top cpu",
    arg="1",
    max=100,
    xc=125,
    yc=700,
    radius=50,
    thickness=5,
    start_angle=0,
    end_angle=-270,
    sectors=15,
    inverse_arc=false,
    inverse_arc=true,
    gap_sectors=2,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },

    {
    --Top cpu 2
    name="top cpu",
    arg="2",
    max=100,
    xc=125,
    yc=700,
    radius=40,
    thickness=5,
    start_angle=0,
    end_angle=-270,
    sectors=15,
    inverse_arc=false,
    inverse_arc=true,
    gap_sectors=2,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
    },
    
    {
    --Top cpu 3
    name="top cpu",
    arg="3",
    max=100,
    xc=125,
    yc=700,
    radius=30,
    thickness=5,
    start_angle=0,
    end_angle=-270,
    sectors=15,
    inverse_arc=false,
    inverse_arc=true,
    gap_sectors=2,
    bg_colour1={{0,0x000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
    fg_colour1={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
    bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,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)
    cr=cairo_create(cs)

    if tonumber(conky_parse('${updates}'))>3 then
        for i in pairs(rings_settings) do
            draw_ring(rings_settings[i])
        end
    end

    cairo_destroy(cr)

end




function draw_ring(t)

    local function rgba_to_r_g_b_a(tcolour)
        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
    
    --initialize table
    setup(t)
    --[[grid
    h=conky_window.height
    w=conky_window.width
    cairo_set_source_rgba(cr,1,1,1,1)
    cairo_set_line_width(cr,0.5)
    cairo_move_to(cr,0,t.yc)
    cairo_line_to(cr,w,t.yc)
    cairo_stroke(cr)
    cairo_move_to(cr,t.xc,0)
    cairo_line_to(cr,t.xc,h)
    cairo_stroke(cr)
    cairo_move_to(cr,t.xc,t.yc)
    cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
    cairo_stroke(cr)
    cairo_move_to(cr,0,t.yc-t.radius)
    cairo_line_to(cr,w,t.yc-t.radius)
    cairo_stroke(cr)
    cairo_move_to(cr,0,t.yc-t.int_radius)
    cairo_line_to(cr,w,t.yc-t.int_radius)
    cairo_stroke(cr)
    cairo_move_to(cr,0,t.yc-t.gap_sectors)
    cairo_line_to(cr,w,t.yc-t.gap_sectors)
    cairo_stroke(cr)
    cairo_set_source_rgba(cr,1,0,0,0.5)
    cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
    cairo_stroke(cr)
    cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)    
    cairo_stroke(cr)    
    cairo_set_source_rgba(cr,0,1,0,1)    
    cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
    cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
    cairo_stroke(cr)
    --END GRID
    ]]
    
    --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 :
    angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
    --value of a sector : 
    valueA = t.max/t.sectors
    --first angle of a sector : 
    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 #
         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
        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 
        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
        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]]


function axis(ctx,alpha)
    cairo_set_line_width(ctx,1)
    cairo_set_source_rgba(ctx,1,0,0,alpha)
    cairo_move_to(ctx,0,0)
    cairo_line_to(ctx,150,0)
    cairo_stroke(ctx)
    cairo_set_source_rgba(ctx,0,1,0,alpha)
    cairo_move_to(ctx,0,0)
    cairo_line_to(ctx,0,150)
    cairo_stroke(ctx)
end

Les textes lua :

require 'cairo'
function conky_draw_text()
    --BEGIN OF PARAMETRES
    text_settings={

        {
            text=conky_parse("${cpu cpu1}"),
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
        v_align="m",
            bold=true,
            x=100,
            y=100,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${cpu cpu2}"),
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
        v_align="m",
            bold=true,
            x=150,
            y=100,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${cpu cpu3}"),
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
        v_align="m",
            bold=true,
            x=100,
            y=150,
            orientation="nn",
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${cpu cpu4}"),
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
        v_align="m",
            bold=true,
            x=150,
            y=150,
            orientation="nn",
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },     

        {
            text=conky_parse("$mem"),
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
            v_align="m",
            bold=true,
            orientation="nn",
            x=125,
            y=290,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

{
            text=conky_parse("$memmax"),
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
            v_align="m",
            bold=true,
            orientation="nn",
            x=125,
            y=310,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text="/",
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
            v_align="m",
            bold=true,
            orientation="nn",
            x=100,
            y=450,
            colour={{0,0X000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
        },

        {
            text="/home",
            font_name="Geosans Light",
            font_size=10,
            h_align="c",
            v_align="m",
            bold=true,
            orientation="nn",
            x=150,
            y=450,
            colour={{0,0X000000,1},{0.5,0x000000,1}, {1,0x000000,1}},
        },

        {
            text=conky_parse("${downspeedf p10p1} K/s"),
            font_name="Geosans Light",
            font_size=12,
            h_align="c",
            v_align="m",
            bold=true,
            x=100,
            y=550,
            angle=-90,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${upspeedf p10p1} K/s"),
            font_name="Geosans Light",
            font_size=12,
            h_align="c",
            v_align="m",
            bold=true,
            x=150,
            y=550,
            angle=90,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${top name 1}"),
            font_name="Geosans Light",
            font_size=10,
            h_align="l",
            bold=true,
            orientation="nn",
            angle=0,
            x=130,
            y=655,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },    

        {
            text=conky_parse("${top name 2}"),
            font_name="Geosans Light",
            font_size=10,
            h_align="l",
            bold=true,
            orientation="nn",
            angle=0,
            x=130,
            y=665,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },    

        {
            text=conky_parse("${top name 3}"),
            font_name="Geosans Light",
            font_size=10,
            h_align="l",
            bold=true,
            orientation="nn",
            angle=0,
            x=130,
            y=675,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

    }
    
    
--------------END OF PARAMETERES----------------
    if conky_window == nil then return end
    if tonumber(conky_parse("$updates"))<3 then return end
       
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)

    for i,v in pairs(text_settings) do    
        cr = cairo_create (cs)
        display_text(v)
        cairo_destroy(cr)
    end
    
    cairo_surface_destroy(cs)
    


end

function rgb_to_r_g_b2(tcolour)
    colour,alpha=tcolour[2],tcolour[3]
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function display_text(t)

    local function set_pattern()
        --this function set the pattern
        if #t.colour==1 then 
            cairo_set_source_rgba(cr,rgb_to_r_g_b2(t.colour[1]))
        else
            local pat
            
            if t.radial==nil then
                local pts=linear_orientation(t,te)
                pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
            else
                pat = cairo_pattern_create_radial (t.radial[1],t.radial[2],t.radial[3],t.radial[4],t.radial[5],t.radial[6])
            end
        
            for i=1, #t.colour do
                cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgb_to_r_g_b2(t.colour[i]))
            end
            cairo_set_source (cr, pat)
        end
    end
    
    --set default values if needed
    if t.text==nil then t.text="Conky is good for you !" end
    if t.x==nil then t.x = conky_window.width/2 end
    if t.y==nil then t.y = conky_window.height/2 end
    if t.colour==nil then t.colour={{1,0xFFFFFF,1}} end
    if t.font_name==nil then t.font_name="Free Sans" end
    if t.font_size==nil then t.font_size=14 end
    if t.angle==nil then t.angle=0 end
    if t.italic==nil then t.italic=false end
    if t.oblique==nil then t.oblique=false end
    if t.bold==nil then t.bold=false end
    if t.radial ~= nil then
        if #t.radial~=6 then 
            print ("error in radial table")
            t.radial=nil 
        end
    end
    if t.orientation==nil then t.orientation="ww" end
    if t.h_align==nil then t.h_align="l" end
    if t.v_align==nil then t.v_align="b" end    
    if t.reflection_alpha == nil then t.reflection_alpha=0 end
    if t.reflection_length == nil then t.reflection_length=1 end
    if t.reflection_scale == nil then t.reflection_scale=1 end
    if t.skew_x==nil then t.skew_x=0 end
    if t.skew_y==nil then t.skew_y=0 end    
    cairo_translate(cr,t.x,t.y)
    cairo_rotate(cr,t.angle*math.pi/180)
    cairo_save(cr)       
     
 

    local slant = CAIRO_FONT_SLANT_NORMAL
    local weight =CAIRO_FONT_WEIGHT_NORMAL
    if t.italic then slant = CAIRO_FONT_SLANT_ITALIC end
    if t.oblique then slant = CAIRO_FONT_SLANT_OBLIQUE end
    if t.bold then weight = CAIRO_FONT_WEIGHT_BOLD end
    
    cairo_select_font_face(cr, t.font_name, slant,weight)
 
    for i=1, #t.colour do    
        if #t.colour[i]~=3 then 
            print ("error in color table")
            t.colour[i]={1,0xFFFFFF,1} 
        end
    end

    local matrix0 = cairo_matrix_t:create()
    skew_x,skew_y=t.skew_x/t.font_size,t.skew_y/t.font_size
    cairo_matrix_init (matrix0, 1,skew_y,skew_x,1,0,0)
    cairo_transform(cr,matrix0)
    cairo_set_font_size(cr,t.font_size)
    te=cairo_text_extents_t:create()
    cairo_text_extents (cr,t.text,te)
    
    set_pattern()


            
    mx,my=0,0
    
    if t.h_align=="c" then
        mx=-te.width/2
    elseif t.h_align=="r" then
        mx=-te.width
    end
    if t.v_align=="m" then
        my=-te.height/2-te.y_bearing
    elseif t.v_align=="t" then
        my=-te.y_bearing
    end
    cairo_move_to(cr,mx,my)
    
    cairo_show_text(cr,t.text)

     
        
        
   if t.reflection_alpha ~= 0 then 
        local matrix1 = cairo_matrix_t:create()
        cairo_set_font_size(cr,t.font_size)

        cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(te.height+te.y_bearing+my)*(1+t.reflection_scale))
        cairo_set_font_size(cr,t.font_size)
        te=cairo_text_extents_t:create()
        cairo_text_extents (cr,t.text,te)
        
                
        cairo_transform(cr,matrix1)
        set_pattern()
        cairo_move_to(cr,mx,my)
        cairo_show_text(cr,t.text)

        local pat2 = cairo_pattern_create_linear (0,
                                        (te.y_bearing+te.height+my),
                                        0,
                                        te.y_bearing+my)
        cairo_pattern_add_color_stop_rgba (pat2, 0,1,0,0,1-t.reflection_alpha)
        cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)    
        
        
        cairo_set_line_width(cr,1)
        dy=te.x_bearing
        if dy<0 then dy=dy*(-1) end
        cairo_rectangle(cr,mx+te.x_bearing,te.y_bearing+te.height+my,te.width+dy,-te.height*1.05)
        cairo_clip_preserve(cr)
        cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
        --cairo_stroke(cr)
        cairo_mask(cr,pat2)
        cairo_pattern_destroy(pat2)
        cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
    end
    
end


function linear_orientation(t,te)
    local w,h=te.width,te.height
    local xb,yb=te.x_bearing,te.y_bearing
    
    if t.h_align=="c" then
        xb=xb-w/2
    elseif t.h_align=="r" then
        xb=xb-w
       end    
    if t.v_align=="m" then
        yb=-h/2
    elseif t.v_align=="t" then
        yb=0
       end    
       
    if t.orientation=="nn" then
        p={xb+w/2,yb,xb+w/2,yb+h}
    elseif t.orientation=="ne" then
        p={xb+w,yb,xb,yb+h}
    elseif t.orientation=="ww" then
        p={xb,h/2,xb+w,h/2}
    elseif vorientation=="se" then
        p={xb+w,yb+h,xb,yb}
    elseif t.orientation=="ss" then
        p={xb+w/2,yb+h,xb+w/2,yb}
    elseif vorientation=="ee" then
        p={xb+w,h/2,xb,h/2}        
    elseif t.orientation=="sw" then
        p={xb,yb+h,xb+w,yb}
    elseif t.orientation=="nw" then
        p={xb,yb,xb+w,yb+h}
    end
    return p
end

et le background :
1308561768.png

Dernière modification par PapsOu (20/06/2011 11:23:15)

Hors ligne

#349 29/06/2011 03:07:30

PapsOu
Developpeur PHP7 Symfony3
Rédacteur Wiki
Lieu : Quimper
Inscription : 27/11/2009
Messages : 1 849
Site Web

Re : Conky - Partage de scripts

Mon dernier conky plus sobre, plus en adéquation avec le thème utilisé pour gnome-shell.
1309309488.png

conky_rc

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

own_window true
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,sticky,skip_taskbar,skip_pager,below

border_inner_margin 0
border_outer_margin 0
stippled_borders 0

minimum_size 1920 1080
maximum_width 1920
 
alignment top_left
gap_x 0
gap_y 0

draw_shades yes
default_shade_color 000000
draw_outline no
draw_borders no
draw_graph_borders no

use_xft yes
xftfont Geosans Light:size=10
xftalpha 1

lua_load ~/.conky/conky_bar/conky_bar.lua
lua_load ~/.conky/conky_bar/conky_bar_txt.lua

lua_draw_hook_pre main_bars
lua_draw_hook_post draw_text

TEXT
${image ~/.conky/conky_bar/bg.png -p 0,0 -f 86400}

conky_bar.lua

--[[ BARGRAPH WIDGET
    v2.1 by wlourf (07 Jan. 2011)
    this widget draws a bargraph with different effects 
    http://u-scripts.blogspot.com/2010/07/bargraph-widget.html
    
To call the script in a conky, use, before TEXT
    lua_load /path/to/the/script/bargraph.lua
    lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT

    
Parameters are :
3 parameters are mandatory
name    - the name of the conky variable to display, for example for {$cpu cpu0}, just write name="cpu"
arg        - the argument of the above variable, for example for {$cpu cpu0}, just write arg="cpu0"
          arg can be a numerical value if name=""
max        - the maximum value the above variable can reach, for example, for {$cpu cpu0}, just write max=100
    
Optional parameters:
x,y        - coordinates of the starting point of the bar, default = middle of the conky window
cap        - end of cap line, ossibles values are r,b,s (for round, butt, square), default="b"
          http://www.cairographics.org/samples/set_line_cap/
angle    - angle of rotation of the bar in degress, default = 0 (i.e. a vertical bar)
          set to 90 for an horizontal bar
skew_x    - skew bar around x axis, default = 0
skew_y    - skew bar around y axis, default = 0
blocks  - number of blocks to display for a bar (values >0) , default= 10
height    - height of a block, default=10 pixels
width    - width of a block, default=20 pixels
space    - space between 2 blocks, default=2 pixels
angle_bar    - this angle is used to draw a bar on a circular way (ok, this is no more a bar !) default=0
radius        - for cicular bars, internal radius, default=0
              with radius, parameter width has no more effect.

Colours below are defined into braces {colour in hexadecimal, alpha}
fg_colour    - colour of a block ON, default= {0x00FF00,1}
bg_colour    - colour of a block OFF, default = {0x00FF00,0.5}
alarm        - threshold, values after this threshold will use alarm_colour colour , default=max
alarm_colour - colour of a block greater than alarm, default=fg_colour
smooth        - (true or false), create a gradient from fg_colour to bg_colour, default=false 
mid_colour    - colours to add to gradient, with this syntax {position into the gradient (0 to1), colour hexa, alpha}
              for example, this table {{0.25,0xff0000,1},{0.5,0x00ff00,1},{0.75,0x0000ff,1}} will add
              3 colurs to gradient created by fg_colour and alarm_colour, default=no mid_colour
led_effect    - add LED effects to each block, default=no led_effect
              if smooth=true, led_effect is not used
              possibles values : "r","a","e" for radial, parallelel, perdendicular to the bar (just try!)
              led_effect has to be used with theses colours :
fg_led        - middle colour of a block ON, default = fg_colour
bg_led        - middle colour of a block OFF, default = bg_colour
alarm_led    - middle colour of a block > ALARM,  default = alarm_colour

reflection parameters, not avaimable for circular bars
reflection_alpha    - add a reflection effect (values from 0 to 1) default = 0 = no reflection
                      other values = starting opacity
reflection_scale    - scale of the reflection (default = 1 = height of text)
reflection_length   - length of reflection, define where the opacity will be set to zero
                      calues from 0 to 1, default =1
reflection            - position of reflection, relative to a vertical bar, default="b"
                      possibles values are : "b","t","l","r" for bottom, top, left, right
draw_me     - if set to false, text is not drawn (default = true or 1)
              it can be used with a conky string, if the string returns 1, the text is drawn :
              example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",

v1.0 (10 Feb. 2010) original release
v1.1 (13 Feb. 2010) numeric values can be passed instead conky stats with parameters name="", arg = numeric_value    
v1.2 (28 Feb. 2010) just renamed the widget to bargraph
v1.3 (03 Mar. 2010) added parameters radius & angle_bar to draw the bar in a circular way
v2.0 (12 Jul. 2010) rewrite script + add reflection effects and parameters are now set into tables
v2.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"

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

]]

require 'cairo'

----------------START OF PARAMETERS ----------
function conky_main_bars()
    local bars_settings={    
        {
            name="cpu",
            arg="cpu1",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=60,
            angle=90,
            blocks=50,
            height=2,width=6,
            space=1,
            draw_me=true,
            
        },    
        {
            name="cpu",
            arg="cpu2",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=70,
            angle=90,
            blocks=50,
            height=2,width=6,
            space=1,
            draw_me=true,
        },

        {
            name="cpu",
            arg="cpu3",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=80,
            angle=90,
            blocks=50,
            height=2,width=6,
            space=1,
            draw_me=true,
        },

        {
            name="cpu",
            arg="cpu4",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=90,
            angle=90,
            blocks=50,
            height=2,width=6,
            space=1,
            draw_me=true,
        },    
            
        {
            name="fs_used_perc",
            arg="/",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=130,
            angle=90,
            blocks=40,
            height=2,width=6,
            space=1,
            draw_me=true,
        },    

        {
            name="fs_used_perc",
            arg="/home",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=141,
            angle=90,
            blocks=40,
            height=2,width=6,
            space=1,
            draw_me=true,
        },    

        {
            name="memperc",
            arg="",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.15},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=11,y=155,
            angle=90,
            blocks=24,
            height=4,width=8,
            space=1,
            draw_me=true,
        },        

        {
            name="downspeedf",
            arg="p10p1",
            max=300,
            alarm=250,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xFF0000,1},
            blocks=50,
            x=10,y=190,
            height=2,width=6,
            space=1,
            angle=90,
            draw_me=true,
        },        
            
        {
            name="upspeedf",
            arg="p10p1",
            max=30,
            alarm=25,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xFF0000,1},
            blocks=50,
            x=10,y=200,
            height=2,width=6,    
            space=1,
            angle=90,
            draw_me=true,
        },    

        {
            name="top cpu 1",
            arg="/home",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=231,
            angle=90,
            blocks=40,
            height=2,width=6,
            space=1,
            draw_me=true,
        },
        {
            name="top cpu 2",
            arg="/home",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=241,
            angle=90,
            blocks=40,
            height=2,width=6,
            space=1,
            draw_me=true,
        },
        {
            name="top cpu 3",
            arg="/home",
            max=100,
            alarm=80,
            bg_colour={0x000000,0.25},
            fg_colour={0xffffff,1},
            alarm_colour={0xff0000,1},
            x=10,y=251,
            angle=90,
            blocks=40,
            height=2,width=6,
            space=1,
            draw_me=true,
        },                
    }
    
-----------END OF PARAMETERS--------------


    
    if conky_window == nil then return end
    
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    
    cr = cairo_create(cs)    
    --prevent segmentation error when reading cpu state
    if tonumber(conky_parse('${updates}'))>3 then
        for i in pairs(bars_settings) do
            
            draw_multi_bar_graph(bars_settings[i])
            
        end
    end
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil

end



function draw_multi_bar_graph(t)
    cairo_save(cr)
    --check values
    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    
    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'")
        return
    end
    if t.name==nil then t.name="" end
    if t.arg==nil then t.arg="" end

    --set default values    
    if t.x == nil        then t.x = conky_window.width/2 end
    if t.y == nil        then t.y = conky_window.height/2 end
    if t.blocks == nil    then t.blocks=10 end
    if t.height == nil    then t.height=10 end
    if t.angle == nil     then t.angle=0 end
    t.angle = t.angle*math.pi/180
    --line cap style
    if t.cap==nil        then t.cap = "b" end
    local cap="b"
    for i,v in ipairs({"s","r","b"}) do 
        if v==t.cap then cap=v end
    end
    local delta=0
    if t.cap=="r" or t.cap=="s" then delta = t.height end
    if cap=="s" then     cap = CAIRO_LINE_CAP_SQUARE
    elseif cap=="r" then
        cap = CAIRO_LINE_CAP_ROUND
    elseif cap=="b" then
        cap = CAIRO_LINE_CAP_BUTT
    end
    --end line cap style
    --if t.led_effect == nil    then t.led_effect="r" end
    if t.width == nil    then t.width=20 end
    if t.space == nil    then t.space=2 end
    if t.radius == nil    then t.radius=0 end
    if t.angle_bar == nil    then t.angle_bar=0 end
    t.angle_bar = t.angle_bar*math.pi/360 --halt angle
    
    --colours
    if t.bg_colour == nil     then t.bg_colour = {0x00FF00,0.5} end
    if #t.bg_colour~=2         then t.bg_colour = {0x00FF00,0.5} end
    if t.fg_colour == nil     then t.fg_colour = {0x00FF00,1} end
    if #t.fg_colour~=2         then t.fg_colour = {0x00FF00,1} end
    if t.alarm_colour == nil     then t.alarm_colour = t.fg_colour end
    if #t.alarm_colour~=2         then t.alarm_colour = t.fg_colour end

    if t.mid_colour ~= nil then    
        for i=1, #t.mid_colour do    
            if #t.mid_colour[i]~=3 then 
                print ("error in mid_color table")
                t.mid_colour[i]={1,0xFFFFFF,1} 
            end
        end
    end
    
    if t.bg_led ~= nil and #t.bg_led~=2    then t.bg_led = t.bg_colour end
    if t.fg_led ~= nil and #t.fg_led~=2    then t.fg_led = t.fg_colour end
    if t.alarm_led~= nil and #t.alarm_led~=2 then t.alarm_led = t.fg_led end
    
    if t.led_effect~=nil then
        if t.bg_led == nil then t.bg_led = t.bg_colour end
        if t.fg_led == nil     then t.fg_led = t.fg_colour end
        if t.alarm_led == nil  then t.alarm_led = t.fg_led end
    end
    

    if t.alarm==nil then t.alarm = t.max end --0.8*t.max end
    if t.smooth == nil then t.smooth = false end

    if t.skew_x == nil then 
        t.skew_x=0 
    else
        t.skew_x = math.pi*t.skew_x/180    
    end
    if t.skew_y == nil then 
        t.skew_y=0
    else
        t.skew_y = math.pi*t.skew_y/180    
    end
    
    if t.reflection_alpha==nil then t.reflection_alpha=0 end
    if t.reflection_length==nil then t.reflection_length=1 end
    if t.reflection_scale==nil then t.reflection_scale=1 end
    
    --end of default values
    

     local function rgb_to_r_g_b(col_a)
        return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
    end
    
    
    --functions used to create patterns

    local function create_smooth_linear_gradient(x0,y0,x1,y1)
        local pat = cairo_pattern_create_linear (x0,y0,x1,y1)
        cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
        cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
        if t.mid_colour ~=nil then
            for i=1, #t.mid_colour do
                cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
            end
        end
        return pat
    end

    local function create_smooth_radial_gradient(x0,y0,r0,x1,y1,r1)
        local pat =  cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
        cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
        cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
        if t.mid_colour ~=nil then
            for i=1, #t.mid_colour do
                cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
            end
        end
        return pat
    end
    
    local function create_led_linear_gradient(x0,y0,x1,y1,col_alp,col_led)
        local pat = cairo_pattern_create_linear (x0,y0,x1,y1) ---delta, 0,delta+ t.width,0)
        cairo_pattern_add_color_stop_rgba (pat, 0.0, rgb_to_r_g_b(col_alp))
        cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
        cairo_pattern_add_color_stop_rgba (pat, 1.0, rgb_to_r_g_b(col_alp))
        return pat
    end

    local function create_led_radial_gradient(x0,y0,r0,x1,y1,r1,col_alp,col_led,mode)
        local pat = cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
        if mode==3 then
            cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_alp))                
            cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
            cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))                
        else
            cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_led))
            cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))                
        end
        return pat
    end






    local function draw_single_bar()
        --this fucntion is used for bars with a single block (blocks=1) but 
        --the drawing is cut in 3 blocks : value/alarm/background
        --not zvzimzblr for circular bar
        local function create_pattern(col_alp,col_led,bg)
            local pat
            
            if not t.smooth then
                if t.led_effect=="e" then
                    pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
                elseif t.led_effect=="a" then
                    pat = create_led_linear_gradient (t.width/2, 0,t.width/2,-t.height,col_alp,col_led)
                elseif  t.led_effect=="r" then
                    pat = create_led_radial_gradient (t.width/2, -t.height/2, 0, t.width/2,-t.height/2,t.height/1.5,col_alp,col_led,2)
                else
                    pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(col_alp))
                end
            else
                if bg then
                    pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(t.bg_colour))
                else
                    pat = create_smooth_linear_gradient(t.width/2, 0, t.width/2,-t.height)
                end
            end
            return pat
        end
        
        local y1=-t.height*pct/100
        local y2,y3
        if pct>(100*t.alarm/t.max) then 
            y1 = -t.height*t.alarm/100
            y2 = -t.height*pct/100
            if t.smooth then y1=y2 end
        end
        
        if t.angle_bar==0 then
        
            --block for fg value
            local pat = create_pattern(t.fg_colour,t.fg_led,false)
            cairo_set_source(cr,pat)
            cairo_rectangle(cr,0,0,t.width,y1)
            cairo_fill(cr)
            cairo_pattern_destroy(pat)
        
            -- block for alarm value            
            if not t.smooth and y2 ~=nil then 
                pat = create_pattern(t.alarm_colour,t.alarm_led,false)
                cairo_set_source(cr,pat)
                cairo_rectangle(cr,0,y1,t.width,y2-y1)
                cairo_fill(cr)
                y3=y2
                cairo_pattern_destroy(pat)
            else
                y2,y3=y1,y1
            end
            -- block for bg value
            cairo_rectangle(cr,0,y2,t.width,-t.height-y3)
            pat = create_pattern(t.bg_colour,t.bg_led,true)
            cairo_set_source(cr,pat)
            cairo_pattern_destroy(pat)
            cairo_fill(cr)
        end        
    end  --end single bar
    





    local function draw_multi_bar()
        --function used for bars with 2 or more blocks
        for pt = 1,t.blocks do 
            --set block y
            local y1 = -(pt-1)*(t.height+t.space)
            local light_on=false
            
            --set colors
            local col_alp = t.bg_colour
            local col_led = t.bg_led
            if pct>=(100/t.blocks) or pct>0 then --ligth on or not the block
                if pct>=(pcb*(pt-1))  then 
                    light_on = true
                    col_alp = t.fg_colour
                    col_led = t.fg_led
                    if pct>=(100*t.alarm/t.max) and (pcb*pt)>(100*t.alarm/t.max) then 
                        col_alp = t.alarm_colour 
                        col_led = t.alarm_led 
                    end
                end
            end

            --set colors
            --have to try to create gradients outside the loop ?
            local pat 
            
            if not t.smooth then
                if t.angle_bar==0 then
                    if t.led_effect=="e" then
                        pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
                    elseif t.led_effect=="a" then
                        pat = create_led_linear_gradient (t.width/2, -t.height/2+y1,t.width/2,0+t.height/2+y1,col_alp,col_led)                    
                    elseif  t.led_effect=="r" then
                        pat = create_led_radial_gradient (t.width/2, y1, 0, t.width/2,y1,t.width/1.5,col_alp,col_led,2)    
                    else
                        pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(col_alp))
                    end
                else
                     if t.led_effect=="a"  then
                         pat = create_led_radial_gradient (0, 0, t.radius+(t.height+t.space)*(pt-1),
                                                         0, 0, t.radius+(t.height+t.space)*(pt),                         
                                             col_alp,col_led,3)    
                    else
                        pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(col_alp))                    
                    end
                    
                end
            else
                
                if light_on then
                    if t.angle_bar==0 then
                        pat = create_smooth_linear_gradient(t.width/2, t.height/2, t.width/2,-(t.blocks-0.5)*(t.height+t.space))
                    else
                        pat = create_smooth_radial_gradient(0, 0, (t.height+t.space),  0,0,(t.blocks+1)*(t.height+t.space),2)
                    end
                else        
                    pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(t.bg_colour))
                end
            end
            cairo_set_source (cr, pat)
            cairo_pattern_destroy(pat)

            --draw a block
            if t.angle_bar==0 then
                cairo_move_to(cr,0,y1)
                cairo_line_to(cr,t.width,y1)
            else        
                cairo_arc( cr,0,0,
                    t.radius+(t.height+t.space)*(pt)-t.height/2,
                     -t.angle_bar -math.pi/2 ,
                     t.angle_bar -math.pi/2)
            end
            cairo_stroke(cr)
        end    
    end
    
    
    
    
    local function setup_bar_graph()
        --function used to retrieve the value to display and to set the cairo structure
        if t.blocks ~=1 then t.y=t.y-t.height/2 end
        
        local value = 0
        if t.name ~="" then
            value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
            --$to_bytes doesn't work when value has a decimal point,
            --https://garage.maemo.org/plugins/ggit/browse.php/?p=monky;a=commitdiff;h=174c256c81a027a2ea406f5f37dc036fac0a524b;hp=d75e2db5ed3fc788fb8514121f67316ac3e5f29f
            --http://sourceforge.net/tracker/index.php?func=detail&aid=3000865&group_id=143975&atid=757310
            --conky bug?
            --value = (conky_parse(string.format('${%s %s}', t.name, t.arg)))
            --if string.match(value,"%w") then
            --    value = conky_parse(string.format('${to_bytes %s}',value))
            --end
        else
            value = tonumber(t.arg)
        end

        if value==nil then value =0 end
        
        pct = 100*value/t.max
        pcb = 100/t.blocks
        
        cairo_set_line_width (cr, t.height)
        cairo_set_line_cap  (cr, cap)
        cairo_translate(cr,t.x,t.y)
        cairo_rotate(cr,t.angle)

        local matrix0 = cairo_matrix_t:create()
        tolua.takeownership(matrix0)
        cairo_matrix_init (matrix0, 1,t.skew_y,t.skew_x,1,0,0)
        cairo_transform(cr,matrix0)

    
        
        --call the drawing function for blocks
        if t.blocks==1 and t.angle_bar==0 then
            draw_single_bar()
            if t.reflection=="t" or t.reflection=="b" then cairo_translate(cr,0,-t.height) end
        else
            draw_multi_bar()
        end

        --dot for reminder
        --[[
        if t.blocks ~=1 then
            cairo_set_source_rgba(cr,1,0,0,1)
            cairo_arc(cr,0,t.height/2,3,0,2*math.pi)
            cairo_fill(cr)
        else
            cairo_set_source_rgba(cr,1,0,0,1)
            cairo_arc(cr,0,0,3,0,2*math.pi)
            cairo_fill(cr)
        end]]
        
        --call the drawing function for reflection and prepare the mask used        
        if t.reflection_alpha>0 and t.angle_bar==0 then
            local pat2
            local matrix1 = cairo_matrix_t:create()
            tolua.takeownership(matrix1)
            if t.angle_bar==0 then
                pts={-delta/2,(t.height+t.space)/2,t.width+delta,-(t.height+t.space)*(t.blocks)}
                if t.reflection=="t" then
                    cairo_matrix_init (matrix1,1,0,0,-t.reflection_scale,0,-(t.height+t.space)*(t.blocks-0.5)*2*(t.reflection_scale+1)/2)
                    pat2 = cairo_pattern_create_linear (t.width/2,-(t.height+t.space)*(t.blocks),t.width/2,(t.height+t.space)/2)
                elseif t.reflection=="r" then
                    cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,delta+2*t.width,0)
                    pat2 = cairo_pattern_create_linear (delta/2+t.width,0,-delta/2,0)
                elseif t.reflection=="l" then
                    cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,-delta,0)
                    pat2 = cairo_pattern_create_linear (-delta/2,0,delta/2+t.width,-0)
                else --bottom
                    cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(t.height+t.space)*(t.reflection_scale+1)/2)
                    pat2 = cairo_pattern_create_linear (t.width/2,(t.height+t.space)/2,t.width/2,-(t.height+t.space)*(t.blocks))
                end
            end
            cairo_transform(cr,matrix1)

            if t.blocks==1 and t.angle_bar==0 then
                draw_single_bar()
                cairo_translate(cr,0,-t.height/2) 
            else
                draw_multi_bar()
            end
            
            
            cairo_set_line_width(cr,0.01)
            cairo_pattern_add_color_stop_rgba (pat2, 0,0,0,0,1-t.reflection_alpha)
            cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)
            if t.angle_bar==0 then
                cairo_rectangle(cr,pts[1],pts[2],pts[3],pts[4])
            end
            cairo_clip_preserve(cr)
            cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
            cairo_stroke(cr)
            cairo_mask(cr,pat2)
            cairo_pattern_destroy(pat2)
            cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
            
        end --reflection
        pct,pcb=nil
    end --setup_bar_graph()
    
    --start here !
    setup_bar_graph()
    cairo_restore(cr)
end

conky_bar_txt.lua

require 'cairo'
function conky_draw_text()
    --BEGIN OF PARAMETRES
    text_settings={


        {
            text=conky_parse("${exec cat /etc/fedora-release}"),
            font_name="MgOpen Modata",
            font_size=16,
            h_align="l",
        bold=true,
            x=5,
            y=25,
            colour={{0,0X4D4D4D,1},{0.5,0x4D4D4D,1}, {1,0x4D4D4D,1}},
        },
        {
            text=conky_parse("${KERNEL} | ${uptime}"),
            font_name="MgOpen Modata",
            font_size=11,
            h_align="l",
            x=15,
            y=42,
            colour={{0,0X4D4D4D,1},{0.5,0x4D4D4D,1}, {1,0x4D4D4D,1}},
        },

        {
            text=conky_parse("Core 1 - ${cpu cpu1} %"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=165,
            y=65,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("Core 2 - ${cpu cpu2} %"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=165,
            y=76,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("Core 3 - ${cpu cpu3} %"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=165,
            y=87,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("Core 4 - ${cpu cpu4} %"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=165,
            y=98,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("/         - ${fs_used /}"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=140,
            y=136,
            orientation="nn",
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("/home  - ${fs_used /home}"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=140,
            y=147,
            orientation="nn",
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },     

        {
            text=conky_parse("RAM  - $mem"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            orientation="nn",
            x=140,
            y=162,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${downspeedf p10p1} K/s"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=170,
            y=195,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${upspeedf p10p1} K/s"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            x=170,
            y=207,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },

        {
            text=conky_parse("${top name 1}"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            orientation="nn",
            x=140,
            y=234,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },    

        {
            text=conky_parse("${top name 2}"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            orientation="nn",
            x=140,
            y=246,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },
        {
            text=conky_parse("${top name 3}"),
            font_name="Geosans Light",
            font_size=11,
            h_align="l",
            orientation="nn",
            x=140,
            y=258,
            colour={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFFFFF,1}},
        },    

    }
    
    
--------------END OF PARAMETERES----------------
    if conky_window == nil then return end
    if tonumber(conky_parse("$updates"))<3 then return end
       
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)

    for i,v in pairs(text_settings) do    
        cr = cairo_create (cs)
        display_text(v)
        cairo_destroy(cr)
    end
    
    cairo_surface_destroy(cs)
    


end

function rgb_to_r_g_b2(tcolour)
    colour,alpha=tcolour[2],tcolour[3]
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function display_text(t)

    local function set_pattern()
        --this function set the pattern
        if #t.colour==1 then 
            cairo_set_source_rgba(cr,rgb_to_r_g_b2(t.colour[1]))
        else
            local pat
            
            if t.radial==nil then
                local pts=linear_orientation(t,te)
                pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
            else
                pat = cairo_pattern_create_radial (t.radial[1],t.radial[2],t.radial[3],t.radial[4],t.radial[5],t.radial[6])
            end
        
            for i=1, #t.colour do
                cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgb_to_r_g_b2(t.colour[i]))
            end
            cairo_set_source (cr, pat)
        end
    end
    
    --set default values if needed
    if t.text==nil then t.text="Conky is good for you !" end
    if t.x==nil then t.x = conky_window.width/2 end
    if t.y==nil then t.y = conky_window.height/2 end
    if t.colour==nil then t.colour={{1,0xFFFFFF,1}} end
    if t.font_name==nil then t.font_name="Free Sans" end
    if t.font_size==nil then t.font_size=14 end
    if t.angle==nil then t.angle=0 end
    if t.italic==nil then t.italic=false end
    if t.oblique==nil then t.oblique=false end
    if t.bold==nil then t.bold=false end
    if t.radial ~= nil then
        if #t.radial~=6 then 
            print ("error in radial table")
            t.radial=nil 
        end
    end
    if t.orientation==nil then t.orientation="ww" end
    if t.h_align==nil then t.h_align="l" end
    if t.v_align==nil then t.v_align="b" end    
    if t.reflection_alpha == nil then t.reflection_alpha=0 end
    if t.reflection_length == nil then t.reflection_length=1 end
    if t.reflection_scale == nil then t.reflection_scale=1 end
    if t.skew_x==nil then t.skew_x=0 end
    if t.skew_y==nil then t.skew_y=0 end    
    cairo_translate(cr,t.x,t.y)
    cairo_rotate(cr,t.angle*math.pi/180)
    cairo_save(cr)       
     
 

    local slant = CAIRO_FONT_SLANT_NORMAL
    local weight =CAIRO_FONT_WEIGHT_NORMAL
    if t.italic then slant = CAIRO_FONT_SLANT_ITALIC end
    if t.oblique then slant = CAIRO_FONT_SLANT_OBLIQUE end
    if t.bold then weight = CAIRO_FONT_WEIGHT_BOLD end
    
    cairo_select_font_face(cr, t.font_name, slant,weight)
 
    for i=1, #t.colour do    
        if #t.colour[i]~=3 then 
            print ("error in color table")
            t.colour[i]={1,0xFFFFFF,1} 
        end
    end

    local matrix0 = cairo_matrix_t:create()
    skew_x,skew_y=t.skew_x/t.font_size,t.skew_y/t.font_size
    cairo_matrix_init (matrix0, 1,skew_y,skew_x,1,0,0)
    cairo_transform(cr,matrix0)
    cairo_set_font_size(cr,t.font_size)
    te=cairo_text_extents_t:create()
    cairo_text_extents (cr,t.text,te)
    
    set_pattern()


            
    mx,my=0,0
    
    if t.h_align=="c" then
        mx=-te.width/2
    elseif t.h_align=="r" then
        mx=-te.width
    end
    if t.v_align=="m" then
        my=-te.height/2-te.y_bearing
    elseif t.v_align=="t" then
        my=-te.y_bearing
    end
    cairo_move_to(cr,mx,my)
    
    cairo_show_text(cr,t.text)

     
        
        
   if t.reflection_alpha ~= 0 then 
        local matrix1 = cairo_matrix_t:create()
        cairo_set_font_size(cr,t.font_size)

        cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(te.height+te.y_bearing+my)*(1+t.reflection_scale))
        cairo_set_font_size(cr,t.font_size)
        te=cairo_text_extents_t:create()
        cairo_text_extents (cr,t.text,te)
        
                
        cairo_transform(cr,matrix1)
        set_pattern()
        cairo_move_to(cr,mx,my)
        cairo_show_text(cr,t.text)

        local pat2 = cairo_pattern_create_linear (0,
                                        (te.y_bearing+te.height+my),
                                        0,
                                        te.y_bearing+my)
        cairo_pattern_add_color_stop_rgba (pat2, 0,1,0,0,1-t.reflection_alpha)
        cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)    
        
        
        cairo_set_line_width(cr,1)
        dy=te.x_bearing
        if dy<0 then dy=dy*(-1) end
        cairo_rectangle(cr,mx+te.x_bearing,te.y_bearing+te.height+my,te.width+dy,-te.height*1.05)
        cairo_clip_preserve(cr)
        cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
        --cairo_stroke(cr)
        cairo_mask(cr,pat2)
        cairo_pattern_destroy(pat2)
        cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
    end
    
end


function linear_orientation(t,te)
    local w,h=te.width,te.height
    local xb,yb=te.x_bearing,te.y_bearing
    
    if t.h_align=="c" then
        xb=xb-w/2
    elseif t.h_align=="r" then
        xb=xb-w
       end    
    if t.v_align=="m" then
        yb=-h/2
    elseif t.v_align=="t" then
        yb=0
       end    
       
    if t.orientation=="nn" then
        p={xb+w/2,yb,xb+w/2,yb+h}
    elseif t.orientation=="ne" then
        p={xb+w,yb,xb,yb+h}
    elseif t.orientation=="ww" then
        p={xb,h/2,xb+w,h/2}
    elseif vorientation=="se" then
        p={xb+w,yb+h,xb,yb}
    elseif t.orientation=="ss" then
        p={xb+w/2,yb+h,xb+w/2,yb}
    elseif vorientation=="ee" then
        p={xb+w,h/2,xb,h/2}        
    elseif t.orientation=="sw" then
        p={xb,yb+h,xb+w,yb}
    elseif t.orientation=="nw" then
        p={xb,yb,xb+w,yb+h}
    end
    return p
end

et le bg : 1309309633.png

Hors ligne

#350 23/07/2011 00:42:31

doom2a
Membre
Lieu : Corse
Inscription : 31/05/2011
Messages : 97

Re : Conky - Partage de scripts

Salut !

Voir ce tuto m'a donné envie de m'y mettre !! big_smile

J'ai donc installé conky avec le thème Lua 2011 que j'ai un peu modifié en prenant des idées à droite à gauche. La police utilisée est DS9 Computer, que l'on trouve dans le pack LCARS

La partie CPU affiche la charge de 4 coeurs + la charge globale

Certains reconnaîtrons des petits bouts de scripts wink

EDIT: Refonte du thème avec logo Fedora (à renommer en fedora-logo.png), nouvelles couleurs, Charge CPUs et Températures CPU + GPU cool

1311442711.png

.conky_rc

# 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_transparent yes
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below

border_inner_margin 0
border_outer_margin 0

minimum_size 200 250
maximum_width 220

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 1

uppercase no

temperature_unit celsius


default_color FFFFFF

# Lua Load  #
lua_load ~/.lua/scripts/clock_rings.lua
lua_draw_hook_pre clock_rings

TEXT
${image ~/.conky/fedora-logo.png -p 29,110 -s 120x120}
${voffset -10}${color 2D7DB3}${font DS9 Computer:size=26}${time %A}${font}${voffset -4}${alignr 61}${color FFFFFF}${font DS9 Computer:size=48}${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 2D7DB3}${hr}
${voffset 170}

${color 2D7DB3}${font DS9 Computer:size=14}${goto 142}${voffset 28}CPU
${color FFFFFF}${goto 142}${voffset -40}${cpu cpu0}%

${color FFFFFF}${font DS9 Computer:size=12}${goto 35}${voffset -2}${memperc}%
${color 2D7DB3}${goto 21}${voffset -3}RAM
${color FFFFFF}${goto 64}${voffset 23}${swapperc}%${alignr}${color 2D7DB3}CPU: ${color FFFFFF}${hwmon temp 1} C${font caviar dreams:size=12}°
${color 2D7DB3}${goto 46}${voffset -3}${font DS9 Computer:size=12}SWAP ${alignr}${color 2D7DB3}GPU: ${color FFFFFF}${exec nvidia-settings -q GPUCoreTemp -t} C${font caviar dreams:size=12}°
${color FFFFFF}${font DS9 Computer:size=12}${goto 85}${voffset 24}${fs_used_perc /}%
${color 2D7DB3}${goto 72}${voffset -3}DISK
${color FFFFFF}${goto 127}${voffset 28}NET
${color FF6600}${goto 142}${font DS9 Computer:size=12}${voffset -3}UP > ${color FFFFFF}${alignr}${upspeedf p128p1}
${color 339900}${goto 142}${font DS9 Computer:size=12}${voffset -5}DL > ${color FFFFFF}${alignr}${downspeedf p128p1}

${color FFFFFF}${font caviar dreams:size=8}${alignr}Uptime: ${uptime_short}
${color FFFFFF}${font caviar dreams:size=8}${alignr}Processes: ${processes}
${color FFFFFF}${font caviar dreams:size=8}${alignr}Running: ${running_processes}

${color 2D7DB3}${font DS9 Computer:size=12}${alignr}${nodename}
${color 2D7DB3}${font DS9 Computer:size=12}${alignr}${kernel}

${color 2D7DB3}${font DS9 Computer:size=12}${alignr}IP Locale: ${color FFFFFF}${addrs p128p1}
${color 2D7DB3}${font DS9 Computer:size=12}${alignr}IP Publique: ${color FFFFFF}${texeci 25000 dig +short myip.opendns.com @resolver1.opendns.com}

clock_rings.lua

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

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=0x2D7DB3,
        -- "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=90, y=170,
        -- "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=0x2D7DB3,
        fg_alpha=0.6,
        x=90, y=170,
    sectors=4,
    inverse_arc=false,
        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=0x2D7DB3,
        fg_alpha=0.7,
        x=90, y=170,
        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=0x2D7DB3,
        fg_alpha=0.8,
        x=90, y=170,
        radius=70,
        thickness=5,
        start_angle=45,
        end_angle=225
    },
    {
        name='time',
        arg='%m',
        max=12,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0x2D7DB3,
        fg_alpha=1,
        x=90, y=170,
        radius=76,
        thickness=5,
        start_angle=-135,
        end_angle=45
    },
    {
        name='cpu',
        arg='cpu0',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x2D7DB3,
        fg_alpha=1,
        x=157, y=305,
        radius=48,
        thickness=6,
        start_angle=-135,
        end_angle=135
    },

    {
        name='cpu',
        arg='cpu1',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0x844798,
        fg_alpha=0.8,
        x=157, y=305,
        radius=40,
        thickness=6,
        start_angle=-45,
        end_angle=90
    },

 {
        name='cpu',
        arg='cpu2',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0xCB0C29,
        fg_alpha=0.8,
        x=157, y=305,
        radius=33,
        thickness=6,
        start_angle=45,
        end_angle=180
    },

 {
        name='cpu',
        arg='cpu3',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0x49A835,
        fg_alpha=0.8,
        x=157, y=305,
        radius=40,
        thickness=6,
        start_angle=135,
        end_angle=270
    },

 {
        name='cpu',
        arg='cpu4',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0xFF6600,
        fg_alpha=0.8,
        x=157, y=305,
        radius=33,
        thickness=6,
        start_angle=225,
        end_angle=360
    },

    {
        name='memperc',
        arg='',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x2D7DB3,
        fg_alpha=0.8,
        x=50, y=340,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
    {
        name='swapperc',
        arg='',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x2D7DB3,
        fg_alpha=0.8,
        x=75, y=400,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
    {
        name='fs_used_perc',
        arg='/',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x2D7DB3,
        fg_alpha=0.8,
        x=100, y=460,
        radius=25,
        thickness=5,
        start_angle=-90,
        end_angle=180
    },
        {
        name='downspeedf',
        arg='p128p1',
        max=550,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0x339900,
        fg_alpha=0.8,
        x=140, y=520,
        radius=27,
        thickness=7,
        start_angle=-180,
        end_angle=90
    },
        {
        name='upspeedf',
        arg='p128p1',
        max=90,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xff6600,
        fg_alpha=0.8,
        x=140, y=520,
        radius=20,
        thickness=5,
        start_angle=-180,
        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=90
clock_y=170

show_seconds=false

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 - remove -- symbols to display hours's line
    
    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 - remove -- symbols to display minute's line
    
    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

Dernière modification par doom2a (24/07/2011 23:07:44)

Hors ligne

Pied de page des forums