Contenu | Rechercher | Menus

Annonce

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

À propos de l'équipe du forum.

#476 Le 18/03/2014, à 20:48

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@ jlfh0816,
pour le second conky sur lequel j'avais travaillé tout le code est en lua, et donc c'est très compliqué a modifier, mais si tu veux voici le lien vers l'archive, à défaut de retrouver le post.

quand tu te demande comment faire pour reproduire ce qu'il y a dans un message, le plus simple est de cliquer sur citer (en bas a droite sous la signature), et de regarder ce qui a été fait wink
en même temps comme la discussion est fermée sa vas être compliqué, en fait il s'agit d'un gif animé.

la fonction animate n'est pas une fonction de conky, mais un programme, qui permet d'afficher une animation, l'avantage par apport a ta méthode, c'est la conso CPU qui est quasi nul, inconvénient c'est qu'il faut tuer animate pour arrêter le conky.

au fait, bravo pour la recherche, ça date... 2011 tongue

Dernière modification par Didier-T (Le 18/03/2014, à 20:55)

Hors ligne

#477 Le 18/03/2014, à 21:10

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@ Didier-T
Merci beaucoup de tous ces éléments de réponse. Dès ce week-end, j'essaierai de voir ce que je peux faire avec les 2 liens que tu m'as fort gentiment communiqués et si je parviens à faire quelque chose de présentable, j'en ferai un post.

Je vais aussi voir sur Google si je trouve quelque chose sur ce programme animate. Peut-être est-il encore disponible quelque part, peut-être même avec de la doc ? Je vais fouiller !

Pour l'astuce de cliquer sur "citer" en bas à droite sous la signature, tu as raison, je ne peux malheureusement plus le faire sur ce fameux post car la discussion est maintenant fermée ... donc, il n'y a plus la mention "citer" ...
Mais donc, on peut afficher un gif animé dans un post ? Va falloir que je fouille sur le forum Ubuntu.fr pour savoir comment faire. Jusqu'à présent, je ne connaissais que l'incrustation d'une url pour une image fixe ou d'une url pour une vidéo. Je vais donc continuer de chercher, je finirai bien par trouver !

En tout cas, un grand merci de ton aide et un grand bravo pour toutes tes réalisations que je suis d'un œil émerveillé au fil de tes posts

Jean-Luc

EDIT: ça y est, je viens enfin de comprendre comment afficher mon gif animé dans un post. Le résultat est dans mon post 527 ci-dessus. Un petit mystère réglé !

Dernière modification par jlfh0816 (Le 18/03/2014, à 22:24)


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#478 Le 19/03/2014, à 13:01

daniel38100

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

merci Didier-T pour ton chronographe modifier c'est c'est exactement ce que je voulais

je repond un peu tard j'étais en vacance

Hors ligne

#479 Le 19/03/2014, à 20:43

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@ jlfh0816,
pour ce que tu veux faire, je te conseille tous de même l'utilisation du premier lien que je te donnais, si tu as la moindre question n'hésite pas, parfois je ne reçois pas les notifications du site comme quoi il y a de nouveaux messages sur les sujets que je suis, mais j'y retourne régulièrement. cool

@ daniel38100,
cool, te voilà donc reposé et prêt à reprendre du service big_smile

Dernière modification par Didier-T (Le 19/03/2014, à 20:45)

Hors ligne

#480 Le 20/03/2014, à 21:16

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Didier-T a écrit :

@ jlfh0816,
pour ce que tu veux faire, je te conseille tous de même l'utilisation du premier lien que je te donnais, si tu as la moindre question n'hésite pas, parfois je ne reçois pas les notifications du site comme quoi il y a de nouveaux messages sur les sujets que je suis, mais j'y retourne régulièrement. cool

Bonjour Didier-T,

Tout d'abord, je te remercie beaucoup de ta proposition d'aide ... je crois que je vais en avoir bien besoin ...
J'ai en effet voulu faire un premier essai avec le premier script (Clic_info.lua). Je l'ai modifié car tout ce que je lui demande, c'est que le clic dans le conky entraîne l'ouverture de mon dossier Images par l'intermédiaire de mon gestionnaire de fichiers Nemo. Malheureusement, ce premier essai ne s'avère pas du tout concluant. J'arrive tout juste à afficher une fenêtre à gauche de l'écran qui ne contient même pas la totalité de mon cube animé. Comme j'ai lancé le conky dans le terminal, je vois que j'ai 2 nombres qui s'affichent sur les deux dernières lignes ...mais qui ne me disent pas grand chose. Par contre, dans mon dock en bas de l'écran, j'ai un magnifique X qui s'affiche et que je n'avais jamais vu auparavant. C'est ça le serveur graphique X ?
Voici la copie de mon écran:
1395344869.png
Et bien sûr, les clics dans la fenêtre qui s'est affichée ne donnent strictement rien.
Peut-être faut-il que je modifie les valeurs de Posx, Posy, Lageur et Hauteur ...

Je serai très heureux Didier-T si tu acceptais de jeter un oeil sur la bidouille que j'ai faite avec ton script Clic_info.lua. Voilà comment je l'ai modifié :

--[[
!!! Nécessite l’installation de xdotool !!!
Le conky appelant doit avoir sa propre fenêtre et un nom, par exemple
own_window_title Cube
own_window yes

Dans le conky il faut ajouter :
Avant TEXT
lua_load     "Votre chemin"/Clic_info.lua

Après TEXT
${lua click}

Pour obtenir la position de la souris dans le script lié au clic utiliser
posx et posy

Pour ajouter des données récupérées via conky dans la commande à exécuter indiquer dans la ligne de commande arg(x), arg1 sera remplacé par le résultat de arg1, vous disposez de 5 arguments

Les commandes peuvent être exécutées par conky ou directement par le système

Le nom de la fenêtre conky doit être renseigné ci-dessous
]]--
local Fenetre="Cube"
local Bouton={
    {
    Posx=0,
    Posy=120,
    Lageur=100,
    Hauteur=28,
    Commande_Os="nemo /home/jlfh0816/Images",
    Commande_Conky="",
    arg1="",
    arg2="",
    arg3="",
    arg4="",
    arg5="",
    },
}


local start=1
local abstlx, abstly

function conky_click()
    local mousex, mousey, localx, localy, arg1, arg2, arg3, arg4, arg5
    if conky_window == nil then return end
    local updates=tonumber(conky_parse('${updates}'))
    if updates>2 then

        localx,localy=clickfunction()

        for i in pairs(Bouton) do
            if localx>=Bouton[i].Posx and localx<=Bouton[i].Posx+Bouton[i].Lageur and localy>=Bouton[i].Posy and localy<=Bouton[i].Posy+Bouton[i].Hauteur then
                mousex=Bouton[i].Posx+abstlx
                mousey=Bouton[i].Posy+Bouton[i].Hauteur+abstly
                if Bouton[i].arg1 ~= "" then arg1=conky_parse( "${"..Bouton[i].arg1.."}" ) else arg1=" " end
                if Bouton[i].arg2 ~= "" then arg2=conky_parse( "${"..Bouton[i].arg2.."}" ) else arg2=" " end
                if Bouton[i].arg3 ~= "" then arg3=conky_parse( "${"..Bouton[i].arg3.."}" ) else arg3=" " end
                if Bouton[i].arg4 ~= "" then arg4=conky_parse( "${"..Bouton[i].arg4.."}" ) else arg4=" " end
                if Bouton[i].arg5 ~= "" then arg5=conky_parse( "${"..Bouton[i].arg5.."}" ) else arg5=" " end
                if Bouton[i].Commande_Os ~= "" then
                    Bouton[i].Commande_Os=Bouton[i].Commande_Os:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
                    print(Bouton[i].Commande_Os)
                    os.execute(Bouton[i].Commande_Os)
                end
                if Bouton[i].Commande_Conky ~= "" then
                    Bouton[i].Commande_Conky=Bouton[i].Commande_Conky:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
                    conky_parse( "${"..Bouton[i].Commande_Os.."}")
                end
            end
        end
        collectgarbage()
    end
    return ""
end

function clickfunction()
    local xdot, geometry ,s ,f , click, mousex, mousey, localx, localy
    --start click logging and calculations ##########################################
    if start==1 then
        xdot=os.execute("exec ps ax | awk '/ xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation / {print $1}'")
        if tonumber(xdot)==1 then
            os.execute("kill "..xdot)
        end
        os.execute("xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation >> /tmp/xdo &")
        start=nil
        local f = io.popen("xwininfo -name '"..Fenetre.."' | grep 'Absolute'")
        geometry = f:read("*a")
        f:close()
        geometry=string.gsub(geometry,"[\n]","")
        s,f,abstlx=string.find(geometry,"X%p%s*(%d*)")
        s,f,abstly=string.find(geometry,"Y%p%s*(%d*)")
    end--if start=1 ######################################
    --click calculations #################################
    local f=io.open("/tmp/xdo")
    click=f:read()
    f:close()
    if click~=nil then
        local f = io.open("/tmp/xdo","w")
        f:write("")
        f:close() 
    end--if click=nil
    if click==nil then click="x:0 y:0 " end
    s,f,mousex=string.find(click,"x%p(%d*)%s")
    s,f,mousey=string.find(click,"y%p(%d*)%s")
    mousex=tonumber(mousex)
    mousey=tonumber(mousey)
    localx=mousex-abstlx
    localy=mousey-abstly
    --END CLICK CALCULATIONS #################################
    return localx,localy,mousex,mousey
end--function

Et revoici mon conkyrc que j'ai renommé "Cube" :

