Comment créé ses Conky ? version 1.10+ [2018]
Comment créé ses Conky ? version 1.10+ [2018]
Re -Salut les gens,
Je voudrais me mettre au conky.
Mais après pas mal de recherches j'ai du mal a trouver un tuto claire en français qui ne soit pas totalement obsolète depuis la 1.10.
Ce qui n'es pas un drame car je n'ai aucune notion des versions précédente donc je commencerais en 1.10+.
Je ne suis pas un codeur et mes connaissances se limite au .conf de Minetest et le bidouillage des Mods quand j'ai du bol et que j'ai bien "déchifré" le code.
J'arrive a me dépatouiller quand c'est écrit mais partir de rien
En doc pour du 1.10 j'ai trouver que ça :
https://github.com/brndnmtthws/conky/wi ... ne-Options
https://github.com/brndnmtthws/conky/wi ... n-Settings
https://github.com/brndnmtthws/conky/wi ... -Variables
https://github.com/brndnmtthws/conky/wiki/Lua-API
......
Je pense que ces liens contiennent toutes les infos.
Mais je vous avoue que tout en anglais la c'est chaud et du google translate ça ne le fera pas.
Tout le wiki ubuntu en français semble obsolète a première vu.
Alors es-ce que l'on a dans le forum, un(e) vrai(e) pro, à l’âme charitable et qui maîtrise l'anglais pour nous faire un tuto de la mort en français ?
Quelques explications sur :
~/user/.conky/
~/user/.conkyrc
je veux commencer simple Os, kernel, porocess, ram, reseau up/down, etc...
après les graphs en barre ou arrondi avec les % dans les graph.
Bref je sais que c'est du gros boulot de traduction et mise en page mais ce serais cool.
Pour ce qui es de :
Installer conky-all, conky-manger .....
Tout ça c'est bon, j'ai tout de fonctionnel déjà.
Je voudrais me mettre au conky.
Mais après pas mal de recherches j'ai du mal a trouver un tuto claire en français qui ne soit pas totalement obsolète depuis la 1.10.
Ce qui n'es pas un drame car je n'ai aucune notion des versions précédente donc je commencerais en 1.10+.
Je ne suis pas un codeur et mes connaissances se limite au .conf de Minetest et le bidouillage des Mods quand j'ai du bol et que j'ai bien "déchifré" le code.
J'arrive a me dépatouiller quand c'est écrit mais partir de rien
En doc pour du 1.10 j'ai trouver que ça :
https://github.com/brndnmtthws/conky/wi ... ne-Options
https://github.com/brndnmtthws/conky/wi ... n-Settings
https://github.com/brndnmtthws/conky/wi ... -Variables
https://github.com/brndnmtthws/conky/wiki/Lua-API
......
Je pense que ces liens contiennent toutes les infos.
Mais je vous avoue que tout en anglais la c'est chaud et du google translate ça ne le fera pas.
Tout le wiki ubuntu en français semble obsolète a première vu.
Alors es-ce que l'on a dans le forum, un(e) vrai(e) pro, à l’âme charitable et qui maîtrise l'anglais pour nous faire un tuto de la mort en français ?
Quelques explications sur :
~/user/.conky/
~/user/.conkyrc
je veux commencer simple Os, kernel, porocess, ram, reseau up/down, etc...
après les graphs en barre ou arrondi avec les % dans les graph.
Bref je sais que c'est du gros boulot de traduction et mise en page mais ce serais cool.
Pour ce qui es de :
Installer conky-all, conky-manger .....
Tout ça c'est bon, j'ai tout de fonctionnel déjà.
Re: Comment créé ses Conky ? version 1.10+ [2018]
hello
~/.conky/radiotray/conkyrc
~ home de l'utilisateur
./conky dossier des conky
/radiotray dossier spécifique pour radiotray
conkyrc fichier de configuration du conky
~/user/.conkyrc est il me semble le conky de départ (me souvient plus de celui-là) ici aussi pas de user puisque ~ remplace /home/user/
Pour la version 1.10 c'est pareil que la version 1.9 (a part que c'est un peu la cata avec certain conkys)
spécificité de la version 1.10
pour exemple les (presques ) mêmes conky en 1.90 et 1.10
conky 1.90
le presque même en 1.10
@+
~user/.conky/ est le dossier de tes conkys Le "user" ne sert à rien pour moi exemple conky radiotrayQuelques explications sur :
~/user/.conky/
~/user/.conkyrc
~/.conky/radiotray/conkyrc
~ home de l'utilisateur
./conky dossier des conky
/radiotray dossier spécifique pour radiotray
conkyrc fichier de configuration du conky
~/user/.conkyrc est il me semble le conky de départ (me souvient plus de celui-là) ici aussi pas de user puisque ~ remplace /home/user/
Pour la version 1.10 c'est pareil que la version 1.9 (a part que c'est un peu la cata avec certain conkys)
spécificité de la version 1.10
Code : Tout sélectionner
Mettre la partie configuration dans :
conky.config = { ... }
Mettre la partie TEXT dans :
conky.text = [[ ... ]]
Toutes les valeurs doivent être précédées de "=" dans la partie configuration
Finir chaque ligne par une virgule ","
Remplacer tous les "yes"/"no" en "true"/"false" (sans les guillemets)
Toutes les valeurs autres que nombres,"true" et "false", doivent être entre quotes (ex: use_space = 'left' )
Les commentaires doivent commencer avec "–" à la place de "#"
conky 1.90
Code : Tout sélectionner
background yes
use_xft yes
xftfont GE Inspira:size=10
xftalpha 1
update_interval 0.1
total_run_times 0
own_window yes
own_window_transparent yes
#own_window_color 000000
own_window_argb_visual yes
#own_window_argb_value 0
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 412 96
maximum_width 412
text_buffer_size 2048
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_outline_color white
alignment tl
gap_x 0
gap_y 780
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
#imlib_cache_flush_interval 60
imlib_cache_size 0
# Taille des pointillés
stippled_borders 5
# Couleurs
default_color ffffff#ffd579
default_shade_color 333333
default_outline_color black
lua_load ~/.conky/lua/image.lua
lua_load ~/.conky/radiotray/audio_spectrum.lua
lua_draw_hook_pre spectrum default 160 80 1 27 7 1 16 1 1 2f3d40 1 ff6c4a 1
TEXT
${voffset -8}${alignc -50}${font GE Inspira:size=12}${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}$font
${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio > ~/.conky/radiotray/logo.txt}
${voffset 25}${alignc -80}${font GE Inspira:size=7}${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w80 | cut -c1-50}
${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w80 > ~/.conky/radiotray/artiste_titre.txt}
${lua fDrawImage $HOME/.conky/radiotray/images/case.png 0 0 410 108}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "RTL"}${lua fDrawImage ~/.conky/radiotray/logos/rtl.png 240 26 40 40}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "HOTMIX80"}${lua fDrawImage ~/.conky/radiotray/logos/hotmix-80.png 240 28 35 35}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "MAXI80"}${lua fDrawImage ~/.conky/radiotray/logos/maxi80.png 250 29 35 35}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "RTL2"}${lua fDrawImage ~/.conky/radiotray/logos/rtl2.png 246 28 35 35}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "MAGNUM LA RADIO"}${lua fDrawImage ~/.conky/radiotray/logos/magnumradio.png 214 26 120 40}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "LOUNGERADIO"}${lua fDrawImage ~/.conky/radiotray/logos/lounge-radio.png 254 28 35 35}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "NOSTALGIE"}${lua fDrawImage ~/.conky/radiotray/logos/nostalgie.png 80 60 100 60}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "NOSTALGIE80"}${lua fDrawImage ~/.conky/radiotray/logos/nostalgie_80.png 80 60 100 60}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "LOR FM"}${lua fDrawImage ~/.conky/radiotray/logos/lorfm.png 226 10 80 80}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "181.fm"}${lua fDrawImage ~/.conky/radiotray/logos/181fm.png 244 30 45 45}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "Radio swiss pop"}${lua fDrawImage ~/.conky/radiotray/logos/rspop.png 244 30 45 45}${else}
${if_match "${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}" == "RFM"}${lua fDrawImage ~/.conky/radiotray/logos/rfm.png 247 28 35 35}${endif}
${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}
${texeci 2 ~/.conky/radiotray/pochette.sh}#${texeci 3 ~/.conky/radiotray/logo.sh}
${lua fDrawImage ~/.conky/radiotray/pochette.png 24 14 68 70}
${lua fDrawImage ~/.conky/radiotray/images/stop.png 115 31 13 13}
${lua fDrawImage ~/.conky/radiotray/images/prev.png 100 45 13 13}
${lua fDrawImage ~/.conky/radiotray/images/play.png 115 45 13 13}
${lua fDrawImage ~/.conky/radiotray/images/next.png 130 45 13 13}
${lua fDrawImage ~/.conky/radiotray/images/pause.png 115 59 13 13}
${lua fDrawImage ~/.conky/radiotray/images/bar.png 98 78 48 4}
${lua fDrawImage ~/.conky/radiotray/images/grip.png 115 78 5 5}
${lua fDrawImage ~/.conky/radiotray/images/1-play.png 155 15 10 10}
${voffset -250}
Code : Tout sélectionner
conky.config = {
background = true,
use_xft = true,
font = 'Liberation Sans:size=8',
xftalpha = 1,
update_interval = 1.0,
total_run_times = 0,
own_window = true,
own_window_transparent = true,
--own_window_color 000000
own_window_argb_visual = true,
--own_window_argb_value = 250,
own_window_type = 'normal',
own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',
double_buffer = true,
minimum_width = 200, minimum_height = 180,
--maximum_width 200
text_buffer_size = 2048,
draw_shades = false,
draw_outline = false,
draw_borders = false,
draw_graph_borders = false,
default_color = 'white',
default_outline_color = 'white',
alignment = 'top_right',
gap_x = 70,
gap_y = 10,
no_buffers = true,
uppercase = false,
cpu_avg_samples = 2,
override_utf8_locale = true,
imlib_cache_flush_interval = 60,
imlib_cache_size = 0,
-- Taille des pointillés
stippled_borders = 5,
-- Couleurs
default_color = '#ffffff',--ffd579
default_shade_color = '#333333',
default_outline_color = 'black',
lua_load = '~/LUA/image.lua',
};
conky.text = [[
${lua fDrawImage ~/.conky/radiotray/images/caset.png 00 00 150 150}
${voffset 120}${if_match "${execi 5 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w40}" == "Playing"}
${else}${execi 5 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w40 }${endif}
${execi 5 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w40 > ~/.conky/radiotray/artiste_titre.txt}
${execi 5 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio > ~/.conky/radiotray/logo.txt}
${texeci 5 ~/.conky/radiotray/pochette.sh}${texeci 2 ~/.conky/radiotray/logo.sh}
${if_match "${execi 5 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w40}" == "Playing"}${lua fDrawImage ~/.conky/radiotray/logo.png 19 19 112 112}
${else}${lua fDrawImage ~/.conky/radiotray/pochette.png 19 19 112 112}${endif}
${voffset -800}
]];
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04
Asus ROG avec xubuntu 18.04 et xubuntu 19.04
Re: Comment créé ses Conky ? version 1.10+ [2018]
alors après moult potassage
j'ai enfin bidouiller mon premier conky
j'ai du adapter les emplacement des barres et certaines infos,
rajouter le process 5 et 6
certains truc ne s'affiche pas encore a voir
et la police a agrandir c'est sur
mais je commence a choper le truc.
depuis j'ai virer l'image de fond semi transparente elle me gonflais et je n'ai pas les températures des cpu , quelqun a une idée?
j'ai enfin bidouiller mon premier conky
j'ai du adapter les emplacement des barres et certaines infos,
rajouter le process 5 et 6
certains truc ne s'affiche pas encore a voir
et la police a agrandir c'est sur
mais je commence a choper le truc.
depuis j'ai virer l'image de fond semi transparente elle me gonflais et je n'ai pas les températures des cpu , quelqun a une idée?
Code : Tout sélectionner
conky.config = {
--==============================================================================
-- conkyrc_vu-meters
-- author : CAYMUS-conkyrc_7b
-- Modified : autocrosser
-- version : v20151001-08 Modified: V20170820
-- license : Distributed under the terms of GNU GPL version 2 or later
--==============================================================================
cpu_avg_samples = 2,
net_avg_samples = 2,
temperature_unit = 'celsius',
double_buffer = true,
text_buffer_size = 2048,
update_interval = 0.5,
total_run_times = 0,
gap_x = 0,
gap_y = 0,
minimum_width = 180, minimum_height = 1050,
own_window = true,
own_window_transparent = true,
own_window_class = 'conky',
own_window_argb_visual = true,
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
background = false,
border_inner_margin = 0,
border_outer_margin = 0,
alignment = 'tl',
draw_shades = false,
draw_outline = false,
draw_borders = false,
draw_graph_borders = false,
use_spacer = 'none',
short_units = true,
override_utf8_locale = true,
use_xft = true,
font = 'Technical CE:bold:size=9',
xftalpha = 0.5,
uppercase = false,
default_color = '#ffffff',
color1 = '#888888',
color2 = '#AAAAAA',
color3 = '#DDDDDD',
color4 = '#2C2433',
lua_load = '~/.conky/conky_vu-meters.lua',
lua_draw_hook_post = 'main_bars',
};
conky.text = [[
${goto 15}${font Technical CE:bold:size=12}${color}$sysname
${goto 15}${font}${color}$kernel on $machine
${goto 15}${exec cat /etc/issue.net}
${goto 15}CPU: ${execi 1000 cat /proc/cpuinfo|grep 'model name'|sed -e 's/model name.*: //'| uniq | cut -c 1-32}
${goto 15}CPU Speed: ${exec cat /proc/cpuinfo | grep 'model name' | uniq | awk '{print $10}' }
${goto 15}UPDATES: ${color}${execi 360 aptitude search "~U" | wc -l | tail}
${goto 7}${color2}------------------------------------------------
${color}${goto 15}GPU1:${goto 65}${color}${exec nvidia-settings -t -q [gpu:0]/GPUCoreTemp} °C ${color} ${goto 125}GPU2:${goto 180}${color}${exec nvidia-settings -t -q [gpu:1]/GPUCoreTemp} °C
#${color}${goto 15}HDD1:${goto 65}${color}${hddtemp /dev/sda} °C ${color}${goto 125}HDD2: ${color}${hddtemp /dev/sdb} °C
#${color}${goto 15}HDD3:${goto 65}${color}${hddtemp /dev/sdc} °C ${color}${goto 125}HDD4: ${color}${hddtemp /dev/sdd} °C
${goto 15}${color}Core0:${goto 65}${color}${execi 30 sensors|grep 'Core 0'| awk -F'+' '{print $2}' | awk -F'.' '{print $1}'} °C ${goto 125}${color}Core1: ${color}${execi 30 sensors|grep 'Core 1'| awk -F'+' '{print $2}' | awk -F'.' '{print $1}'} °C
${goto 15}${color}Core2:${goto 65}${color}${execi 30 sensors|grep 'Core 2'| awk -F'+' '{print $2}' | awk -F'.' '{print $1}'} °C ${goto 125}${color}Core3: ${color}${execi 30 sensors|grep 'Core 3'| awk -F'+' '{print $2}' | awk -F'.' '{print $1}'} °C ${color2}
${goto 15}${color}HDD1:${goto 65}${hddtemp /dev/sda} °C ${goto 125}HDD2:${goto 180}${hddtemp /dev/sdb} °C
${goto 15}HDD3:${goto 65}${hddtemp /dev/sdc} °C ${goto 125}HDD4:${goto 180}${hddtemp /dev/sdd} °C
${goto 7}${color2}------------------------------------------------
${goto 15}${font Technical CE:bold:size=12}${color}CPU Load:
${goto 15}${font}${color}Core 1:${goto 65}${cpu cpu0}%
${goto 15}${color}Core 2:${goto 65}${cpu cpu1}%
${goto 15}${color}Core 3:${goto 65}${cpu cpu2}%
${goto 15}${color}Core 4:${goto 65}${cpu cpu3}%
${goto 15}${color}Core 5:${goto 65}${cpu cpu4}%
${goto 15}${color}Core 6:${goto 65}${cpu cpu5}%
${goto 7}${color2}------------------------------------------------
${goto 15}${top name 1}${goto 135}${top pid 1}${goto 175}${top cpu 1}%
${goto 15}${top name 2}${goto 135}${top pid 2}${goto 175}${top cpu 2}%
${goto 15}${top name 3}${goto 135}${top pid 3}${goto 175}${top cpu 3}%
${goto 15}${top name 4}${goto 135}${top pid 4}${goto 175}${top cpu 4}%
${goto 15}${top name 5}${goto 135}${top pid 5}${goto 175}${top cpu 5}%
${goto 7}${color2}------------------------------------------------
${goto 15}$processes${goto 55}Total Processes
${goto 15}$running_threads${goto 55}Running Threads
${goto 7}${color2}------------------------------------------------
${goto 15}${font Technical CE:bold:size=12}${color}Memory:
${goto 15}${font}${color}RAM${goto 55}$mem
${goto 15}System Ram:${goto 110}$memperc% of${goto 160}$memmax
${goto 15}${top_mem name 1}${goto 135}${top_mem pid 1}${goto 175}${top_mem mem 1}%
${goto 15}${top_mem name 2}${goto 135}${top_mem pid 2}${goto 175}${top_mem mem 2}%
${goto 15}${top_mem name 3}${goto 135}${top_mem pid 3}${goto 175}${top_mem mem 3}%
${goto 15}${top_mem name 4}${goto 135}${top_mem pid 4}${goto 175}${top_mem mem 4}%
${goto 15}${top_mem name 5}${goto 135}${top_mem pid 5}${goto 175}${top_mem mem 5}%
${goto 7}${color2}------------------------------------------------
${goto 15}${font Technical CE:bold:size=12}${color}Disks:
${goto 15}${font}${color}Home ${goto 56}${fs_used /home}
${goto 15}Root ${goto 58}${fs_used /}
${goto 15}EX2 ${goto 58}${fs_used /mnt/EX2}
${goto 15}EX2h ${goto 58}${fs_used /mnt/EX2home}
${goto 15}Data ${goto 58}${fs_used /media/Storage}
${goto 7}${color2}------------------------------------------------
${goto 15}${font Technical CE:bold:size=12}${color}Network:
${goto 15}${color}${font}Public:${goto 65}${execi 3600 wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]\|.]//g'}
${goto 15}Lan:${goto 65}${addr bond0}
${goto 15}Down:${goto 65}${downspeed bond0}
${goto 15}Up:${goto 65}${upspeed bond0}
${goto 15}Total Down:${goto 95}${totaldown bond0}
${goto 15}Total Up:${goto 95}${totalup bond0}
${goto 7}${color2}------------------------------------------------
${goto 15}${font Technical CE:bold:size=12}${color}Ports:
${goto 15}${font}Inbound Ports:${goto 130}${tcp_portmon 1 32767 count}
${goto 15}Outbound Ports:${goto 130}${tcp_portmon 32768 61000 count}
${goto 15}IP: ${tcp_portmon 1 65535 rip 0}
${goto 37}${tcp_portmon 1 65535 rip 1}
${goto 37}${tcp_portmon 1 65535 rip 2}
${goto 37}${tcp_portmon 1 65535 rip 3}
${goto 37}${tcp_portmon 1 65535 rip 4}
${goto 37}${tcp_portmon 1 65535 rip 5}
]];
Modifié en dernier par Toad_Fr le sam. 22 déc. 2018 19:46, modifié 5 fois.
Re: Comment créé ses Conky ? version 1.10+ [2018]
Salut
Le forum possède son propre hébergeur d'image
Il serait bien de s'en servir, histoire de mettre les images en lieu sur et de manière définitive
Merci !
Si le lien ne s’insère pas, il suffit de recommencer la manip, mais ça fini par fonctionner à coup sur
Du coup j'ai changé le lien de ton image
Le forum possède son propre hébergeur d'image
Il serait bien de s'en servir, histoire de mettre les images en lieu sur et de manière définitive
Merci !
Si le lien ne s’insère pas, il suffit de recommencer la manip, mais ça fini par fonctionner à coup sur
Du coup j'ai changé le lien de ton image
Re: Comment créé ses Conky ? version 1.10+ [2018]
ouais merci j'avais vu et meme essayer et plusieur fois mais quand je clique il ne se passe rien, forcement a moi.
Re: Comment créé ses Conky ? version 1.10+ [2018]
Salut,
Non c'est parce que ta copie faisait plus que 2 mo, je l'ai juste converti en jpeg
Non c'est parce que ta copie faisait plus que 2 mo, je l'ai juste converti en jpeg
Re: Comment créé ses Conky ? version 1.10+ [2018]
Hello
il a de la gueule le conky continue comme cela.
@+
il a de la gueule le conky continue comme cela.
@+
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04
Asus ROG avec xubuntu 18.04 et xubuntu 19.04
Re: Comment créé ses Conky ? version 1.10+ [2018]
pour mon conky actuel j'ai donc mon conkyrc et un script lua pour les barres ok tout va bien.
moi je voudrais pouvoir mettre des barres et les arrondir donc il me faut si j'ai bien compris un script genre :
rings: https://www.deviantart.com/wlourf/art/R ... -166574600
pie: https://www.deviantart.com/wlourf/art/P ... -165734819
ces deux la sont t'il vraiment différent ou non?
es- ce que l'on peut charger plusieur fichiers lua en parrallelle ou sa fou la merde?
Bargraph ça à fonctionné direct, même si j'ai du tout remettre en place dans les settings du lua ou du text conky (agrandir ...)
Mais avec ring sa me sort rien terrible.
c'est le conkyrc qui est foireux ou le lua ?
A priori selon moi , ...... j'ai rien a toucher en dehors des settings (a suposer que le script lua soit bon).
Donc:
Le conkyrc en 1.10
Le but final de ce post est d'avoir : 4 "Type"
Conky, Rings, Bargraph, (Pie?)
Ou on aurait juste a réglé de son "setting"
Donc mettre les explications en français pour commencer...
Mais directement en mise en page "code" l'explication en "-- commentaire" sur 1 SEULE exemple (parce que la, ils sont velu, j'ai peur de faire une connerie à "la coupe")
Avec éventuellement un commentaire -- NE PLUS RIEN CHANGER A PARTIR D'ICI --
Et le Noob a une base fonctionnelle réglable.
Rajoute une section a chaque barre, ring .. qu'il veut rajouter, commente les lignes qu'ils ne veut pas utiliser.... et avec du bol ...
Il fait plus chier je ne vous garranti rien.
Je mettrais a jour ce post au fur et a mesure pour éviter qu'il grossisse pour rien.
---------------------------------------------------------------------------------
- Copiez tout le code.
- Remplacez les zones sans infos, questions, par la réponse si vous l'avez.
ou ajoutez des commandes, compléments d'infos utiles genre traduction. (sur votre ide de préférence les codes sont énorme sur les lua)
- Envoyez moi le code balisé en Mp que je mette ceci a jour au fur et à mesure pour les gros noobs, naze en anglais mais pas trop débiles non plus...comme moi.
- Eviter les futurs sujets inutile... j’espère... pour tout le monde
---------------------------------------------------------------------------------
///------///------///CONKY
Code : Tout sélectionner
conky.config = {
alignment = "tl", -- Place de la fenêtre conky: top, bottom, left, middle,right ou t, b, l, m
--append_file
background = true, --Valeur booléenne, si true, Conky sera inséré en arrière-plan au démarrage.
border_inner_margin =5, --la marge entre la bordure et le texte
border_outer_margin =5, --la marge entre la bordure et le bord de la fenêtre
border_width = 1, --Largeur de la bordure
--color1 = , --definir des couleur 1, 2, 3
--console_bar_fill
--console_bar_unfill
--console_graph_ticks
cpu_avg_samples = 2, --Nombre d'échantillons pour la surveillance de la moyenne CPU.
default_bar_height= 05, --Hauteur des barres par defaut en pixels
default_bar_width = 20, --Hauteur des barres par defaut en pixels
default_color = "black" --Couleur par defaut du texte avant color1,color2...
default_gauge_height = 05, --Hauteur des gauges par defaut en pixels
default_gauge_width = 20, --Largeur des gauges par defaut en pixels
default_graph_height = 05, --Hauteur des graphs par defaut en pixels
default_graph_width = 20, --Largeur des graphs
--default_outline_color = "blue", --Couleur de contour par défaut
--default_shade_color = "red", --Couleur d'ombrage par défaut et couleur d'ombrage de la bordure
--disable_auto_reload = false, --Desactiver le rechargement automatique (de quoi)
--diskio_avg_samples
--display
double_buffer =true, --Utilisez l'extension Xdbe? (élimine le scintillement)
draw_borders = false, --Dessiner les bodures de la fenêtre conky
draw_graph_borders = false, --Dessiner les bordures des graphs
draw_outline = false, --Dessiner les contours (du texte?)
draw_shades = false, --Dessiner les ombres (du texte?)
--extra_newline
--font = "times", --Definir une police de caractere
format_human_readable = true, --affiche en Kb Mb plutot qu'en octets
gap_y
gap_x
hddtemp_host = 127.0.0.1, --Nom d'hôte auquel se connecter pour les hddtemp. La valeur par défaut est "127.0.0.1"
hddtemp_port = 7634, --Port à utiliser pour les connexions hddtemp. La valeur par défaut est 7634.
http_refresh
--if_up_strictness =
imap
--imlib_cache_flush_interval = , --Intervalle en secondes pour vider le cache Imlib2 (?)
imlib_cache_size = 0, --Taille du cache d’images mlib2, en octets. Défaut est 4 Mo (4000000). Augmentez si beaucoup "$image" 0 désactiver
--lua_draw_hook_post = ,
--lua_draw_hook_pre = ,
--lua_load = "chemin/du/fichier", --Charger des scripts lua separer par des espaces
--lua_shutdown_hook = ,
--lua_startup_hook = ,
--mail_spool
--max_port_monitor_connections
max_text_width = 10, --Largeur maximum du texte
max_user_text = 16384, --Taille maximale du tampon de la parti conky.text (défaut 16384 octets)
maximum_width = 400, --Largeur maximum de la fenêtre conky en pixels
minimum_height = 200, --Hauteur minimum de la fenêtre conky en pixels
minimum_width = 200, --Largeur minimum de la fenêtre conky en pixels
--mpd_host
--mpd_password
--mpd_port
--music_player_interval
--mysql_db
--mysql_host
--mysql_password
--mysql_port
--mysql_user
--net_avg_samples
--no_buffers
--nvidia_display
--out_to_console
--out_to_http = , --Laissez conky agir comme un petit serveur http servant son texte(?)
--out_to_ncurses
--out_to_stderr
--out_to_x
override_utf8_locale = true, --Forcer UTF8? nécessite XFT
overwrite_file
own_window
own_window_argb_value = 0, --Si visual ARGB sont activés, modifiez la valeur alpha utilisée. La plage valide entre 0/255, où 0 opacité 0% et 255/100%
own_window_argb_visual = true, --utiliser visuel ARGB?
own_window_class = "conky" --Définissez manuellement le nom WM_CLASS. La valeur par défaut est "Conky"
--own_window_colour = , --Si "own_window_transparent = false," couleur de fond du Conky
--own_window_hints
own_window_title = "titre de la fenetre", --Titre de la fenêtre conky
own_window_transparent = true, --transparence? Si ARGB Visual est activé, définit l'opacité de l'arrière-plan sur 0%.
own_window_type = "normal" --Si "own_window = true", vous pouvez spécifier le type (defaut:normal), desktop, dock, panel ou override
--pad_percents
--pop3
--short_units
--show_graph_range
--show_graph_scale
--stippled_borders
temperature_unit = "celsius", -- unité de température (ou "farenheit")
-- templateN
text_buffer_size = 256, --Taille du tampon de texte ne peut pas être inférieure à défaut 256 octets.
times_in_seconds = false, --Si true, les variables qui affichent le temps se génèrent en secondes.
top_cpu_separate = false, --Si true, cpu top montre l'utilisation de la puissance d'un processeur. Si false, cpu top montrera combinée de tous
top_name_verbose = false, --Si true, top name affiche la ligne de commande complète de chaque processus dans la mesure du possible défaut "false".
top_name_width = 15, --Largeur pour la valeur du nom "$top" défaut de 15 caractères.
total_run_times = 0, --Nombre total de mises à jour de Conky avant de quitter. 0=infini
update_interval = 0.5, --intervale de mise à jour du conky en secondes
update_interval_on_battery = 1, --intervale de mise à jour du conky quand sur batterie en secondes
--uppercase
--use_spacer
use_xft = true, --Utilisez Xft (polices anti-aliasées et autres)
--xftalpha = , --Alpha de la police Xft. Doit être une valeur égale ou comprise entre 1 et 0.
--xinerama_head = , --Spécifiez une tête Xinerama. Voir aussi display
};
conky.text = [[
commandes, (exemple:"${color}"),
texte, (ce qui sera afficher tel quel)
renvois de commandes, (exemple:"${cpu cpu0}"),
]];
Tel quel sans modif alors les settings sont charger ) :
///------///------///RINGS with SECTORS widget
Code : Tout sélectionner
--[[ RINGS with SECTORS widget
v1.1 by wlourf (07 Jan. 2011)
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display,
for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable,
for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach,
for example for {$cpu cpu0}, just write max=100
Optional parameters:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
v1.0 (08 Aug. 2010) original release
v1.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"
text is parsed inside the function, not in the array of settings
]]
require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
local rings_settings={
{--Ring 1 :hours
name="time",
arg="%H",
max=12,
xc=225,
yc=100,
int_radius=0,
radius=20,
thickness=17,
sectors=12,
gap_sectors=2,
fill_sector=true,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0XFFFF00,0},{0.5,0xFFFF00,1}, {1,0xFFFF00,0}},
bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
},
{--Ring 2 :minutes
name="time",
arg="%M",
max=60,
xc=225,
yc=100,
int_radius=20,
radius=40,
thickness=17,
sectors=60,
gap_sectors=2,
fill_sector=true,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0XFFFF00,0},{0.5,0xFFFF00,1}, {1,0xFFFF00,0}},
bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
},
{--Ring 3: Secondes
name="time",
arg="%S",
max=60,
xc=225,
yc=100,
int_radius=40,
radius=60,
thickness=17,
sectors=60,
gap_sectors=2,
fill_sector=true,
bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
fg_colour1={{0,0XFFFF00,0},{0.5,0xFFFF00,1}, {1,0xFFFF00,0}},
bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
},
};
--END OF PARAMETERS HERE
--main function
--if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display,
conky_window.drawable,
conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
draw_ring(cr,rings_settings[i])
end
end
cairo_destroy(cr)
end
function draw_ring(cr, t)
local function rgba_to_r_g_b_a(tcolour)
local colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name'" +
" with 'arg' or only parameter 'arg' ")
return
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
--initialize table
setup(t)
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
local angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
local valueA = t.max/t.sectors
--first angle of a sector :
local lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
local tcolor
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
local b0,b1
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c, angle_d
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
local d0,d1
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
Code : Tout sélectionner
--[[ BARGRAPH WIDGET
v2.1 by wlourf (07 Jan. 2011)
edited by Caymus
modified by autocrosser-20170820
this widget draws a bargraph with different effects
http://u-scripts.blogspot.com/2010/07/bargraph-widget.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/bargraph.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display, for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable, for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach, for example, for {$cpu cpu0}, just write max=100
Optional parameters:
x,y - coordinates of the starting point of the bar, default = middle of the conky window
cap - end of cap line, ossibles values are r,b,s (for round, butt, square), default="b"
http://www.cairographics.org/samples/set_line_cap/
angle - angle of rotation of the bar in degress, default = 0 (i.e. a vertical bar)
set to 90 for an horizontal bar
skew_x - skew bar around x axis, default = 0
skew_y - skew bar around y axis, default = 0
blocks - number of blocks to display for a bar (values >0) , default= 10
height - height of a block, default=10 pixels
width - width of a block, default=20 pixels
space - space between 2 blocks, default=2 pixels
angle_bar - this angle is used to draw a bar on a circular way (ok, this is no more a bar !) default=0
radius - for cicular bars, internal radius, default=0
with radius, parameter width has no more effect.
Colours below are defined into braces {colour in hexadecimal, alpha}
fg_colour - colour of a block ON, default= {0x00FF00,1}
bg_colour - colour of a block OFF, default = {0x00FF00,0.5}
alarm - threshold, values after this threshold will use alarm_colour colour , default=max
alarm_colour - colour of a block greater than alarm, default=fg_colour
smooth - (true or false), create a gradient from fg_colour to bg_colour, default=false
mid_colour - colours to add to gradient, with this syntax {position into the gradient (0 to1), colour hexa, alpha}
for example, this table {{0.25,0xff0000,1},{0.5,0x00ff00,1},{0.75,0x0000ff,1}} will add
3 colurs to gradient created by fg_colour and alarm_colour, default=no mid_colour
led_effect - add LED effects to each block, default=no led_effect
if smooth=true, led_effect is not used
possibles values : "r","a","e" for radial, parallelel, perdendicular to the bar (just try!)
led_effect has to be used with theses colours :
fg_led - middle colour of a block ON, default = fg_colour
bg_led - middle colour of a block OFF, default = bg_colour
alarm_led - middle colour of a block > ALARM, default = alarm_colour
reflection parameters, not avaimable for circular bars
reflection_alpha - add a reflection effect (values from 0 to 1) default = 0 = no reflection
other values = starting opacity
reflection_scale - scale of the reflection (default = 1 = height of text)
reflection_length - length of reflection, define where the opacity will be set to zero
calues from 0 to 1, default =1
reflection - position of reflection, relative to a vertical bar, default="b"
possibles values are : "b","t","l","r" for bottom, top, left, right
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
v1.0 (10 Feb. 2010) original release
v1.1 (13 Feb. 2010) numeric values can be passed instead conky stats with parameters name="", arg = numeric_value
v1.2 (28 Feb. 2010) just renamed the widget to bargraph
v1.3 (03 Mar. 2010) added parameters radius & angle_bar to draw the bar in a circular way
v2.0 (12 Jul. 2010) rewrite script + add reflection effects and parameters are now set into tables
v2.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation version 3 (GPLv3)
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-- MA 02110-1301, USA.
]]
require 'cairo'
----------------START OF PARAMETERS ----------
function conky_main_bars()
local bars_settings={
{
name="nvidia",
arg="temp",
max=80,
alarm=70,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=115,y=176,
blocks=20,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu0",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=312,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu1",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=327,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu2",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=342,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu3",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=357,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu4",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=372,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu5",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=387,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="memperc",
arg="",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=20,y=575,
blocks=25,
height=7,width=16,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/home",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=125,y=755,
blocks=20,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=125,y=770,
blocks=20,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/media/mickael/Cloud-1To",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=125,y=785,
blocks=20,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/media/mickael/Black Hole",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=125,y=800,
blocks=20,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/media/Storage",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=125,y=815,
blocks=20,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="downspeedf",
arg="enp27s0",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=110,y=925,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="enp27s0",
max=100,
alarm=80,
bg_colour={0x848E84,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=110,y=940,
blocks=22,
height=5,width=10,
angle=90,
smooth=true,
cap="e",
skew_y=30,
mid_colour={{0.5,0xffff00,1}}
},
}
-----------END OF PARAMETERS--------------
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
--prevent segmentation error when reading cpu state
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(bars_settings) do
draw_multi_bar_graph(bars_settings[i])
end
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end
function draw_multi_bar_graph(t)
cairo_save(cr)
--check values
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name' with 'arg' or only parameter 'arg' ")
return
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
--set default values
if t.x == nil then t.x = conky_window.width/2 end
if t.y == nil then t.y = conky_window.height/2 end
if t.blocks == nil then t.blocks=10 end
if t.height == nil then t.height=10 end
if t.angle == nil then t.angle=0 end
t.angle = t.angle*math.pi/180
--line cap style
if t.cap==nil then t.cap = "b" end
local cap="b"
for i,v in ipairs({"s","r","b"}) do
if v==t.cap then cap=v end
end
local delta=0
if t.cap=="r" or t.cap=="s" then delta = t.height end
if cap=="s" then cap = CAIRO_LINE_CAP_SQUARE
elseif cap=="r" then
cap = CAIRO_LINE_CAP_ROUND
elseif cap=="b" then
cap = CAIRO_LINE_CAP_BUTT
end
--end line cap style
--if t.led_effect == nil then t.led_effect="r" end
if t.width == nil then t.width=20 end
if t.space == nil then t.space=2 end
if t.radius == nil then t.radius=0 end
if t.angle_bar == nil then t.angle_bar=0 end
t.angle_bar = t.angle_bar*math.pi/360 --halt angle
--colours
if t.bg_colour == nil then t.bg_colour = {0x00FF00,0.5} end
if #t.bg_colour~=2 then t.bg_colour = {0x00FF00,0.5} end
if t.fg_colour == nil then t.fg_colour = {0x00FF00,1} end
if #t.fg_colour~=2 then t.fg_colour = {0x00FF00,1} end
if t.alarm_colour == nil then t.alarm_colour = t.fg_colour end
if #t.alarm_colour~=2 then t.alarm_colour = t.fg_colour end
if t.mid_colour ~= nil then
for i=1, #t.mid_colour do
if #t.mid_colour[i]~=3 then
print ("error in mid_color table")
t.mid_colour[i]={1,0xFFFFFF,1}
end
end
end
if t.bg_led ~= nil and #t.bg_led~=2 then t.bg_led = t.bg_colour end
if t.fg_led ~= nil and #t.fg_led~=2 then t.fg_led = t.fg_colour end
if t.alarm_led~= nil and #t.alarm_led~=2 then t.alarm_led = t.fg_led end
if t.led_effect~=nil then
if t.bg_led == nil then t.bg_led = t.bg_colour end
if t.fg_led == nil then t.fg_led = t.fg_colour end
if t.alarm_led == nil then t.alarm_led = t.fg_led end
end
if t.alarm==nil then t.alarm = t.max end --0.8*t.max end
if t.smooth == nil then t.smooth = false end
if t.skew_x == nil then
t.skew_x=0
else
t.skew_x = math.pi*t.skew_x/180
end
if t.skew_y == nil then
t.skew_y=0
else
t.skew_y = math.pi*t.skew_y/180
end
if t.reflection_alpha==nil then t.reflection_alpha=0 end
if t.reflection_length==nil then t.reflection_length=1 end
if t.reflection_scale==nil then t.reflection_scale=1 end
--end of default values
local function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end
--functions used to create patterns
local function create_smooth_linear_gradient(x0,y0,x1,y1)
local pat = cairo_pattern_create_linear (x0,y0,x1,y1)
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
if t.mid_colour ~=nil then
for i=1, #t.mid_colour do
cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
end
end
return pat
end
local function create_smooth_radial_gradient(x0,y0,r0,x1,y1,r1)
local pat = cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
if t.mid_colour ~=nil then
for i=1, #t.mid_colour do
cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
end
end
return pat
end
local function create_led_linear_gradient(x0,y0,x1,y1,col_alp,col_led)
local pat = cairo_pattern_create_linear (x0,y0,x1,y1) ---delta, 0,delta+ t.width,0)
cairo_pattern_add_color_stop_rgba (pat, 0.0, rgb_to_r_g_b(col_alp))
cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
cairo_pattern_add_color_stop_rgba (pat, 1.0, rgb_to_r_g_b(col_alp))
return pat
end
local function create_led_radial_gradient(x0,y0,r0,x1,y1,r1,col_alp,col_led,mode)
local pat = cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
if mode==3 then
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_alp))
cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))
else
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_led))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))
end
return pat
end
local function draw_single_bar()
--this fucntion is used for bars with a single block (blocks=1) but
--the drawing is cut in 3 blocks : value/alarm/background
--not zvzimzblr for circular bar
local function create_pattern(col_alp,col_led,bg)
local pat
if not t.smooth then
if t.led_effect=="e" then
pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
elseif t.led_effect=="a" then
pat = create_led_linear_gradient (t.width/2, 0,t.width/2,-t.height,col_alp,col_led)
elseif t.led_effect=="r" then
pat = create_led_radial_gradient (t.width/2, -t.height/2, 0, t.width/2,-t.height/2,t.height/1.5,col_alp,col_led,2)
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(col_alp))
end
else
if bg then
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(t.bg_colour))
else
pat = create_smooth_linear_gradient(t.width/2, 0, t.width/2,-t.height)
end
end
return pat
end
local y1=-t.height*pct/100
local y2,y3
if pct>(100*t.alarm/t.max) then
y1 = -t.height*t.alarm/100
y2 = -t.height*pct/100
if t.smooth then y1=y2 end
end
if t.angle_bar==0 then
--block for fg value
local pat = create_pattern(t.fg_colour,t.fg_led,false)
cairo_set_source(cr,pat)
cairo_rectangle(cr,0,0,t.width,y1)
cairo_fill(cr)
cairo_pattern_destroy(pat)
-- block for alarm value
if not t.smooth and y2 ~=nil then
pat = create_pattern(t.alarm_colour,t.alarm_led,false)
cairo_set_source(cr,pat)
cairo_rectangle(cr,0,y1,t.width,y2-y1)
cairo_fill(cr)
y3=y2
cairo_pattern_destroy(pat)
else
y2,y3=y1,y1
end
-- block for bg value
cairo_rectangle(cr,0,y2,t.width,-t.height-y3)
pat = create_pattern(t.bg_colour,t.bg_led,true)
cairo_set_source(cr,pat)
cairo_pattern_destroy(pat)
cairo_fill(cr)
end
end --end single bar
local function draw_multi_bar()
--function used for bars with 2 or more blocks
for pt = 1,t.blocks do
--set block y
local y1 = -(pt-1)*(t.height+t.space)
local light_on=false
--set colors
local col_alp = t.bg_colour
local col_led = t.bg_led
if pct>=(100/t.blocks) or pct>0 then --ligth on or not the block
if pct>=(pcb*(pt-1)) then
light_on = true
col_alp = t.fg_colour
col_led = t.fg_led
if pct>=(100*t.alarm/t.max) and (pcb*pt)>(100*t.alarm/t.max) then
col_alp = t.alarm_colour
col_led = t.alarm_led
end
end
end
--set colors
--have to try to create gradients outside the loop ?
local pat
if not t.smooth then
if t.angle_bar==0 then
if t.led_effect=="e" then
pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
elseif t.led_effect=="a" then
pat = create_led_linear_gradient (t.width/2, -t.height/2+y1,t.width/2,0+t.height/2+y1,col_alp,col_led)
elseif t.led_effect=="r" then
pat = create_led_radial_gradient (t.width/2, y1, 0, t.width/2,y1,t.width/1.5,col_alp,col_led,2)
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(col_alp))
end
else
if t.led_effect=="a" then
pat = create_led_radial_gradient (0, 0, t.radius+(t.height+t.space)*(pt-1),
0, 0, t.radius+(t.height+t.space)*(pt),
col_alp,col_led,3)
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(col_alp))
end
end
else
if light_on then
if t.angle_bar==0 then
pat = create_smooth_linear_gradient(t.width/2, t.height/2, t.width/2,-(t.blocks-0.5)*(t.height+t.space))
else
pat = create_smooth_radial_gradient(0, 0, (t.height+t.space), 0,0,(t.blocks+1)*(t.height+t.space),2)
end
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(t.bg_colour))
end
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
--draw a block
if t.angle_bar==0 then
cairo_move_to(cr,0,y1)
cairo_line_to(cr,t.width,y1)
else
cairo_arc( cr,0,0,
t.radius+(t.height+t.space)*(pt)-t.height/2,
-t.angle_bar -math.pi/2 ,
t.angle_bar -math.pi/2)
end
cairo_stroke(cr)
end
end
local function setup_bar_graph()
--function used to retrieve the value to display and to set the cairo structure
if t.blocks ~=1 then t.y=t.y-t.height/2 end
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
--$to_bytes doesn't work when value has a decimal point,
--https://garage.maemo.org/plugins/ggit/browse.php/?p=monky;a=commitdiff;h=174c256c81a027a2ea406f5f37dc036fac0a524b;hp=d75e2db5ed3fc788fb8514121f67316ac3e5f29f
--http://sourceforge.net/tracker/index.php?func=detail&aid=3000865&group_id=143975&atid=757310
--conky bug?
--value = (conky_parse(string.format('${%s %s}', t.name, t.arg)))
--if string.match(value,"%w") then
-- value = conky_parse(string.format('${to_bytes %s}',value))
--end
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
pct = 100*value/t.max
pcb = 100/t.blocks
cairo_set_line_width (cr, t.height)
cairo_set_line_cap (cr, cap)
cairo_translate(cr,t.x,t.y)
cairo_rotate(cr,t.angle)
local matrix0 = cairo_matrix_t:create()
tolua.takeownership(matrix0)
cairo_matrix_init (matrix0, 1,t.skew_y,t.skew_x,1,0,0)
cairo_transform(cr,matrix0)
--call the drawing function for blocks
if t.blocks==1 and t.angle_bar==0 then
draw_single_bar()
if t.reflection=="t" or t.reflection=="b" then cairo_translate(cr,0,-t.height) end
else
draw_multi_bar()
end
--dot for reminder
--[[
if t.blocks ~=1 then
cairo_set_source_rgba(cr,1,0,0,1)
cairo_arc(cr,0,t.height/2,3,0,2*math.pi)
cairo_fill(cr)
else
cairo_set_source_rgba(cr,1,0,0,1)
cairo_arc(cr,0,0,3,0,2*math.pi)
cairo_fill(cr)
end]]
--call the drawing function for reflection and prepare the mask used
if t.reflection_alpha>0 and t.angle_bar==0 then
local pat2
local matrix1 = cairo_matrix_t:create()
tolua.takeownership(matrix1)
if t.angle_bar==0 then
pts={-delta/2,(t.height+t.space)/2,t.width+delta,-(t.height+t.space)*(t.blocks)}
if t.reflection=="t" then
cairo_matrix_init (matrix1,1,0,0,-t.reflection_scale,0,-(t.height+t.space)*(t.blocks-0.5)*2*(t.reflection_scale+1)/2)
pat2 = cairo_pattern_create_linear (t.width/2,-(t.height+t.space)*(t.blocks),t.width/2,(t.height+t.space)/2)
elseif t.reflection=="r" then
cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,delta+2*t.width,0)
pat2 = cairo_pattern_create_linear (delta/2+t.width,0,-delta/2,0)
elseif t.reflection=="l" then
cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,-delta,0)
pat2 = cairo_pattern_create_linear (-delta/2,0,delta/2+t.width,-0)
else --bottom
cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(t.height+t.space)*(t.reflection_scale+1)/2)
pat2 = cairo_pattern_create_linear (t.width/2,(t.height+t.space)/2,t.width/2,-(t.height+t.space)*(t.blocks))
end
end
cairo_transform(cr,matrix1)
if t.blocks==1 and t.angle_bar==0 then
draw_single_bar()
cairo_translate(cr,0,-t.height/2)
else
draw_multi_bar()
end
cairo_set_line_width(cr,0.01)
cairo_pattern_add_color_stop_rgba (pat2, 0,0,0,0,1-t.reflection_alpha)
cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)
if t.angle_bar==0 then
cairo_rectangle(cr,pts[1],pts[2],pts[3],pts[4])
end
cairo_clip_preserve(cr)
cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
cairo_stroke(cr)
cairo_mask(cr,pat2)
cairo_pattern_destroy(pat2)
cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
end --reflection
pct,pcb=nil
end --setup_bar_graph()
--start here !
setup_bar_graph()
cairo_restore(cr)
end
function conky_main_box()
if conky_window==nil then return end
---------------------- PARAMETERS BEGIN HERE
local boxes_settings={
{x=0,y=50,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=195,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=320,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=410,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=520,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=615,w=200,h=150, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
}
---------------------------- PARAMETERS END HERE
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse("$updates"))<5 then return end
for i in pairs(boxes_settings) do
draw_box (cr,boxes_settings[i])
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
function draw_box(cr,t)
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
local table_corners={"circle","curve","line"}
local t_operators={
clear = CAIRO_OPERATOR_CLEAR,
source = CAIRO_OPERATOR_SOURCE,
over = CAIRO_OPERATOR_OVER,
["in"] = CAIRO_OPERATOR_IN,
out = CAIRO_OPERATOR_OUT,
atop = CAIRO_OPERATOR_ATOP,
dest = CAIRO_OPERATOR_DEST,
dest_over = CAIRO_OPERATOR_DEST_OVER,
dest_in = CAIRO_OPERATOR_DEST_IN,
dest_out = CAIRO_OPERATOR_DEST_OUT,
dest_atop = CAIRO_OPERATOR_DEST_ATOP,
xor = CAIRO_OPERATOR_XOR,
add = CAIRO_OPERATOR_ADD,
saturate = CAIRO_OPERATOR_SATURATE,
}
function rgba_to_r_g_b_a(tc)
--tc={position,colour,alpha}
local colour = tc[2]
local alpha = tc[3]
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function table.copy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = {v[1],v[2]}
end
return t2
end
function draw_corner(num,t)
local shape=t[1]
local radius=t[2]
local x,y = t[3],t[4]
if shape=="line" then
if num == 1 then cairo_line_to(cr,radius,0)
elseif num == 2 then cairo_line_to(cr,x,radius)
elseif num == 3 then cairo_line_to(cr,x-radius,y)
elseif num == 4 then cairo_line_to(cr,0,y-radius)
end
end
if shape=="circle" then
local PI = math.pi
if num == 1 then cairo_arc(cr,radius,radius,radius,-PI,-PI/2)
elseif num == 2 then cairo_arc(cr,x-radius,y+radius,radius,-PI/2,0)
elseif num == 3 then cairo_arc(cr,x-radius,y-radius,radius,0,PI/2)
elseif num == 4 then cairo_arc(cr,radius,y-radius,radius,PI/2,-PI)
end
end
if shape=="curve" then
if num == 1 then cairo_curve_to(cr,0,radius ,0,0 ,radius,0)
elseif num == 2 then cairo_curve_to(cr,x-radius,0, x,y, x,radius)
elseif num == 3 then cairo_curve_to(cr,x,y-radius, x,y, x-radius,y)
elseif num == 4 then cairo_curve_to(cr,radius,y, x,y, 0,y-radius)
end
end
end
--check values and set default values
if t.x == nil then t.x = 0 end
if t.y == nil then t.y = 0 end
if t.w == nil then t.w = conky_window.width end
if t.h == nil then t.h = conky_window.height end
if t.radius == nil then t.radius = 0 end
if t.border == nil then t.border = 0 end
if t.colour==nil then t.colour={{1,0xFFFFFF,0.5}} end
if t.linear_gradient ~= nil then
if #t.linear_gradient ~= 4 then
t.linear_gradient = {t.x,t.y,t.width,t.height}
end
end
if t.angle==nil then t.angle = 0 end
if t.skew_x == nil then t.skew_x=0 end
if t.skew_y == nil then t.skew_y=0 end
if t.scale_x==nil then t.scale_x=1 end
if t.scale_y==nil then t.scale_y=1 end
if t.rot_x == nil then t.rot_x=0 end
if t.rot_y == nil then t.rot_y=0 end
if t.operator == nil then t.operator = "over" end
if (t_operators[t.operator]) == nil then
print ("wrong operator :",t.operator)
t.operator = "over"
end
if t.radial_gradient ~= nil then
if #t.radial_gradient ~= 6 then
t.radial_gradient = {t.x,t.y,0, t.x,t.y, t.width}
end
end
for i=1, #t.colour do
if #t.colour[i]~=3 then
print ("error in color table")
t.colour[i]={1,0xFFFFFF,1}
end
end
if t.corners == nil then t.corners={ {"line",0} } end
local t_corners = {}
local t_corners = table.copy(t.corners)
--don't use t_corners=t.corners otherwise t.corners is altered
--complete the t_corners table if needed
for i=#t_corners+1,4 do
t_corners[i]=t_corners[#t_corners]
local flag=false
for j,v in pairs(table_corners) do flag=flag or (t_corners[i][1]==v) end
if not flag then print ("error in corners table :",t_corners[i][1]);t_corners[i][1]="curve" end
end
--this way :
-- t_corners[1][4]=x
-- t_corners[2][3]=y
--doesn't work
t_corners[1]={t_corners[1][1],t_corners[1][2],0,0}
t_corners[2]={t_corners[2][1],t_corners[2][2],t.w,0}
t_corners[3]={t_corners[3][1],t_corners[3][2],t.w,t.h}
t_corners[4]={t_corners[4][1],t_corners[4][2],0,t.h}
t.no_gradient = (t.linear_gradient == nil ) and (t.radial_gradient == nil )
cairo_save(cr)
cairo_translate(cr, t.x, t.y)
if t.rot_x~=0 or t.rot_y~=0 or t.angle~=0 then
cairo_translate(cr,t.rot_x,t.rot_y)
cairo_rotate(cr,t.angle*math.pi/180)
cairo_translate(cr,-t.rot_x,-t.rot_y)
end
if t.scale_x~=1 or t.scale_y~=1 or t.skew_x~=0 or t.skew_y~=0 then
local matrix0 = cairo_matrix_t:create()
tolua.takeownership(matrix0)
cairo_matrix_init (matrix0, t.scale_x,math.pi*t.skew_y/180 , math.pi*t.skew_x/180 ,t.scale_y,0,0)
cairo_transform(cr,matrix0)
end
local tc=t_corners
cairo_move_to(cr,tc[1][2],0)
cairo_line_to(cr,t.w-tc[2][2],0)
draw_corner(2,tc[2])
cairo_line_to(cr,t.w,t.h-tc[3][2])
draw_corner(3,tc[3])
cairo_line_to(cr,tc[4][2],t.h)
draw_corner(4,tc[4])
cairo_line_to(cr,0,tc[1][2])
draw_corner(1,tc[1])
if t.no_gradient then
cairo_set_source_rgba(cr,rgba_to_r_g_b_a(t.colour[1]))
else
if t.linear_gradient ~= nil then
pat = cairo_pattern_create_linear (t.linear_gradient[1],t.linear_gradient[2],t.linear_gradient[3],t.linear_gradient[4])
elseif t.radial_gradient ~= nil then
pat = cairo_pattern_create_radial (t.radial_gradient[1],t.radial_gradient[2],t.radial_gradient[3],
t.radial_gradient[4],t.radial_gradient[5],t.radial_gradient[6])
end
for i=1, #t.colour do
cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgba_to_r_g_b_a(t.colour[i]))
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
cairo_set_operator(cr,t_operators[t.operator])
if t.border>0 then
cairo_close_path(cr)
if t.dash ~= nil then cairo_set_dash(cr, t.dash, 1, 0.0) end
cairo_set_line_width(cr,t.border)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
(houla ..... sans coulleurs sa pique les yeux. désolé.)
je mettrais le lua de pie si on me dit qu'il est utile/différent de ring
Modifié en dernier par Toad_Fr le dim. 23 déc. 2018 05:23, modifié 8 fois.
- arghlub
- Administrateur du site
- Messages : 10421
- Enregistré le : dim. 21 mai 2017 08:19
- Localisation : Provence
- Contact :
Re: Comment créé ses Conky ? version 1.10+ [2018]
Salut casp3r,
Pour ton conky, comme tu le sais je t'ai données 2-3 explications en "privé"....
Si ça roule, j'aimerais bien que tu en fasses un retour (histoire que d'autres puissent en profiter)
Si c'est du code dont tu parles, ça ne piquera jamais les yeux (je parle au nom des férus de code).
Pour ton conky, comme tu le sais je t'ai données 2-3 explications en "privé"....
Si ça roule, j'aimerais bien que tu en fasses un retour (histoire que d'autres puissent en profiter)
Tour1 (custom) • CM MSI Z270 M3 | CPU Intel I7-7700K | CG Nvidia GTX 1080 | RAM 16Go | tripleBoot : Debian 11 | MXlinux 21 | LMint 19.3 | XFCE
Tour2 (custom) • CM Gigabyte | CPU AMD Athlon 5200+ | CG Nvidia GTX 560 | RAM 6Go | FreeBSD 12.1 XFCE
Portable1 • MSI GF75 Thin 9SC | CPU Intel I7-9750H | CG Nvidia GTX 1650 | RAM 32Go | dualBoot : LMint 20.2 | MXlinux 21 | XFCE
Portable2 • MacBook Air A1466 (2015) | CPU Intel I5-5250U | CG Intel HD Graphics 6000 | RAM 8Go | dualBoot : macOS Sierra | MXlinux 21 XFCE
─────( pour une informatique libre ! -membre en stand-by de l' April.org────────────────
Tour2 (custom) • CM Gigabyte | CPU AMD Athlon 5200+ | CG Nvidia GTX 560 | RAM 6Go | FreeBSD 12.1 XFCE
Portable1 • MSI GF75 Thin 9SC | CPU Intel I7-9750H | CG Nvidia GTX 1650 | RAM 32Go | dualBoot : LMint 20.2 | MXlinux 21 | XFCE
Portable2 • MacBook Air A1466 (2015) | CPU Intel I5-5250U | CG Intel HD Graphics 6000 | RAM 8Go | dualBoot : macOS Sierra | MXlinux 21 XFCE
─────( pour une informatique libre ! -membre en stand-by de l' April.org────────────────