#le conky appelant doit avoir sa propre fenêtre et un nom
Own_window_title Cube
Own_window yes
#vitesse de rotation du cube
update_interval 0.15
# réglage de la mémoire, pour éviter le clignotement
double_buffer yes
# Soustraire les mémoires tampons de la mémoire utilisée
no_buffers yes
text_buffer_size 1024
imlib_cache_size 0
template1 /home/jlfh0816/essai/temp.gif.
template2 -p 100,280 -s 135x135
lua_load /home/jlfh0816/essai/Clic_info.lua
TEXT
Conky animation with images
${lua click}
${if_updatenr 01}${image ${template1}005 ${template2}}${endif}
${if_updatenr 02}${image ${template1}010 ${template2}}${endif}
${if_updatenr 03}${image ${template1}015 ${template2}}${endif}
${if_updatenr 04}${image ${template1}020 ${template2}}${endif}
${if_updatenr 05}${image ${template1}025 ${template2}}${endif}
${if_updatenr 06}${image ${template1}030 ${template2}}${endif}
${if_updatenr 07}${image ${template1}035 ${template2}}${endif}
${if_updatenr 08}${image ${template1}040 ${template2}}${endif}
${if_updatenr 09}${image ${template1}045 ${template2}}${endif}
${if_updatenr 10}${image ${template1}050 ${template2}}${endif}
${if_updatenr 11}${image ${template1}055 ${template2}}${endif}
${if_updatenr 12}${image ${template1}060 ${template2}}${endif}
${if_updatenr 13}${image ${template1}065 ${template2}}${endif}
${if_updatenr 14}${image ${template1}070 ${template2}}${endif}
${if_updatenr 15}${image ${template1}075 ${template2}}${endif}
${if_updatenr 16}${image ${template1}080 ${template2}}${endif}
${if_updatenr 17}${image ${template1}085 ${template2}}${endif}
${if_updatenr 18}${image ${template1}090 ${template2}}${endif}
${if_updatenr 19}${image ${template1}095 ${template2}}${endif}
${if_updatenr 20}${image ${template1}100 ${template2}}${endif}
${if_updatenr 21}${image ${template1}105 ${template2}}${endif}
${if_updatenr 22}${image ${template1}110 ${template2}}${endif}
${if_updatenr 23}${image ${template1}115 ${template2}}${endif}
${if_updatenr 24}${image ${template1}120 ${template2}}${endif}
${if_updatenr 25}${image ${template1}125 ${template2}}${endif}
${if_updatenr 26}${image ${template1}130 ${template2}}${endif}
${if_updatenr 27}${image ${template1}135 ${template2}}${endif}
${if_updatenr 28}${image ${template1}140 ${template2}}${endif}
${if_updatenr 29}${image ${template1}145 ${template2}}${endif}
${if_updatenr 30}${image ${template1}150 ${template2}}${endif}
${if_updatenr 31}${image ${template1}155 ${template2}}${endif}
${if_updatenr 32}${image ${template1}160 ${template2}}${endif}
${if_updatenr 33}${image ${template1}165 ${template2}}${endif}
${if_updatenr 34}${image ${template1}170 ${template2}}${endif}
${if_updatenr 35}${image ${template1}175 ${template2}}${endif}
${if_updatenr 36}${image ${template1}180 ${template2}}${endif}
${if_updatenr 37}${image ${template1}185 ${template2}}${endif}
${if_updatenr 38}${image ${template1}190 ${template2}}${endif}
${if_updatenr 39}${image ${template1}195 ${template2}}${endif}
${if_updatenr 40}${image ${template1}200 ${template2}}${endif}
${if_updatenr 41}${image ${template1}205 ${template2}}${endif}
${if_updatenr 42}${image ${template1}210 ${template2}}${endif}
${if_updatenr 43}${image ${template1}215 ${template2}}${endif}
${if_updatenr 44}${image ${template1}220 ${template2}}${endif}
${if_updatenr 45}${image ${template1}225 ${template2}}${endif}
${if_updatenr 46}${image ${template1}230 ${template2}}${endif}
${if_updatenr 47}${image ${template1}235 ${template2}}${endif}
${if_updatenr 48}${image ${template1}240 ${template2}}${endif}
${if_updatenr 49}${image ${template1}245 ${template2}}${endif}
${if_updatenr 50}${image ${template1}250 ${template2}}${endif}
${if_updatenr 51}${image ${template1}255 ${template2}}${endif}
${if_updatenr 52}${image ${template1}260 ${template2}}${endif}
${if_updatenr 53}${image ${template1}265 ${template2}}${endif}
${if_updatenr 54}${image ${template1}270 ${template2}}${endif}
${if_updatenr 55}${image ${template1}275 ${template2}}${endif}
${if_updatenr 56}${image ${template1}280 ${template2}}${endif}
${if_updatenr 57}${image ${template1}285 ${template2}}${endif}
${if_updatenr 58}${image ${template1}290 ${template2}}${endif}
${if_updatenr 59}${image ${template1}295 ${template2}}${endif}
${if_updatenr 60}${image ${template1}300 ${template2}}${endif}
${if_updatenr 61}${image ${template1}305 ${template2}}${endif}
${if_updatenr 62}${image ${template1}310 ${template2}}${endif}
${if_updatenr 63}${image ${template1}315 ${template2}}${endif}
${if_updatenr 64}${image ${template1}320 ${template2}}${endif}
${if_updatenr 65}${image ${template1}325 ${template2}}${endif}
${if_updatenr 66}${image ${template1}330 ${template2}}${endif}
${if_updatenr 67}${image ${template1}335 ${template2}}${endif}
${if_updatenr 68}${image ${template1}340 ${template2}}${endif}
${if_updatenr 69}${image ${template1}345 ${template2}}${endif}
${if_updatenr 70}${image ${template1}350 ${template2}}${endif}
${if_updatenr 71}${image ${template1}355 ${template2}}${endif}
${if_updatenr 72}${image ${template1}360 ${template2}}${endif}
${if_updatenr 73}${image ${template1}365 ${template2}}${endif}
${if_updatenr 74}${image ${template1}370 ${template2}}${endif}
${if_updatenr 75}${image ${template1}375 ${template2}}${endif}
${if_updatenr 76}${image ${template1}380 ${template2}}${endif}
${if_updatenr 77}${image ${template1}385 ${template2}}${endif}
${if_updatenr 78}${image ${template1}390 ${template2}}${endif}
${if_updatenr 79}${image ${template1}395 ${template2}}${endif}
${if_updatenr 80}${image ${template1}400 ${template2}}${endif}
${if_updatenr 81}${image ${template1}405 ${template2}}${endif}
${if_updatenr 82}${image ${template1}410 ${template2}}${endif}
${if_updatenr 83}${image ${template1}415 ${template2}}${endif}
${if_updatenr 84}${image ${template1}420 ${template2}}${endif}
${if_updatenr 85}${image ${template1}425 ${template2}}${endif}
${if_updatenr 86}${image ${template1}430 ${template2}}${endif}
${if_updatenr 87}${image ${template1}435 ${template2}}${endif}
${if_updatenr 88}${image ${template1}440 ${template2}}${endif}
${if_updatenr 89}${image ${template1}445 ${template2}}${endif}
${if_updatenr 90}${image ${template1}450 ${template2}}${endif}

Dernière modification par jlfh0816 (Le 20/03/2014, à 21:18)


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#481 Le 21/03/2014, à 07:19

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Bonjour jlfh0816,
ceci devrait fonctionner

Clic_info.lua

--[[
!!! Nécessite l’installation de xdotool !!!
Le conky appelant doit avoir sa propre fenêtre et un nom, par exemple
own_window_title Cube
own_window yes

Dans le conky il faut ajouter :
Avant TEXT
lua_load     "Votre chemin"/Clic_info.lua

Après TEXT
${lua click}

Pour obtenir la position de la souris dans le script lié au clic utiliser
posx et posy

Pour ajouter des données récupérées via conky dans la commande à exécuter indiquer dans la ligne de commande arg(x), arg1 sera remplacé par le résultat de arg1, vous disposez de 5 arguments

Les commandes peuvent être exécutées par conky ou directement par le système

Le nom de la fenêtre conky doit être renseigné ci-dessous
]]--
local Fenetre="Cube"
local Bouton={
    {
    Posx=0,
    Posy=0,
    Lageur=135,
    Hauteur=135,
    Commande_Os="nemo /home/jlfh0816/Images",
    Commande_Conky="",
    arg1="",
    arg2="",
    arg3="",
    arg4="",
    arg5="",
    },
}


local start=1
local abstlx, abstly

function conky_click()
    local mousex, mousey, localx, localy, arg1, arg2, arg3, arg4, arg5
    if conky_window == nil then return end
    local updates=tonumber(conky_parse('${updates}'))
    if updates>2 then

        localx,localy=clickfunction()

        for i in pairs(Bouton) do
            if localx>=Bouton[i].Posx and localx<=Bouton[i].Posx+Bouton[i].Lageur and localy>=Bouton[i].Posy and localy<=Bouton[i].Posy+Bouton[i].Hauteur then
                mousex=Bouton[i].Posx+abstlx
                mousey=Bouton[i].Posy+Bouton[i].Hauteur+abstly
                if Bouton[i].arg1 ~= "" then arg1=conky_parse( "${"..Bouton[i].arg1.."}" ) else arg1=" " end
                if Bouton[i].arg2 ~= "" then arg2=conky_parse( "${"..Bouton[i].arg2.."}" ) else arg2=" " end
                if Bouton[i].arg3 ~= "" then arg3=conky_parse( "${"..Bouton[i].arg3.."}" ) else arg3=" " end
                if Bouton[i].arg4 ~= "" then arg4=conky_parse( "${"..Bouton[i].arg4.."}" ) else arg4=" " end
                if Bouton[i].arg5 ~= "" then arg5=conky_parse( "${"..Bouton[i].arg5.."}" ) else arg5=" " end
                if Bouton[i].Commande_Os ~= "" then
                    Bouton[i].Commande_Os=Bouton[i].Commande_Os:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
                    print(Bouton[i].Commande_Os)
                    os.execute(Bouton[i].Commande_Os)
                end
                if Bouton[i].Commande_Conky ~= "" then
                    Bouton[i].Commande_Conky=Bouton[i].Commande_Conky:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
                    conky_parse( "${"..Bouton[i].Commande_Os.."}")
                end
            end
        end
        collectgarbage()
    end
    return ""
end

function clickfunction()
    local xdot, geometry ,s ,f , click, mousex, mousey, localx, localy
    --start click logging and calculations ##########################################
    if start==1 then
        xdot=os.execute("exec ps ax | awk '/ xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation / {print $1}'")
        if tonumber(xdot)==1 then
            os.execute("kill "..xdot)
        end
        os.execute("xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation >> /tmp/xdo &")
        start=nil
        local f = io.popen("xwininfo -name '"..Fenetre.."' | grep 'Absolute'")
        geometry = f:read("*a")
        f:close()
        geometry=string.gsub(geometry,"[\n]","")
        s,f,abstlx=string.find(geometry,"X%p%s*(%d*)")
        s,f,abstly=string.find(geometry,"Y%p%s*(%d*)")
    end--if start=1 ######################################
    --click calculations #################################
    local f=io.open("/tmp/xdo")
    click=f:read()
    f:close()
    if click~=nil then
        local f = io.open("/tmp/xdo","w")
        f:write("")
        f:close()
    end--if click=nil
    if click==nil then click="x:0 y:0 " end
    s,f,mousex=string.find(click,"x%p(%d*)%s")
    s,f,mousey=string.find(click,"y%p(%d*)%s")
    mousex=tonumber(mousex)
    mousey=tonumber(mousey)
    localx=mousex-abstlx
    localy=mousey-abstly
    --END CLICK CALCULATIONS #################################
    return localx,localy,mousex,mousey
end--function

.conkyrc

#le conky appelant doit avoir sa propre fenêtre et un nom
own_window_title Cube
#definition du type de fenetre, et des décorations
own_window_argb_visual yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
#définition de la taille, et de la position du conky
minimum_size 135 135

alignment br
gap_x 10
gap_y 10
#vitesse de rotation du cube
update_interval 0.15
# réglage de la mémoire, pour éviter le clignotement
double_buffer yes
# Soustraire les mémoires tampons de la mémoire utilisée
no_buffers yes
text_buffer_size 1024
imlib_cache_size 0
template1 ~/essai/temp.gif.
template2 -p 0,0 -s 135x135
lua_load ~/essai/Clic_info.lua
TEXT
Conky animation with images
${lua click}
${if_updatenr 01}${image ${template1}005 ${template2}}${endif}
${if_updatenr 02}${image ${template1}010 ${template2}}${endif}
${if_updatenr 03}${image ${template1}015 ${template2}}${endif}
${if_updatenr 04}${image ${template1}020 ${template2}}${endif}
${if_updatenr 05}${image ${template1}025 ${template2}}${endif}
${if_updatenr 06}${image ${template1}030 ${template2}}${endif}
${if_updatenr 07}${image ${template1}035 ${template2}}${endif}
${if_updatenr 08}${image ${template1}040 ${template2}}${endif}
${if_updatenr 09}${image ${template1}045 ${template2}}${endif}
${if_updatenr 10}${image ${template1}050 ${template2}}${endif}
${if_updatenr 11}${image ${template1}055 ${template2}}${endif}
${if_updatenr 12}${image ${template1}060 ${template2}}${endif}
${if_updatenr 13}${image ${template1}065 ${template2}}${endif}
${if_updatenr 14}${image ${template1}070 ${template2}}${endif}
${if_updatenr 15}${image ${template1}075 ${template2}}${endif}
${if_updatenr 16}${image ${template1}080 ${template2}}${endif}
${if_updatenr 17}${image ${template1}085 ${template2}}${endif}
${if_updatenr 18}${image ${template1}090 ${template2}}${endif}
${if_updatenr 19}${image ${template1}095 ${template2}}${endif}
${if_updatenr 20}${image ${template1}100 ${template2}}${endif}
${if_updatenr 21}${image ${template1}105 ${template2}}${endif}
${if_updatenr 22}${image ${template1}110 ${template2}}${endif}
${if_updatenr 23}${image ${template1}115 ${template2}}${endif}
${if_updatenr 24}${image ${template1}120 ${template2}}${endif}
${if_updatenr 25}${image ${template1}125 ${template2}}${endif}
${if_updatenr 26}${image ${template1}130 ${template2}}${endif}
${if_updatenr 27}${image ${template1}135 ${template2}}${endif}
${if_updatenr 28}${image ${template1}140 ${template2}}${endif}
${if_updatenr 29}${image ${template1}145 ${template2}}${endif}
${if_updatenr 30}${image ${template1}150 ${template2}}${endif}
${if_updatenr 31}${image ${template1}155 ${template2}}${endif}
${if_updatenr 32}${image ${template1}160 ${template2}}${endif}
${if_updatenr 33}${image ${template1}165 ${template2}}${endif}
${if_updatenr 34}${image ${template1}170 ${template2}}${endif}
${if_updatenr 35}${image ${template1}175 ${template2}}${endif}
${if_updatenr 36}${image ${template1}180 ${template2}}${endif}
${if_updatenr 37}${image ${template1}185 ${template2}}${endif}
${if_updatenr 38}${image ${template1}190 ${template2}}${endif}
${if_updatenr 39}${image ${template1}195 ${template2}}${endif}
${if_updatenr 40}${image ${template1}200 ${template2}}${endif}
${if_updatenr 41}${image ${template1}205 ${template2}}${endif}
${if_updatenr 42}${image ${template1}210 ${template2}}${endif}
${if_updatenr 43}${image ${template1}215 ${template2}}${endif}
${if_updatenr 44}${image ${template1}220 ${template2}}${endif}
${if_updatenr 45}${image ${template1}225 ${template2}}${endif}
${if_updatenr 46}${image ${template1}230 ${template2}}${endif}
${if_updatenr 47}${image ${template1}235 ${template2}}${endif}
${if_updatenr 48}${image ${template1}240 ${template2}}${endif}
${if_updatenr 49}${image ${template1}245 ${template2}}${endif}
${if_updatenr 50}${image ${template1}250 ${template2}}${endif}
${if_updatenr 51}${image ${template1}255 ${template2}}${endif}
${if_updatenr 52}${image ${template1}260 ${template2}}${endif}
${if_updatenr 53}${image ${template1}265 ${template2}}${endif}
${if_updatenr 54}${image ${template1}270 ${template2}}${endif}
${if_updatenr 55}${image ${template1}275 ${template2}}${endif}
${if_updatenr 56}${image ${template1}280 ${template2}}${endif}
${if_updatenr 57}${image ${template1}285 ${template2}}${endif}
${if_updatenr 58}${image ${template1}290 ${template2}}${endif}
${if_updatenr 59}${image ${template1}295 ${template2}}${endif}
${if_updatenr 60}${image ${template1}300 ${template2}}${endif}
${if_updatenr 61}${image ${template1}305 ${template2}}${endif}
${if_updatenr 62}${image ${template1}310 ${template2}}${endif}
${if_updatenr 63}${image ${template1}315 ${template2}}${endif}
${if_updatenr 64}${image ${template1}320 ${template2}}${endif}
${if_updatenr 65}${image ${template1}325 ${template2}}${endif}
${if_updatenr 66}${image ${template1}330 ${template2}}${endif}
${if_updatenr 67}${image ${template1}335 ${template2}}${endif}
${if_updatenr 68}${image ${template1}340 ${template2}}${endif}
${if_updatenr 69}${image ${template1}345 ${template2}}${endif}
${if_updatenr 70}${image ${template1}350 ${template2}}${endif}
${if_updatenr 71}${image ${template1}355 ${template2}}${endif}
${if_updatenr 72}${image ${template1}360 ${template2}}${endif}
${if_updatenr 73}${image ${template1}365 ${template2}}${endif}
${if_updatenr 74}${image ${template1}370 ${template2}}${endif}
${if_updatenr 75}${image ${template1}375 ${template2}}${endif}
${if_updatenr 76}${image ${template1}380 ${template2}}${endif}
${if_updatenr 77}${image ${template1}385 ${template2}}${endif}
${if_updatenr 78}${image ${template1}390 ${template2}}${endif}
${if_updatenr 79}${image ${template1}395 ${template2}}${endif}
${if_updatenr 80}${image ${template1}400 ${template2}}${endif}
${if_updatenr 81}${image ${template1}405 ${template2}}${endif}
${if_updatenr 82}${image ${template1}410 ${template2}}${endif}
${if_updatenr 83}${image ${template1}415 ${template2}}${endif}
${if_updatenr 84}${image ${template1}420 ${template2}}${endif}
${if_updatenr 85}${image ${template1}425 ${template2}}${endif}
${if_updatenr 86}${image ${template1}430 ${template2}}${endif}
${if_updatenr 87}${image ${template1}435 ${template2}}${endif}
${if_updatenr 88}${image ${template1}440 ${template2}}${endif}
${if_updatenr 89}${image ${template1}445 ${template2}}${endif}
${if_updatenr 90}${image ${template1}450 ${template2}}${endif}

si tu conserve le texte en haut de ton conky :
dans Clic_info.lua, il faudra certainement jour sur la position posy, mais sa devrait être de l’ordre d'une dizaine de pixel, pas beaucoup plus (enfin je crois)
dans .conkyrc ajuster la position de l'image par rapport au texte affiché

Si tu supprimes le texte les réglages doivent être bons

Hors ligne

#482 Le 21/03/2014, à 07:48

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@Didier_T
Un très grand merci de ton aide Didier_T ! :D
Dès que je serai de retour chez moi (là, je suis dehors pour le travail et sous Windows ...), je teste tout cela ce week-end et je te rends compte.
Encore Merci !
Jean-Luc


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#483 Le 22/03/2014, à 10:24

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@Didier_T

Bonjour Didier_T,
Wouaah, ce que tu as fait est formidable, ça fonctionne nickel !
Je clique et mon dossier "Images" apparaît bien (ça entraîne aussi l'arrêt sur image de l'animation du conky) et si je ferme la fenêtre de mon dossier "Images", le conky redémarre son animation. Super, c'est exactement ce que je voulais, je suis un homme heureux ! tongue

Le seul petit bémol, c'est que la position de mon conky n'est pas à la place où je voulais le faire apparaître. En effet, il apparaît en haut et à droite de l'écran (il chevauche le conky Orange de Voyager) alors que j'aurai préféré le placer à mi-hauteur et à gauche de l'écran. J'ai donc modifié les coordonnées dans le .conkyrc et les bonnes coordonnées sont gap_x 1700 et gap_y -200
Le hic, c'est qu'avec ces nouvelles coordonnées, le clic devient inefficace. Je pense qu'il faut également adapter les coordonnées dans ton script Clic_info.lua mais, à part jouer sur posx et posy, je ne vois pas où. Aurais-tu la gentillesse de me dire ce que je dois modifier dans Clic_info.lua pour conserver un clic efficace avec mes nouvelles coordonnées ?

En tout cas, je te remercie de ton aide précieuse pour ce conky et je te souhaite un excellent week-end !

Jean-Luc

Dernière modification par jlfh0816 (Le 22/03/2014, à 10:36)


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#484 Le 22/03/2014, à 10:34

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@Didier_T

Ah oui, j'allais oublier, tout fonctionne bien si je lance le conky avec le terminal.
Par contre, lorsque je le lance en automatique avec la session, le conky apparait bien mais n'est pas cliquable. Ma ligne de commande est peut-être mauvaise ? Voici celle que j'utilise:

sh -c "sleep 5; conky -c /home/jlfh0816/essai/.conkyrc;"

Ai-je entré une commande fausse ?


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#485 Le 22/03/2014, à 11:30

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@Didier_T

En voulant remercier Pieter Blinkenshell sur le site Crunchbang, l'auteur du script qui m'a permis d'avoir le gif animé sans utiliser de code lua, j'ai lié contact avec mrpeachy lequel m'a fort gentiment communiqué ses propositions de scripts lua pour précisément créer un gif animé. Voici le lien qui va bien (c'est le post n°7). D'après ce que j'ai compris, c'est beaucoup plus rapide, carré et efficace qu'avec la méthode de Blinkenshell. Le problème, c'est que dans l'état actuel de mes connaissances, je n'y comprends pas grand chose. J'ai essayé plusieurs fois d'adapter son gif.lua et son .conkyrc à mon cas mais j'avoue que je ne suis arrivé à rien de fonctionnel.
Lorsque tu auras le temps Didier_T, peux-tu jeter un œil dessus ? Connaissant la réputation de mrpeachy, c'est sûrement très intéressant et très bien fait mais je n'ai pas les épaules assez solides pour être capable d'utiliser son travail ... hélas, 100 fois hélas ...
Merci à l'avance encore une fois,

Dernière modification par jlfh0816 (Le 22/03/2014, à 20:18)


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#486 Le 22/03/2014, à 20:54

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Bonsoir jlfh0816,
la commande que tu utilise est bonne, mais peut être devrais-tu allonger le délais, en le passant a 15 secondes par exemple.

j'adore le travail de mrpeachy, mais je suis une burne en anglais, mais bon, je n'ai pas besoins de le comprendre pour apprécier ses scripts.
je me suis permis de modifier un peut son script, ce serait gentils de ta part de lui montrer la modification, je pense que sa lui plaira wink

gif.lua (qui pour le coup gagnerait a être renommé)

--[[
Script gif.lua
By mrpeachy
Modifier le 22/03/2014 par Didier-T
 prise en charge du contenu complet d'un répertoire avec choix de format (jpg, gif, etc...)
 prise en charge des racourcis ~ et $HOME, ainsi que des espaces dans le chemin du repertoire

#############################################################################################
#                                                                                           #
#                                           Usage                                           #
#                                                                                           #
#############################################################################################
#                                                                                           #
# lua_load ~/gif.lua                                                                        #
# TEXT                                                                                      #
# ${lua gif repertoire format pos_x pos_y largeur hauteur}                                  #
#                                                                                           #
#############################################################################################
remplacer les espaces par %20 pour le chemin du repertoire

]]--
--gifsicle --unoptimize --explode /home/pieter/temp/compdead.gif --output /home/pieter/temp/temp.gif
require 'cairo'
require 'imlib2'
ini=0
count=0
fichier={}
function conky_gif(rep,ext,x,y,w,h)
    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 ini==0 then fichier=init(rep, ext) end

    show_image=fichier[count]

    if count<table.getn(fichier) then
        count=count+1
    else
        count=0
    end
    image({x=x,y=y,w=w,h=h,file=show_image,decache=1})
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
    return ""
end-- end main function

function init(rep, ext)
    ini=1
    local home = os.getenv("HOME")
    rep = string.gsub(rep, "~", home)
    rep = string.gsub(rep, "$HOME", home)
    rep=string.gsub(rep, '%%20', "\\ ")
    local file=conky_parse("${exec find "..rep.."/*."..ext.." -type f -print}")
    return file:split('\n')
end

-- Fonction de découpage maison
function string:split(pat)
    -- Détermination du caractère séparant les champs pour le découpage
    -- Par défaut ce sera espace
    pat = pat or '%s+'
    local tab = {}
    local x=0
    for i in self:gmatch("([^"..pat.."]+)") do
        tab[x]=i
        x=x+1
    end
    return tab
end

function image(im)--#######################################################################################
    local x=(im.x or 0)
    local y=(im.y or 0)
    local w=(im.w or 50)
    local h=(im.h or 50)
    local file=tostring(im.file)
    local decache=im.decache or 0
    if file==nil then print("set image file") end
    ---------------------------------------------
    local show = imlib_load_image(file)
    if show == nil then return end
    imlib_context_set_image(show)
    if tonumber(w)==0 then
        width=imlib_image_get_width()
    else
        width=tonumber(w)
    end
    if tonumber(h)==0 then
        height=imlib_image_get_height()
    else
        height=tonumber(h)
    end
    imlib_context_set_image(show)
    local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
    if decache==1 then
        imlib_free_image_and_decache()
    else
        imlib_free_image()
    end
    imlib_context_set_image(scaled)
    imlib_render_image_on_drawable(x,y)
    imlib_free_image()
end--function image

Clic_info.lua

--[[
!!! Nécessite l’installation de xdotool !!!
Le conky appelant doit avoir sa propre fenêtre et un nom, par exemple
own_window_title Cube
own_window yes

Dans le conky il faut ajouter :
Avant TEXT
lua_load     "Votre chemin"/Clic_info.lua

Après TEXT
${lua click}

Pour obtenir la position de la souris dans le script lié au clic utiliser
posx et posy

Pour ajouter des données récupérées via conky dans la commande à exécuter indiquer dans la ligne de commande arg(x), arg1 sera remplacé par le résultat de arg1, vous disposez de 5 arguments

Les commandes peuvent être exécutées par conky ou directement par le système

Le nom de la fenêtre conky doit être renseigné ci-dessous
]]--
local Fenetre="Cube"
local Bouton={
    {
    Posx=0,
    Posy=15,
    Lageur=135,
    Hauteur=135,
    Commande_Os="nemo /home/jlfh0816/Images",
    Commande_Conky="",
    arg1="",
    arg2="",
    arg3="",
    arg4="",
    arg5="",
    },
}


local start=1
local abstlx, abstly

function conky_click()
    local mousex, mousey, localx, localy, arg1, arg2, arg3, arg4, arg5
    if conky_window == nil then return end
    local updates=tonumber(conky_parse('${updates}'))
    if updates>2 then

        localx,localy=clickfunction()

        for i in pairs(Bouton) do
            if localx>=Bouton[i].Posx and localx<=Bouton[i].Posx+Bouton[i].Lageur and localy>=Bouton[i].Posy and localy<=Bouton[i].Posy+Bouton[i].Hauteur then
                mousex=Bouton[i].Posx+abstlx
                mousey=Bouton[i].Posy+Bouton[i].Hauteur+abstly
                if Bouton[i].arg1 ~= "" then arg1=conky_parse( "${"..Bouton[i].arg1.."}" ) else arg1=" " end
                if Bouton[i].arg2 ~= "" then arg2=conky_parse( "${"..Bouton[i].arg2.."}" ) else arg2=" " end
                if Bouton[i].arg3 ~= "" then arg3=conky_parse( "${"..Bouton[i].arg3.."}" ) else arg3=" " end
                if Bouton[i].arg4 ~= "" then arg4=conky_parse( "${"..Bouton[i].arg4.."}" ) else arg4=" " end
                if Bouton[i].arg5 ~= "" then arg5=conky_parse( "${"..Bouton[i].arg5.."}" ) else arg5=" " end
                if Bouton[i].Commande_Os ~= "" then
                    Bouton[i].Commande_Os=Bouton[i].Commande_Os:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
                    print(Bouton[i].Commande_Os)
                    os.execute(Bouton[i].Commande_Os)
                end
                if Bouton[i].Commande_Conky ~= "" then
                    Bouton[i].Commande_Conky=Bouton[i].Commande_Conky:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
                    conky_parse( "${"..Bouton[i].Commande_Os.."}")
                end
            end
        end
        collectgarbage()
    end
    return ""
end

function clickfunction()
    local xdot, geometry ,s ,f , click, mousex, mousey, localx, localy
    --start click logging and calculations ##########################################
    if start==1 then
        xdot=os.execute("exec ps ax | awk '/ xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation / {print $1}'")
        if tonumber(xdot)==1 then
            os.execute("kill "..xdot)
        end
        os.execute("xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation >> /tmp/xdo &")
        start=nil
        local f = io.popen("xwininfo -name '"..Fenetre.."' | grep 'Absolute'")
        geometry = f:read("*a")
        f:close()
        geometry=string.gsub(geometry,"[\n]","")
        s,f,abstlx=string.find(geometry,"X%p%s*(%d*)")
        s,f,abstly=string.find(geometry,"Y%p%s*(%d*)")
    end--if start=1 ######################################
    --click calculations #################################
    local f=io.open("/tmp/xdo")
    click=f:read()
    f:close()
    if click~=nil then
        local f = io.open("/tmp/xdo","w")
        f:write("")
        f:close()
    end--if click=nil
    if click==nil then click="x:0 y:0 " end
    s,f,mousex=string.find(click,"x%p(%d*)%s")
    s,f,mousey=string.find(click,"y%p(%d*)%s")
    mousex=tonumber(mousex)
    mousey=tonumber(mousey)
    localx=mousex-abstlx
    localy=mousey-abstly
    --END CLICK CALCULATIONS #################################
    return localx,localy,mousex,mousey
end--function

.conkyrc

#le conky appelant doit avoir sa propre fenêtre et un nom
own_window_title Cube
#definition du type de fenetre, et des décorations
own_window_argb_visual yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
#définition de la taille, et de la position du conky
minimum_size 135 135

alignment ml
gap_x 10
gap_y 10
#vitesse de rotation du cube
update_interval 0.15
# réglage de la mémoire, pour éviter le clignotement
double_buffer yes
# Soustraire les mémoires tampons de la mémoire utilisée
no_buffers yes
text_buffer_size 1024

lua_load ~/essai/Clic_info.lua
lua_load ~/essai/gif.lua
TEXT
Conky animation with images
${lua click}
${lua gif ~/essai/ gif 0 15 135 135}

pour info si tu fait des essais de positions, pense a tuer xdotool sinon il vas être lancé plusieurs fois

killall xdotool

j'ai donc déplacé le conky au milieux a gauche, il me semble que c'est ce que tu souhaitais wink

P.S. : pense a redimensionner tes images a la taille d'affichage souhaité, sa limitera l'utilisation de ton processeur

Dernière modification par Didier-T (Le 23/03/2014, à 19:03)

Hors ligne

#487 Le 23/03/2014, à 09:15

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Didier-T a écrit :

Bonsoir jlfh0816,
la commande que tu utilise est bonne, mais peut être devrais-tu allonger le délais, en le passant a 15 secondes par exemple.

j'adore le travail de mrpeachy, mais je suis une burne en anglais, mais bon, je n'ai pas besoins de le comprendre pour apprécier ses scripts.
je me suis permis de modifier un peut son script, ce serait gentils de ta part de lui montrer la modification, je pense que sa lui plaira wink

Bonjour Didier_T,

Une nouvelle fois, un très grand merci de ton travail. Je transmets bien entendu à mrpeachy de ta part. Je suis certain qu'il appréciera ton travail. Et pour l'anglais, rassures-toi, je me fais aider car de moi-même je suis resté assez scolaire. Ma grande chance, c'est d'avoir à la maison un fils qui maîtrise, ça aide beaucoup ! wink

Pour ma part, j'essaierai cet après-midi toutes les modifications que tu m'as si gentiment proposées (ce matin, c'est marché, famille .... et élections ! ) et je ne manquerai pas de te dire comment tout cela a fonctionné.

Très bon dimanche !   big_smile


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#488 Le 23/03/2014, à 11:18

alfe08

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Bonjour,

Depuis que je suis passé à Ubuntu  13.10, si je mets : own_window_type override

Après quelques minutes, le fond de conky devient blanc :
84651.jpeg

Et les commandes "upspeedf" & "downspeedf" ne donnent plus d'info sur le trafic ?

Avez-vous des suggestions roll

Voici mon conky, et merci d'avance....

# temps pour fermer conky en secondes. 0 = toujours actif 
total_run_times 0

# affiche le texte sur la sortie standard
out_to_console no

# réglage de la mémoire, pour éviter le clignotement
double_buffer yes
# Soustraire les mémoires tampons de la mémoire utilisée
no_buffers yes
text_buffer_size 2048 #512#1024

# taux de rafraichissement de la fenêtre (en secondes)
update_interval 1

# nombre d'échantillons à utiliser pour calculer la moyenne d'utilisation
cpu_avg_samples 4
net_avg_samples 2

# taille et positon
alignment top_left	#Position sur l'écran : top_left (haut gauche), top_right (haut droit), bottom_left (bas
minimum_size 360 200	#Taille minimale de la fenêtre
maximum_width 360 200	#Largeur maximale de la fenêtre
gap_x 80		#Écart avec le bord gauche ou droit de l'écran
gap_y 5			#Écart avec le bord haut ou bas de l'écran

#  afficher les ombres
draw_shades no
# afficher des contours
draw_outline no
# contours autour des blocs de texte
draw_borders no
#Afficher des bordures autour du graphe
draw_graph_borders yes		
# largeur du contour
border_width 1
# largeur des marges
border_margin 4
#Largeur des marges intérieur (en pixel)
border_inner_margin 0	
#Largeur des marges externe (en pixel)
border_outer_margin 0	

#pour que conky tourne en arrière plan background no pour les tests
background yes

# utiliser sa propre fenêtre
own_window yes
#type de fenêtre : normal(avec le cadre) / override / desktop
own_window_type override # normal / override / desktop
#pseudo transparence si vous avez des icones sous le conky elle ne seront plus accessibles une fois Conky activé
own_window_transparent yes

# Utiliser Xft (polices lissées etc)
use_xft yes
xftalpha  0.8			#Transparence de la police Xft. Valeurs entre 0 et 1 inclus.
override_utf8_locale yes # force UTF8

#police a utiliser : use_xft doit être a "yes"
xftfont   DejaVu Sans Mono:bold:size=10		#Police Xft à utiliser #Fixed:size=7#OCR A Std:size=6
# Tout le texte en majuscule
uppercase no

# Ajoute des espaces après certains objets pour éviter de les faire bouger.
# Fonctionne uniquement avec les polices Fixes
use_spacer right #yes #

# Couleurs
default_color DCDCDC	#Couleur par défaut
default_shade_color 94959C	#Couleur de l'ombre par défaut
default_outline_color black	#Couleur de contour par défaut

color0 FF000C			# définition des couleurs "0 - 1 - 2 -3 - ect..
color1 708094			#
color2 E7E1D6			#
color3 FF931C			#
color4 FF5900			#
color5 FFFFFF			#
color6 ffcb48			#
color7 DCDCDC			#

TEXT
${image /home/alfe/.conky/Icones/ubuntu-64.png -p 5,30 -s 40x40}
${voffset 17}${goto 85}${font Bitstream Vera Sans Mono:style=Bold:size=14}${color6} ${pre_exec lsb_release -si} ${pre_exec lsb_release -sr} ${pre_exec lsb_release -sc}
${color2}${alignr 45}${voffset 1}${font OpenLogos:size=15}t${font}${voffset -8} ${kernel}
${color6}${hr 0.5}${color2}
${voffset 2}${font Poky:size=10}c${font}${goto 30}${execi 8 lspci | grep VGA | cut -c36-42} ${execi 8 lspci | grep VGA | cut -c62-76} ${alignr}${voffset -3}${font Weather:size=14}y${font} ${voffset -3}${execi 60 nvidia-settings -query GPUCoreTemp | perl -ne 'print $1 if /GPUCoreTemp.*?: (\d+)./;' | cut -c1-2} °C
${goto 30}Pilote : ${execi 8 lspci | grep VGA | cut -c36-42}${execi 300 ~/.conky/scripts/nvidia-version.sh}
${voffset 6}${font StyleBats:size=14}g${font}${goto 30}RAM : ${mem}${goto 150}${memgraph 12,95 0000ff 00ff00}${alignr +2}$memperc%  ${alignr}${voffset -3}${font Weather:size=14}y${font} ${hwmon 0 temp 1}°C
${voffset 4}${color2}${voffset 6}${font StyleBats:size=14}A${font}${goto 30}CPU : ${freq_g}GHz${goto 150}${cpugraph 12,95 0000ff 00ff00}${alignr +2}${cpu cpu0}%  ${alignr}${voffset -3}${font Weather:size=14}y${font} ${exec expr `cat /sys/class/hwmon/hwmon0/temp2_input` / 1000} °C
${color6}${hr 0.5}${color2}
${voffset 6}${color7}Utilisation Core 1: ${cpu cpu1}% ${goto 190}${cpubar cpu1 10,170}
${voffset 3}${color7}            Core 2: ${cpu cpu2}% ${goto 190}${cpubar cpu2 10,170}
${voffset 3}${color7}            Core 3: ${cpu cpu3}% ${goto 190}${cpubar cpu3 10,170}
${voffset 3}${color7}            Core 4: ${cpu cpu4}% ${goto 190}${cpubar cpu4 10,170}
${voffset 3}${color7}            Core 5: ${cpu cpu5}% ${goto 190}${cpubar cpu5 10,170}
${voffset 3}${color7}            Core 6: ${cpu cpu6}% ${goto 190}${cpubar cpu6 10,170}
${voffset 3}${color7}            Core 7: ${cpu cpu7}% ${goto 190}${cpubar cpu7 10,170}
${color6}${hr 0.5}${color2}
${voffset 3}${font Poky:size=14}a${font}${goto 30}${voffset -9}${color2}$processes Processus${alignr}dont${color7} $running_processes en cours
${goto 30}Depuis :${alignr}${uptime}
${goto 30}${voffset -5}${hr 0.5}
${goto 190}${voffset -3}cpu${goto 260}mem${alignr 5}pid
${goto 30}${color2}${top name 1}${goto 165}${top cpu 1}%${goto 235}${top mem 1}%${alignr}${top pid 1}
${goto 30}${color1}${top name 2}${goto 165}${top cpu 2}%${goto 235}${top mem 2}%${alignr}${top pid 2}
${goto 30}${top name 3}${goto 165}${top cpu 3}%${goto 235}${top mem 3}%${alignr}${top pid 3}
${goto 30}${top name 4}${goto 165}${top cpu 4}%${goto 235}${top mem 4}%${alignr}${top pid 4}
${goto 30}${top name 5}${goto 165}${top cpu 5}%${goto 235}${top mem 2}%${alignr}${top pid 5}
${goto 30}${top name 6}${goto 165}${top cpu 6}%${goto 235}${top mem 2}%${alignr}${top pid 6}${color2}
${voffset 4}${color6}Espace Disques ${hr 1}${color2}
    Système  :    ${fs_free /}/${fs_size /} $alignr${fs_used_perc /}% 
    ${fs_bar /}
    Home     :    ${fs_free /home}/${fs_size /home} $alignr${fs_used_perc /home}% 
    ${fs_bar /home}
    Divers      :    ${fs_free /mnt/Divers}/${fs_size /mnt/Divers} $alignr${fs_used_perc /mnt/Divers}% 
    ${fs_bar /mnt/Divers}
    Jeux     :    ${fs_free /mnt/Jeux}/${fs_size /mnt/Jeux} $alignr${fs_used_perc /mnt/Jeux}% 
    ${fs_bar /mnt/Jeux}
    Media    :    ${fs_free /mnt/Media}/${fs_size /mnt/Media} $alignr${fs_used_perc /mnt/Media}% 
    ${fs_bar /mnt/Media}
    Transfert :    ${fs_free /mnt/Transfert}/${fs_size /mnt/Transfert} $alignr${fs_used_perc /mnt/Transfert}% 
    ${fs_bar /mnt/Transfert}
${voffset 2}${color6}Réseau ${hr 1}${color2}
${if_existing /proc/net/route wlan0}
${voffset -12}${goto 1}${font VariShapes Solid:size=10}q${font}${goto 30}Up   : ${upspeedf wlan0}k/s / ${totalup wlan0}${alignr}${upspeedgraph wlan0 10,80 F57900 FCAF3E}
${voffset 4}${goto 1}${font VariShapes Solid:size=10}Q${font}${goto 30}Down : ${downspeedf wlan0}k/s / ${totaldown wlan0}${alignr}${downspeedgraph wlan0 10,80 F57900 FCAF3E}
${voffset 4}${goto 3}${font Martin Vogel's Symbols:size=14}H${font}${goto 30}Signal    : ${wireless_link_qual wlan0}% ${alignr}${wireless_link_bar 10,80 wlan0}
${voffset 4}${font Poky:size=10}w${font}${goto 30}IP Local  : ${addr wlan0}
${voffset 4}${goto 30}IP Public : ${execi 1 ~/.conky/scripts/ip.sh}
${else}${if_existing /proc/net/route eth0}
${voffset -12}${font VariShapes Solid:size=10}q${font}${goto 30}${goto 30}Up   : ${upspeedf eth0}k/s / ${totalup eth0}${alignr}${upspeedgraph eth0 10,80 F57900 FCAF3E}
${voffset 4}${font VariShapes Solid:size=10}Q${font}${goto 30}Down : ${downspeedf eth0}k/s / ${totaldown eth0}${alignr}${downspeedgraph eth0 10,80 F57900 FCAF3E}
${voffset 4}${font Poky:size=10}w${font}${goto 30}Ip Local  : ${addr eth0}
${voffset 4}${goto 30}Ip Public : ${execi 1 ~/.conky/scripts/ip.sh}
${endif}${else}
${font DejaVu Sans Mono:size=10}4${font}   Network Unavailable${endif}
${voffset -12}${color6}Port(s) ouvert(s): ${color2}${tcp_portmon 1 65535 count}
${tcp_portmon 1 65535 rhost 0}
${tcp_portmon 1 65535 rhost 1}
${tcp_portmon 1 65535 rhost 2}
${tcp_portmon 1 65535 rhost 3}
${tcp_portmon 1 65535 rhost 4}
${tcp_portmon 1 65535 rhost 5}

84666.jpeg


Ubuntu 13.10 sur PC composé - CM "MSI Z87-G45 Gaming" & CG "MSI GeForce GTX 770 Lightning"
Kubuntu 13.04 sur EeePc 1001PXD

Hors ligne

#489 Le 23/03/2014, à 17:19

loutch

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

smilies%20(204).gif

Je suis en train de modifier un chrono lua trouvé sur le net  et je me perd dans le script impossible d'ajouter un cercle sur les trois autres parties du chrono comme j'ai réussi à le faire sur la petite horloge du bas et le contour général.

Merci d'avance pour toute aide .

Une imge et le code lua :

1395591138.png

 
--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
 21 Jun 2012 - Chronograph modifications by Sector11
 22 Jun 2012 - again with mrpeachy's help day names, numbers and month names
 23 Jun 2012 - crono.lua by mrprachy - modified by Sector11 23/24 Jun 2012
 24 Jun 2012 - crono_mix - combination of Cronograph.lua and modified crono.lua

use in conkyrc

lua_load /path/crono_mix.lua
lua_draw_hook_pre main
TEXT

-- INDEX (use find with):

-- ###### 12 OR 24 CLOCK FACE
-- SET BORDER OPTIONS ######  ALL CLOCKS

-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
-- CLOCK A ###### 24 HR TIME

-- ### START DIAL B ### Top - Week Day Names Dial #########
-- ### START DIAL C ### Right - Month Names Dial ##########
-- ### START DIAL D ### Left - Day Numbers Dial ###########

-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
-- CLOCK E HOUR HAND
-- CLOCK E MINUTE HAND SETUP
-- CLOCK E SECOND HAND SETUP
-- CLOCK E ###### 12 HR TIME

TO GET MONTH NAME WHERE THE HOUR # IS FOR THAT MONTH
 mrpeachy wrote:

    the numbers are drawn using a for loop somewhere, like this

    for i=1,12 do
    calculate position of number
    move_to(x,y)
    show_text(i)
    end

    change it to something like this

    for i=1,12 do
    calculate position of number
      if i==month_number then
      move_to(x,y)
      show_text(month_number)
      else
      move_to(x,y)
      show_text(i)
      end
    end ]]


require 'cairo'

function conky_main()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
-- ### SETTINGS AREA ######################################
-- ###### 12 OR 24 CLOCK FACE #############################
local clock_type_A=24 -- Large Main 24 HR Clock
local clock_type_E=12 -- Bottom - 12 HR Clock

-- ###### CLOCK SETTINGS ##################################
-- SET BORDER OPTIONS FOR "CLOCKS" ########################
local clock_border_width=2
-- set color and alpha for clock border
local cbr,cbg,cbb,cba=0,0,0,1  -- full opaque white
-- gap from clock border to minute marks
local b_to_m=1

-- ########################################################
-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=24
-- set mark length
local m_length_A=0
-- set mark width
local m_width_A=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,1-- opaque white
-- SETUP HOUR HANDS
-- CLOCK A HOUR HAND
-- longueur aiguille verte
hh_length_A=130
-- épaisseur aiguille verte
hh_width_A=5
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- couleur aiguille verte
hhr,hhg,hhb,hha=0,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS
-- CLOCK A MINUTE HAND SETUP
-- longueur aiguille bleue
mh_length_A=150
-- largeur aiguille bleue +point 
mh_width_A=3.2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=0,0,1,1-- fully opaque white
-- SETUP SECOND HANDS
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
sh_length_A=160
-- set hour hand width
sh_width_A=1
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
shr,shg,shb,sha=1,0,0,1-- fully opaque red
-- CLOCK A ###### 24 HR TIME
-- position grand cercle noir
clock_radius=172
clock_centerx=176
clock_centery=175
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A
-- set line cap type
cairo_set_line_cap  (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_A)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end-- of for loop
-- HOUR MARKS
-- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds just as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
--[[ DRAW SECOND HAND
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr) ]]
-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=175
local radius=160
-- FONT
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 16)
cairo_set_source_rgba (cr,0,0,0,1)
-- TABLE OF TEXT -- in order
text_days={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
for i=1,24 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/24)*(i-1))
local x=-1+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- position points grand horloge
local radius=149
for i=1,24 do
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- ### END CLOCK A ########################################

-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- days of week
-- positioning
local center_x=175
local center_y=90
local radius=45
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,1,1,1,1)
-- table holds text you want to see in order
text_days={"DIM","LUN","JEU","MER","JEU","VEN","SAM",}
-- draw days
local tx_deg=35
for i=1,7 do
start=((360/7)*(i-1))-(tx_deg/2)
circlewriting (text_days[i], "URW Chancery L", 12, radius, center_x, center_y, {0x000000,1}, start, start+tx_deg)
end
--draw points, radius smaller than text circle

local radius=40
for i=1,7 do
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
--draw hand pointing to current day
local hand_length=40--radius for this calculation
local day_number=tonumber(os.date("%w"))
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK B ########################################

-- ########################################################
-- ### START DIAL C ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=260
local center_y=175
local radius=45
cairo_select_font_face (cr, "", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,1,1,1,1)
-- table holds text you want to see in order
text_days={"DEC","JAN","FEV","MAR","AVR","MAI","JUN","JUL","AOU","SEP","OCT","NOV",}
-- draw days
local tx_deg=20
for i=1,12 do
start=((360/12)*(i-1))-(tx_deg/2)
circlewriting (text_days[i], "URW Chancery L", 12, radius, center_x, center_y, {0x000000,1}, start, start+tx_deg)
end
--draw points, radius smaller than text circle

local radius=40
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
--draw hand pointing to current day
local hand_length=35 --radius for this calculation
local day_number=tonumber(os.date("%m"))
local point=(math.pi/180)*((360/12)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK C ########################################

-- ### START DIAL D ### Left - Day Numbers Dial ###########
-- GET NUMBER OF DAYS IN CURRENT MONTH
-- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
-- MONTH TABLE
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]
-- TEXT positioning
local center_x=95
local center_y=175
local radius=50
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 8)
cairo_set_source_rgba (cr,0,0,0,1)
for i=1,number_days do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=i
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=40
for i=1,number_days do
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current DAY
local this_day=tonumber(os.date("%d"))
local hand_length=35--radius for this calculation
local point=(math.pi/180)*((360/number_days)*(this_day-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK D ########################################

-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,0,0,1-- opaque white
-- SETUP HOUR HAND
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=30
-- set hour hand width
hh_width_E=3
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=0.3,  0.6,  0.9  ,1 -- fully opaque lightblue
-- SETUP MINUTE HAND
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=45
-- set minute hand width
mh_width_E=3
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=0.0,  0.6,  0.9  ,1 -- fully opaque lightblue
-- SETUP SECOND HAND
-- CLOCK E SECOND HAND SETUP
-- longueur troteuse petite montre
sh_length_E=50
-- grosseur points petite montre + trotteuse
sh_width_E=2
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- couleur trotteuse petite montre
shr,shg,shb,sha=1,0,0,1 -- fully opaque red
-- CLOCK E ###### 12 HR TIME
-- CLOCK SETTINGS
clock_radius=53
clock_centerx=176
clock_centery=260
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_E
-- set line cap type
cairo_set_line_cap  (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end-- of for loop
-- TIME CALCULATIONS CLOCK E
if clock_type_E==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_E==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND
-- get hours minutes seconds as just seconds and draw it
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_E))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_E)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_E)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_E)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr)
-- POSITION texte petite montre
local center_x=175
local center_y=260
local radius=45
-- FONT
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,0,0,0,1)
-- TABLE OF TEXT -- in order
--text_days={"12","01","02","03","04","05","06","07","08","09","10","11",}
-- FOR A 12 HOUR CLOCK WITH THE NUMBERS 13-00
text_days={"00","01","02","03","04","05","06","07","08","09","10","11",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- position point petite montre
local radius=36
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- ### END CLOCK E ########################################

-- ########################################################
end-- end main function

function circlewriting(text, font, fsize, radi, horiz, verti, text_color, start, finish)
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
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,rgb_to_r_g_b(text_color));
local inum=string.len(text)
local deg=(finish-start)/(inum)
local r2d=(math.pi/180)
	for i=1,inum do
	local cha=string.sub(text,i,i)
	local interval=(r2d*(start+(deg*(i-1))))
	local txs=0+radi*(math.sin(interval))
	local tys=0-radi*(math.cos(interval))
	cairo_move_to (cr, txs+horiz, tys+verti);
	cairo_rotate (cr, interval)
	cairo_show_text (cr, cha)
	cairo_stroke (cr)
	cairo_rotate (cr, -interval)
	end
end--of function


smilies%20(1).gif

Dernière modification par loutch (Le 23/03/2014, à 17:20)

Hors ligne

#490 Le 23/03/2014, à 18:53

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@ Didier_T

Bon, j'ai passé une bonne partie de l'après-midi sur le conky animé cliquable et ça ne marche qu'à moitié...
Au départ, ça ne marchait même pas du tout jusqu'à ce que je m'aperçoive que tu avais changé le nom de ton script lua qui sert au clic. Dans le .conkyrc, tu l'as appelé Click_info.lua alors que partout ailleurs tu l'appelles Clic_info.lua. En le renommant Click.info.lua, le clic refonctionne et j'ai bien un conky cliquable que tu as par ailleurs eu la gentillesse de positionner au bon endroit sur l'écran ( merci, j'apprécie beaucoup !  smile )

Par contre, rien à faire avec le script de mrpeachy modifié, mon conky reste désespérément fixe, aucune animation.
J'ai vérifié dans ~/temp  : j'y ai bien placé le gif animé (appelé cube.gif) qu'il faut décomposer mais aucune décomposition ne s'effectue en gif.001, gif.002, gif.003, etc ...

Je te renvoie ce que j'utilise comme fichiers gif.lua et .conkyrc après y avoir adapté mes chemins. Ai-je commis une bourde quelque part ?
Est-ce que j'ai fait des erreurs dans les chemins ? J'avoue que je n'ai pas trop compris ce que tu veux dire par remplacer les espaces dans le chemin du répertoire par %20. De quels espaces s'agit-il ?

Par ailleurs, toujours dans le gif.lua, j'ai été obligé de remplacer --unoptimize par --colors=255 car c'était le conseil que me donnait le terminal lorsque je veux décomposer manuellement le gif animé (--unoptimize ne peut fonctionner d'après le terminal)

Le lua m'a l'air bien difficile et coton à régler !

Voici le gif.lua que j'ai adapté à mes chemins :

--[[
Script gif.lua
By mrpeachy
Modifier le 22/03/2014 par Didier-T
 prise en charge du contenu complet d'un répertoire avec choix de format (jpg, gif, etc...)
 prise en charge des racourcis ~ et $HOME, ainsi que des espaces dans le chemin du repertoire

#############################################################################################
#                                                                                           #
#                                           Usage                                           #
#                                                                                           #
#############################################################################################
#                                                                                           #
# lua_load ~/gif.lua                                                                        #
# TEXT                                                                                      #
# ${lua gif repertoire format pos_x pos_y largeur hauteur}                                  #
#                                                                                           #
#############################################################################################
remplacer les espaces par %20 pour le chemin du repertoire

]]--
--gifsicle --colors=255 --explode /home/jlfh0816/temp/cube.gif --output /home/jlfh0816/temp/temp.gif
require 'cairo'
require 'imlib2'
ini=0
count=0
fichier={}
function conky_gif(rep,ext,x,y,w,h)
    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 ini==0 then fichier=init(rep, ext) end

    show_image=fichier[count]

    if count<table.getn(fichier) then
        count=count+1
    else
        count=0
    end
    image({x=x,y=y,w=w,h=h,file=show_image,decache=1})
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
    return ""
end-- end main function

function init(rep, ext)
    ini=1
    local home = os.getenv("HOME")
    rep = string.gsub(rep, "~", home)
    rep = string.gsub(rep, "$HOME", home)
    rep=string.gsub(rep, '%%20', "\\ ")
    local file=conky_parse("${exec find "..rep.."/*."..ext.." -type f -print}")
    return file:split('\n')
end

-- Fonction de découpage maison
function string:split(pat)
    -- Détermination du caractère séparant les champs pour le découpage
    -- Par défaut ce sera espace
    pat = pat or '%s+'
    local tab = {}
    local x=0
    for i in self:gmatch("([^"..pat.."]+)") do
        tab[x]=i
        x=x+1
    end
    return tab
end

function image(im)--#######################################################################################
    local x=(im.x or 0)
    local y=(im.y or 0)
    local w=(im.w or 50)
    local h=(im.h or 50)
    local file=tostring(im.file)
    local decache=im.decache or 0
    if file==nil then print("set image file") end
    ---------------------------------------------
    local show = imlib_load_image(file)
    if show == nil then return end
    imlib_context_set_image(show)
    if tonumber(w)==0 then
        width=imlib_image_get_width()
    else
        width=tonumber(w)
    end
    if tonumber(h)==0 then
        height=imlib_image_get_height()
    else
        height=tonumber(h)
    end
    imlib_context_set_image(show)
    local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
    if decache==1 then
        imlib_free_image_and_decache()
    else
        imlib_free_image()
    end
    imlib_context_set_image(scaled)
    imlib_render_image_on_drawable(x,y)
    imlib_free_image()
end--function image

et le .conkyrc:

#le conky appelant doit avoir sa propre fenêtre et un nom
own_window_title Cube
#definition du type de fenetre, et des décorations
own_window_argb_visual yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
#définition de la taille, et de la position du conky
minimum_size 135 135

alignment ml
gap_x 10
gap_y 10
#vitesse de rotation du cube
update_interval 0.15
# réglage de la mémoire, pour éviter le clignotement
double_buffer yes
# Soustraire les mémoires tampons de la mémoire utilisée
no_buffers yes
text_buffer_size 1024

lua_load ~/essai/Click_info.lua
lua_load ~/essai/gif.lua
TEXT
#Conky animation with images
${lua click}
${lua gif ~/essai/ gif 0 15 135 135}

Dans le gif.lua, il y a ces deux lignes au début:

require 'cairo'
require 'imlib2'

Est-ce que ça veut dire qu'il faut que je télécharge des paquets appelés cairo et imlib2  ? Je ne les ai pas trouvé dans la logithèque Ubuntu ni par Synaptic ...

Je suis désolé d'avoir encore à te solliciter Didier_T, j'ai mauvaise conscience ... mais je n'y arriverai pas tout seul. Merci par avance de ton aide

Jean-Luc


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#491 Le 23/03/2014, à 19:02

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Bonsoir jlfh0816,
en fait il ne faut modifier que le .conkyrc
cette ligne ci pour être précis.

${lua gif ~/essai/ gif 0 15 135 135}

sa donnerais pour toi

${lua gif ~/temp gif.* 0 15 135 135}

par contre le script de mrpeachy ne décompose pas le gif animé

en fait gifsicle est un programme linux présent dans les dépots ubuntu

Dernière modification par Didier-T (Le 23/03/2014, à 19:12)

Hors ligne

#492 Le 23/03/2014, à 20:53

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Didier-T a écrit :

Bonsoir jlfh0816,
en fait il ne faut modifier que le .conkyrc
cette ligne ci pour être précis.

${lua gif ~/essai/ gif 0 15 135 135}

sa donnerais pour toi

${lua gif ~/temp gif.* 0 15 135 135}

Bonsoir Didier_T,
J'ai fait comme tu m'as dit mais plus rien ce s'affiche maintenant à l'écran. Voici ce que me répond le terminal:

jlfh0816 @ Voyager-13-10  ~
└─ $ ▶ conky -c ~/essai/.conkyrc
Conky: desktop window (1400003) is subwindow of root window (256)
Conky: window type - normal
Conky: drawing to created window (0x4a00002)
Conky: drawing to double buffer
find: "/home/jlfh0816/temp/*.gif.*": Aucun fichier ou dossier de ce type
8387
8389

J'ai regardé ce qu'il y a dans mon dossier ~/temp : il y a 18 images gif.000 jusque gif.017 :

jlfh0816 @ Voyager-13-10  ~/temp
└─ $ ▶ ls
gif.000  gif.002  gif.004  gif.006  gif.008  gif.010  gif.012  gif.014  gif.016
gif.001  gif.003  gif.005  gif.007  gif.009  gif.011  gif.013  gif.015  gif.017
jlfh0816 @ Voyager-13-10  ~/temp
└─ $ ▶ 

J'ai refait la manip en créant un sous-dossier ~/temp/gif et j'y ai injecté également les 18 mêmes gif mais ça ne change rien

Peut-être est-ce dans la façon de nommer les gif.000 à gif.017  ? Il faut peut-être les nommer autrement ?


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#493 Le 23/03/2014, à 21:03

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

ok, je vois ou ce situe le problème.
si il n'y a que les images de ton animation dans ce répertoire, sa fonctionneras

${lua gif ~/temp .* 0 15 135 135}

Hors ligne

#494 Le 23/03/2014, à 21:21

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

@Didier-T

Tu trouveras sur ce lien la communication de ton script lua que j'ai faite à mrpeachy (c'est le post n°9).

En te remerciant à nouveau de ta disponibilité et de ta gentillesse,  big_smile

Jean-Luc

Dernière modification par jlfh0816 (Le 23/03/2014, à 21:22)


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#495 Le 24/03/2014, à 20:59

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Didier-T a écrit :

ok, je vois ou ce situe le problème.
si il n'y a que les images de ton animation dans ce répertoire, sa fonctionneras

${lua gif ~/temp .* 0 15 135 135}

Bonsoir Didier-T

Désolé, ça ne fonctionne pas mieux, j'obtiens ceci :

jlfh0816 @ Voyager-13-10  ~
└─ $ ▶ conky -c ~/essai/.conkyrc
Conky: desktop window (1400003) is subwindow of root window (256)
Conky: window type - normal
Conky: drawing to created window (0x4c00002)
Conky: drawing to double buffer
find: "/home/jlfh0816/temp/*..*": Aucun fichier ou dossier de ce type
21462
21464

Est-ce que mes fichiers gif.001, gif.002, etc ... sont mal nommés ?


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#496 Le 24/03/2014, à 21:03

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

houps,

${lua gif ~/temp * 0 15 135 135}

le point était en trop.
et pour répondre a ta question, en générale l’extension est après le point, et pas avant, donc je dirais que oui, tes fichiers sont mal nommés, mais sa n'est pas bien grave, ça devrait tout de même fonctionner wink

Hors ligne

#497 Le 24/03/2014, à 21:17

jlfh0816

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Didier-T a écrit :

houps,

${lua gif ~/temp * 0 15 135 135}

le point était en trop.
et pour répondre a ta question, en générale l’extension est après le point, et pas avant, donc je dirais que oui, tes fichiers sont mal nommés, mais sa n'est pas bien grave, ça devrait tout de même fonctionner wink

O  U  I ... enfin, ça marche      !  !  !   big_smile  big_smile  big_smile

Didier-T, je te remercie +++ de tous tes efforts et de ta disponibilité. Sans toi, jamais je n'y serai parvenu. Suis vraiment content et heureux !


Xubuntu - Voyager 18.04 et 22.04

Hors ligne

#498 Le 25/03/2014, à 20:33

Didier-T

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

bonsoir loutch,
j'ai modifié l'horloge pour que tu aies tes cercles sur tous les cadrans

--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
 21 Jun 2012 - Chronograph modifications by Sector11
 22 Jun 2012 - again with mrpeachy's help day names, numbers and month names
 23 Jun 2012 - crono.lua by mrprachy - modified by Sector11 23/24 Jun 2012
 24 Jun 2012 - crono_mix - combination of Cronograph.lua and modified crono.lua

use in conkyrc

lua_load /path/crono_mix.lua
lua_draw_hook_pre main
TEXT

-- INDEX (use find with):

-- ###### 12 OR 24 CLOCK FACE
-- SET BORDER OPTIONS ######  ALL CLOCKS

-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
-- CLOCK A ###### 24 HR TIME

-- ### START DIAL B ### Top - Week Day Names Dial #########
-- ### START DIAL C ### Right - Month Names Dial ##########
-- ### START DIAL D ### Left - Day Numbers Dial ###########

-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
-- CLOCK E HOUR HAND
-- CLOCK E MINUTE HAND SETUP
-- CLOCK E SECOND HAND SETUP
-- CLOCK E ###### 12 HR TIME

TO GET MONTH NAME WHERE THE HOUR # IS FOR THAT MONTH
 mrpeachy wrote:

    the numbers are drawn using a for loop somewhere, like this

    for i=1,12 do
    calculate position of number
    move_to(x,y)
    show_text(i)
    end

    change it to something like this

    for i=1,12 do
    calculate position of number
      if i==month_number then
      move_to(x,y)
      show_text(month_number)
      else
      move_to(x,y)
      show_text(i)
      end
    end ]]


require 'cairo'

function conky_main()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
-- ### SETTINGS AREA ######################################
-- ###### 12 OR 24 CLOCK FACE #############################
local clock_type_A=24 -- Large Main 24 HR Clock
local clock_type_E=12 -- Bottom - 12 HR Clock

-- ###### CLOCK SETTINGS ##################################
-- SET BORDER OPTIONS FOR "CLOCKS" ########################
local clock_border_width=2
-- set color and alpha for clock border
local cbr,cbg,cbb,cba=0,0,0,1  -- full opaque white
-- gap from clock border to minute marks
local b_to_m=1

-- ########################################################
-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=24
-- set mark length
local m_length_A=0
-- set mark width
local m_width_A=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,1-- opaque white
-- SETUP HOUR HANDS
-- CLOCK A HOUR HAND
-- longueur aiguille verte
hh_length_A=130
-- épaisseur aiguille verte
hh_width_A=5
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- couleur aiguille verte
hhr,hhg,hhb,hha=0,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS
-- CLOCK A MINUTE HAND SETUP
-- longueur aiguille bleue
mh_length_A=150
-- largeur aiguille bleue +point
mh_width_A=3.2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=0,0,1,1-- fully opaque white
-- SETUP SECOND HANDS
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
sh_length_A=160
-- set hour hand width
sh_width_A=1
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
shr,shg,shb,sha=1,0,0,1-- fully opaque red
-- CLOCK A ###### 24 HR TIME
-- position grand cercle noir
clock_radius=172
clock_centerx=175
clock_centery=175
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A
-- set line cap type
cairo_set_line_cap  (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_A)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end-- of for loop
-- HOUR MARKS
-- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds just as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
--[[ DRAW SECOND HAND
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr) ]]
-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=175
local radius=160
-- FONT
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 16)
cairo_set_source_rgba (cr,0,0,0,1)
-- TABLE OF TEXT -- in order
text_days={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
for i=1,24 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/24)*(i-1))
local x=-1+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- position points grand horloge
local radius=149
for i=1,24 do
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- ### END CLOCK A ########################################

-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- days of week
-- positioning
local center_x=175
local center_y=87
local radius=45
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,1,1,1,1)
-- table holds text you want to see in order
text_days={"DIM","LUN","JEU","MER","JEU","VEN","SAM",}
-- draw days
local tx_deg=35
for i=1,7 do
start=((360/7)*(i-1))-(tx_deg/2)
circlewriting (text_days[i], "URW Chancery L", 12, radius, center_x, center_y, {0x000000,1}, start, start+tx_deg)
end
-- SET BORDER OPTIONS ########################
local border_width=2
radius=radius+12
-- set color and alpha for border
local cbr,cbg,cbb,cba=0,0,0,1  -- full opaque white
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,border_width)
cairo_arc (cr,center_x,center_y,radius,0,2*math.pi)
cairo_stroke (cr)

--draw points, radius smaller than text circle

local radius=40
for i=1,7 do
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
--draw hand pointing to current day
local hand_length=40--radius for this calculation
local day_number=tonumber(os.date("%w"))
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK B ########################################

-- ########################################################
-- ### START DIAL C ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=261
local center_y=175
local radius=45
cairo_select_font_face (cr, "", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,1,1,1,1)
-- table holds text you want to see in order
text_days={"DEC","JAN","FEV","MAR","AVR","MAI","JUN","JUL","AOU","SEP","OCT","NOV",}
-- draw days
local tx_deg=20
for i=1,12 do
start=((360/12)*(i-1))-(tx_deg/2)
circlewriting (text_days[i], "URW Chancery L", 12, radius, center_x, center_y, {0x000000,1}, start, start+tx_deg)
end
-- SET BORDER OPTIONS ########################
local border_width=2
radius=radius+12
-- set color and alpha for border
local cbr,cbg,cbb,cba=0,0,0,1  -- full opaque white
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,border_width)
cairo_arc (cr,center_x,center_y,radius,0,2*math.pi)
cairo_stroke (cr)

--draw points, radius smaller than text circle

local radius=40
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
--draw hand pointing to current day
local hand_length=35 --radius for this calculation
local day_number=tonumber(os.date("%m"))
local point=(math.pi/180)*((360/12)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK C ########################################

-- ### START DIAL D ### Left - Day Numbers Dial ###########
-- GET NUMBER OF DAYS IN CURRENT MONTH
-- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
-- MONTH TABLE
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]
-- TEXT positioning
local center_x=87
local center_y=175
local radius=50
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 8)
cairo_set_source_rgba (cr,0,0,0,1)
for i=1,number_days do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=i
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- SET BORDER OPTIONS ########################
local border_width=2
radius=radius+8
-- set color and alpha for border
local cbr,cbg,cbb,cba=0,0,0,1  -- full opaque white
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,border_width)
cairo_arc (cr,center_x,center_y,radius,0,2*math.pi)
cairo_stroke (cr)

-- INNER POINTS POSITION, radius smaller than text circle
local radius=40
for i=1,number_days do
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current DAY
local this_day=tonumber(os.date("%d"))
local hand_length=35--radius for this calculation
local point=(math.pi/180)*((360/number_days)*(this_day-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK D ########################################

-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,0,0,1-- opaque white
-- SETUP HOUR HAND
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=30
-- set hour hand width
hh_width_E=3
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=0.3,  0.6,  0.9  ,1 -- fully opaque lightblue
-- SETUP MINUTE HAND
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=45
-- set minute hand width
mh_width_E=3
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=0.0,  0.6,  0.9  ,1 -- fully opaque lightblue
-- SETUP SECOND HAND
-- CLOCK E SECOND HAND SETUP
-- longueur troteuse petite montre
sh_length_E=50
-- grosseur points petite montre + trotteuse
sh_width_E=2
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- couleur trotteuse petite montre
shr,shg,shb,sha=1,0,0,1 -- fully opaque red
-- CLOCK E ###### 12 HR TIME
-- CLOCK SETTINGS
clock_radius=53
clock_centerx=176
clock_centery=261
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_E
-- set line cap type
cairo_set_line_cap  (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end-- of for loop
-- TIME CALCULATIONS CLOCK E
if clock_type_E==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_E==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND
-- get hours minutes seconds as just seconds and draw it
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_E))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_E)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_E)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_E)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr)
-- POSITION texte petite montre
local center_x=175
local center_y=260
local radius=45
-- FONT
cairo_select_font_face (cr, "URW Chancery L", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,0,0,0,1)
-- TABLE OF TEXT -- in order
--text_days={"12","01","02","03","04","05","06","07","08","09","10","11",}
-- FOR A 12 HOUR CLOCK WITH THE NUMBERS 13-00
text_days={"00","01","02","03","04","05","06","07","08","09","10","11",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- position point petite montre
local radius=36
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- ### END CLOCK E ########################################

-- ########################################################
end-- end main function

function circlewriting(text, font, fsize, radi, horiz, verti, text_color, start, finish)
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
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,rgb_to_r_g_b(text_color));
local inum=string.len(text)
local deg=(finish-start)/(inum)
local r2d=(math.pi/180)
        for i=1,inum do
        local cha=string.sub(text,i,i)
        local interval=(r2d*(start+(deg*(i-1))))
        local txs=0+radi*(math.sin(interval))
        local tys=0-radi*(math.cos(interval))
        cairo_move_to (cr, txs+horiz, tys+verti);
        cairo_rotate (cr, interval)
        cairo_show_text (cr, cha)
        cairo_stroke (cr)
        cairo_rotate (cr, -interval)
        end
end--of function

Hors ligne

#499 Le 25/03/2014, à 21:58

loutch

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Bonsoir

Didier-T

tu es le "king of the lua"  .Encore merci voici ce que cela donne (c'est 2 conky superposés avec 2 lua  )
1395781302.png

@+

Dernière modification par loutch (Le 26/03/2014, à 16:49)

Hors ligne

#500 Le 06/04/2014, à 19:50

TwistedSister

Re : [5] Conky : Postez vos conkyrc ou certaines parties intéressantes

Bonsoir, je viens de me mettre au .lua apres une petite absence mais rien ne se lance

root@rhum1:/home/pi# conky -c /home/pi/.conkyrc
Conky: desktop window (a000d4) is subwindow of root window (43)
Conky: window type - override
Conky: drawing to created window (0x1600001)
Conky: drawing to double buffer

Ca reste comme ca indéfiniement....

Hors ligne