Nos conky 2017

Bureaux,conky et autres personnalisations esthétiques.
Avatar du membre
zeb
Administrateur du site
Messages : 13896
Enregistré le : ven. 19 juin 2015 22:13
Localisation : Au pays du mistral

Nos conky 2017

Message par zeb » jeu. 12 janv. 2017 18:44

Hello ;)
Tout comme hermes a lancé "Nos bureaux 2017" je lance "Nos conky 2017" 8-)

Avec (bien sûr si possible) les codes qui suivent les images :!:

Voici mon mien :mrgreen:
Image
Le code à adapter a votre systeme:

Code : Tout sélectionner

background yes
use_xft yes
xftfont Sans:size=10
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 220
maximum_width 1500
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_outline_color white
alignment top_right
gap_x 10
gap_y 10
no_buffers yes
uppercase no
cpu_avg_samples 4
net_avg_samples 4
override_utf8_locale yes
#
color1 white
#
color2 orange
#
color3 6495ee
#
color4 green
#cornflowerblue
color5 red
color6 yellow
# Lua Load
#lua_load ~/.conky/draw_bg.lua
#lua_draw_hook_pre draw_bg
#lua_load ~/.conky/conky_grey.lua
#lua_draw_hook_pre main
lua_load ~/.conky/tous/tous.lua #chemin du .lua
lua_draw_hook_post main_rings #ordre de lancement si demande de plusieurs lua

TEXT
${color1}${font URW Chancery L:style=Medium Italic:pixelsize=25}Nous sommes le:
${color1}${font URW Chancery L:style=Medium Italic:pixelsize=25}${time %A %d %B}
${color}${color1}${font URW Chancery L:style=Medium Italic:pixelsize=25}depuis:  ${color1}${voffset -8}${font URW Chancery L:style=Medium Italic:pixelsize=34}${time %H:%M:%S}${font}${color}
${voffset 43}${font Sans:size=10}${color3}${goto 35}proc ${color3}${goto 143}temp
${color ff8000} ${goto 20}${freq_g} GHz ${Goto 145}${hwmon 1 temp 1}°C
${voffset 42}${color6}core: ${color1}1: ${cpu cpu1}%${Goto 100}${color6}core: ${color1}1: ${hwmon 1 temp 2}°C 
${goto 41}${color5}2: ${cpu cpu2}%${Goto 136}${color5}2: ${hwmon 1 temp 3}°C
${goto 41}${color3}3: ${cpu cpu3}%${Goto 136}${color3}3: ${hwmon 1 temp 4}°C
${goto 41}${color4}4: ${cpu cpu4}%${Goto 136}${color4}4: ${hwmon 1 temp 5}°C
${voffset 25}${goto 23}${color4} /Racine ${color4}${goto 143} Ram
${color4}${goto 25}${fs_used /}${color4}${Goto 140}$mem 
${color3}${goto 23} /home ${color5}${goto 143} swap
${color3}${goto 27}${fs_free /home}${color5}${goto 135}${swap}
${voffset 30}${color2}${font}Backup $alignc ${fs_free /media/sauvegarde} / ${fs_size /media/sauvegarde} $alignr ${fs_used_perc /media/sauvegarde}%
${fs_bar /media/sauvegarde}
${voffset 10}${goto 35}${font}Vitesse ventilo: ${hwmon 2 fan 1} Tr/m
${voffset 50}${goto 25}${font Sans:size=8}${color4}${downspeedf eth0}k/s ${color5}${goto 140}${upspeedf eth0}k/s
${color3}${goto 23} /Down ${color3}${goto 140} /Up
${color4}${goto 25}${totaldown eth0}${goto 140}${color5}${totalup eth0}

${voffset 30}${color1}${goto 50}PROCESSUS 
${color3}NOM ${goto 125}CPU ${goto 185}RAM 
${color1}${top name 1} ${goto 120}${top cpu 1} ${goto 180}${top mem 1}
${color1}${top name 2} ${goto 120}${top cpu 2} ${goto 180}${top mem 2}
${color1}${top name 3} ${goto 120}${top cpu 3} ${goto 180}${top mem 3}
${color1}${top name 4} ${goto 120}${top cpu 4} ${goto 180}${top mem 4}
${color1}${top name 5} ${goto 120}${top cpu 5} ${goto 180}${top mem 5}

${goto 50}INTERNET
${color3}URL NB PORTS OUVERTS: ${tcp_portmon 1 65535 count}
${color2}${tcp_portmon 1 65535 rip 0}${goto 155}${tcp_portmon 1 65535 rport 0}
${color2}${tcp_portmon 1 65535 rip 1}${goto 155}${tcp_portmon 1 65535 rport 1}
${color2}${tcp_portmon 1 65535 rip 2}${goto 155}${tcp_portmon 1 65535 rport 2}
${color2}${tcp_portmon 1 65535 rip 3}${goto 155}${tcp_portmon 1 65535 rport 3}
${color2}${tcp_portmon 1 65535 rip 4}${goto 155}${tcp_portmon 1 65535 rport 4}
Voili, maintenant, a vous ;)
LMDE3 Cinnamon 64-bit + LMDE3 Xfce.
Proc: intel I5 4440, Cm: Gigabyte GA-B85M-D3H, Alim: Corsair CX Bronze 430 W, Ram: Crucial Ballistix Sport, 2 x 2 Go.
SSD: 2.5 sandisk ultra+ 64 Go pour /+home, DD: Seagate Barracuda 500 Go pour mes données persos, DD maxtor 160 Go pour la sauvegarde ciblée via luckybackup.
Impr: HP Envy 4502.

Avatar du membre
Cyrrus
Messages : 402
Enregistré le : mar. 29 nov. 2016 01:09
Localisation : French County

Re: Nos conky 2017

Message par Cyrrus » jeu. 12 janv. 2017 20:31

à mon tour :D

Image



Code : Tout sélectionner

# .conkyrc by fabsh <fabsh@lamerk.org>
# Based on ideas and code from the CunchBang Linux forums at http://crunchbanglinux.org
# v. 1.0

# Use Xft?
use_xft yes
xftfont DejaVu Sans:size=8
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 4

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

own_window yes
own_window_transparent yes
#own_window_type override
own_window_type desktop
#own_window_type normal #use this if you want a nice shadow to appear around conky

# If own_window is yes, these window manager hints may be used
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 200 0
maximum_width 200

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_margin 5

# border width
border_width 1

# Default colors and also border colors
default_color white
#default_shade_color white
#default_outline_color white
own_window_colour 000000

# Text alignment, other possible values are commented
#alignment top_left
alignment top_left
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 12
gap_y 32

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer none

temperature_unit celcius

own_window_argb_value 0
own_window_argb_visual yes
TEXT

${image avatar.png -p 40,0 -s 128x128}${font Dark Times:pixelsize=15}${font Sony_Sketch_EF:pixelsize=13} 



${color #40FF00}
DATE ${hr 2}
${color white}${alignc 5}${font Arial Black:size=18}${time %H:%M}${font}
${voffset 2}${alignc}${time %A, %d %B %Y}

${color #40FF00}
${voffset 20}SYSTEM ${hr 2}${color white}
${alignc +15}${font Arial Black:size=14}${nodename}${font}
${alignc 0}Lenovo G50-30${color #9AFE2E}
${font OpenLogos:size=16}u${font} ${color white}Kernel: ${alignr}${kernel}${color #9AFE2E}
${font StyleBats:size=16}A${font} ${color white}CPU1: ${cpu cpu1}% ${alignr}${cpubar cpu1 8,60}${color #9AFE2E}
${font StyleBats:size=16}A${font} ${color white}CPU2: ${cpu cpu2}% ${alignr}${cpubar cpu2 8,60}${color #9AFE2E}
${font StyleBats:size=16}g${font} ${color white}RAM: $memperc% ${alignr}${membar 8,60}${color #9AFE2E}
${font StyleBats:size=16}j${font} ${color white}SWAP: $swapperc% ${alignr}${swapbar 8,60}${color #9AFE2E}
${font StyleBats:size=16}u${font} ${color white}Battery: ${battery_percent BAT0}% ${alignr}${battery_bar 8,60 BAT0}${color #9AFE2E}
${font StyleBats:size=16}q${font} ${color white}Uptime: ${alignr}${uptime}


${color #40FF00}
${voffset -30}HD ${hr 2}
${color #9AFE2E}
${execpi 10 df | df | sed '/none/d' | sed '/udev/d' | sed '/tmpfs/d' | sed 1d | cut -d% -f2 | while read line ; do
if [ $line = "/" ]
then echo '${voffset 5}${font Modern Pictograms:size=24}C${color white}${font} ${voffset -10}${alignr}${fs_bar 8,60 '$line'} \n ${alignr}${fs_used '$line'}/${fs_size '$line'} '

else echo '${voffset 5}${color #9AFE2E}${font Modern Pictograms:size=24}Q${color white}${font} ${voffset -10}${alignr}${fs_bar 8,60 '$line'} \n ${alignr}${fs_used '$line'}/${fs_size '$line'} '
fi
done }
${color #40FF00}
${voffset 10}NETWORK ${hr 2}
${color #9AFE2E}
${if_existing /proc/net/route wlp2s0}
${voffset -6}${font PizzaDude Bullets:size=14}O${color white}${font} Up: ${upspeed wlp2s0}${alignr}${upspeedgraph wlp2s0 8,60 black black}
${color #9AFE2E}
${voffset 4}${font PizzaDude Bullets:size=14}U${color white}${font} Down: ${downspeed wlp2s0}${alignr}${downspeedgraph wlp2s0 8,60 black black}
${color #9AFE2E}
${voffset 4}${font PizzaDude Bullets:size=14}N${color white}${font} Upload: ${alignr}${totalup wlp2s0}
${color #9AFE2E}
${voffset 4}${font PizzaDude Bullets:size=14}T${color white}${font} Download: ${alignr}${totaldown wlp2s0}
J'en ai un second, un conky audacious qui m'a été donné par loutch, je vous mets le lien pour ceux que ça intéresse, voir un peu plus haut que mon (long) topic de configuration, mais ça vous évitera peut-être des galères ... viewtopic.php?f=14&t=34&p=58113#p58113" onclick="window.open(this.href);return false;

ce qui donne ça :


Image

Avatar du membre
bouledogue
Messages : 1386
Enregistré le : jeu. 6 oct. 2016 06:54
Localisation : Hauts de France
Contact :

Re: Nos conky 2017

Message par bouledogue » ven. 13 janv. 2017 07:23

Super idée ! :) jolis vos conky
J'aimerais en avoir un mais Ca a l'air bien opaque à mes yeux ces programmations .
Les conky se font ils toujours en lignes de codes ? Il n'y a pas de logiciels graphiques pour créer son conky en trois clics? :roll:
Modifié en dernier par bouledogue le ven. 13 janv. 2017 10:36, modifié 1 fois.
En matière d'aide, un chien vaut mieux que deux tu l'auras 8-)
Image

Avatar du membre
Cyrrus
Messages : 402
Enregistré le : mar. 29 nov. 2016 01:09
Localisation : French County

Re: Nos conky 2017

Message par Cyrrus » ven. 13 janv. 2017 10:15

Hello, tu as Conky Manager qui te permet, non pas de créer ton conky , mais de faire déjà quelques reglages basiques comme le déplacement ou passer de 12/24 heures sans se prendre la tête ...

Tu sais, moi non plus je n'y connais rien, mais tu changes des valeurs dans un fichier texte pour changer de couleur , de taille, etc ... Pour plus de sécurité tu fais une sauvegarde de ton fichier avant manip et comme ça tu le restaure si tu t'es planté. Il n'y a pas de gros risques ... tu verras, on s'y fait vite et je dirrais même qu'on se prend rapidement au jeu, ça devient un plaisir de personnaliser ces petits gadgets :D

Avatar du membre
Cyrrus
Messages : 402
Enregistré le : mar. 29 nov. 2016 01:09
Localisation : French County

Re: Nos conky 2017

Message par Cyrrus » dim. 15 janv. 2017 11:26

Hello

je continue à m'amuser avec mes conky, voici ce que ça donne sous ma session Solus OS, il s' agit de plusieurs conky trouvés sur la toile et que j'ai modifiés à mon goût :ugeek:


Image

Avatar du membre
toryx
Messages : 165
Enregistré le : dim. 11 sept. 2016 21:57

Re: Nos conky 2017

Message par toryx » sam. 21 janv. 2017 10:14

hello
le mien se compose d'un lanceur, de 3 conkyrc et de 3 lua, version conky 1.10
adapter les chemins à votre system.
je ne poste pas la meteo car deja presente sur le fofo ;)

desolé ça fait un peut pâté, mais je n'est pas encore réussi à mettre tout ça dans un seul conkyrc avec un script multiua
manque aussi les PNG, mais vous pouvez un mettre les votres ;)

Image
le lanceur:

Code : Tout sélectionner

#!/bin/bash
killall conky
conky -c ~/1_accuweather/conkyrc &
conky -p 4 -c ~/.conky/jimmy/conky_cpu &
conky -p 4 -c ~/.conky/jimmy/conky_hdd &
conky -p 4 -c ~/.conky/jimmy/conky_network
conky cpu et ram:

Code : Tout sélectionner

conky.config = {
-- ------------------------- Windows Settings
	own_window = true,
	own_window_type = 'normal',
	own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',
	own_window_argb_visual = true,
	own_window_argb_value = 0,
    border_inner_margin = 0,
	border_outer_margin = 20,

	double_buffer = true,
	background = true,

-- ------------------------- Position
	alignment = 'bottom_left',

	minimum_width = 383,
	minimum_height = 165,
	maximum_width = 500,
	gap_x = 2880,
	gap_y = 500,

-- ------------------------- Font
	use_xft = true,
	xftalpha = 0.8,
	override_utf8_locale = true,

	draw_shades = true,
	default_shade_color = 'black',

	draw_borders = false,
	draw_outline = false,

	font = 'Monofur:bold:size=8',

-- ------------------------- Color
	default_color = 'DCDCDC',
	color0 = '1793d0',
	color1 = 'DDDDDD',
	color2 = 'AAAAAA',
	color3 = '888888',

--------------------------- OTHER
    update_interval = 5,

	template0 = [[${GOTO 150}${color\1}${top_mem name \2}${alignr}${top_mem mem \2}%]],

	no_buffers = true,
	lua_load = '~/.conky/jimmy/lua/bargraph.system.lua',
    lua_draw_hook_post = 'main_bars',
	        
};

conky.text = [[
${voffset 25}${GOTO 50}${font}${color 77B753}${alignr 200}CPU
${font}${alignr 190}Core1${alignr 175}${cpu cpu0}%${alignr 10}${hwmon 1 temp 2}°C${alignr -4}${font}Freq: ${font Monofur:size=8}${freq_g} Ghz
${font}${alignr 190}Core2${alignr 175}${cpu cpu1}%${alignr 10}${hwmon 1 temp 3}°C${alignr -4}${font}Freq: ${font Monofur:size=8}${freq_g} Ghz
${font}${alignr 190}Core3${alignr 175}${cpu cpu2}%${alignr 10}${hwmon 1 temp 4}°C${alignr -4}${font}Freq: ${font Monofur:size=8}${freq_g} Ghz
${font}${alignr 190}Core4${alignr 175}${cpu cpu3}%${alignr 10}${hwmon 1 temp 5}°C${alignr -4}${font}Freq: ${font Monofur:size=8}${freq_g} Ghz
${image ~/.conky/ConkyBar/img/cpu.png -p -2,0}
# ---------------------------------------------
${GOTO 150}${font}${color 77B753}RAM
${GOTO 150}${color 77B753}${font}Usage: ${font Monofur:size=8}${memperc}% | ${mem}${font Monofur:size=7}${alignr}[+${buffers} +${cached}]
${voffset 27}${font Monofur:size=8}${template0 0 1}
${template0 1 2}
${template0 2 3}
${template0 3 4}
${template0 3 5}
${image ~/.conky/ConkyBar/img/ram.png -p 105,95}
]];
conky hdd:

Code : Tout sélectionner

conky.config = {
-- ------------------------- Windows Settings
	own_window = true,
	own_window_type = 'normal',
	own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',
	own_window_argb_visual = true,
	own_window_argb_value = 0,

	double_buffer = true,
	background = true,

-- ------------------------- Position
	alignment = 'bottom_left',

	maximum_width = 295,
    minimum_width = 400,
	maximum_height = 10,
	gap_x = 2880,
	gap_y = 280,

-- ------------------------- Font
	use_xft = true,
	xftalpha = 0.8,
	override_utf8_locale = true,

	draw_shades = true,
	default_shade_color = 'black',

	draw_borders = false,
	draw_outline = false,

	font = 'Monofur:bold:size=8',

-- ------------------------- Color
	default_color = 'DCDCDC',

--------------------------- OTHER
	update_interval = 1,
    lua_load = '~/.conky/jimmy/lua/files_ring_hdd.lua',
    lua_draw_hook_post = 'system',
};

conky.text = [[
${voffset 25}${GOTO 50}${color 77B753}${font}HDD:${GOTO 90}${font}Temp: ${font Monofur:size=8}${hwmon 1 temp 1}°C${GOTO 230} 
${GOTO 120}${font Monofur:size=8}${voffset 38}Utilisé ${fs_used /}${GOTO 210}${fs_used_perc /}%
${GOTO 160}${font Monofur:size=8}${voffset 7}Utilisé ${fs_used /home} ${fs_used_perc /home}%
${voffset 85}

${image ~/.conky/ConkyBar/img/files.png -p 0,15}
]];
conky network:

Code : Tout sélectionner

conky.config = {
-- ------------------------- Windows Settings
	own_window = true,
	own_window_type = 'normal',
	own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',
	own_window_argb_visual = true,
	own_window_argb_value = 0,

	double_buffer = true,
	--background = true,

-- ------------------------- Position
	alignment = 'bottom_left',

	minimum_width = 313,
	minimum_height = 165,
	maximum_width = 313,
	gap_x = 2880,
	gap_y = 220,

-- ------------------------- Font
	use_xft = true,
	xftalpha = 0.8,
	override_utf8_locale = true,

	draw_shades = true,
	default_shade_color = 'black',

	draw_borders = false,
	draw_outline = false,

	font = 'Monofur:bold:size=8',

-- ------------------------- Color
	default_color = 'DCDCDC',


-- ------------------------- OTHER
	update_interval = 1,

	lua_load = '~/.conky/jimmy/lua/net_graph.lua',
	lua_draw_hook_pre = 'main_graph',

};

conky.text = [[
${if_existing /proc/net/route enp2s0}${voffset 25}${GOTO 50}${color 77B753}${font}Network
${GOTO 50}${font}Public ip: ${font Monofur:size=8}${texeci 36000 wget -qO - http://ip.tupeux.com | tail}
${voffset 85}${GOTO 50}${color 1793d0}${font}Recieve: ${font Monofur:size=8}${downspeed enp2s0}${GOTO 200}${color FEE83D}${font}Send: ${font Monofur:size=8}${upspeed enp2s0}
${image ~/.conky/ConkyBar/img/networkhigh.png -p 0,15}${else}${if_existing /proc/net/route wlp2s0}${voffset 25}${GOTO 50}${font}Network
${GOTO 50}${font}Public ip: ${font Monofur:size=8}$${texeci 36000 wget -qO - http://ip.tupeux.com | tail}${GOTO 200}${font}Sig: ${font Monofur:size=8}${wireless_link_qual_perc wlp2s0}%
${voffset 85}${GOTO 50}${font}Recieve: ${font Monofur:size=8}${downspeed wlp2s0}${GOTO 200}${font}Send: ${font Monofur:size=8}${upspeed wlp2s0}
${if_match "${wireless_link_qual_perc wlp2s0}"<"33"}${image ~/.conky/ConkyBar/img/networklow.png -p 0,15 -s 45x45}${else}${if_match "${wireless_link_qual_perc wlp2s0}"<"66"}${image ~/.conky/ConkyBar/img/networkmid.png -p 0,15}${else}${image ~/.conky/ConkyBar/img/networkhigh.png -p 0,15}${endif}${endif}${else}${voffset 27}${GOTO 50}${font}Network
${GOTO 50}${font}No connection
${image ~/.conky/ConkyBar/img/nonetwork.png -p 0,15}${endif}${endif}
# ${image $HOME/1_accuweather/fond/base.png -p 0,15 -s 300x150}
]];
bargraph.system.lua:

Code : Tout sélectionner

--[[ BARGRAPH WIDGET
	Author: Nooby4Ever v2.2
	Original author: wlourf (v1.0-2.1)
	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/NAME-OF-THE-SCRIPT.lua
	lua_draw_hook_pre main_bars
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

==Note: 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",

============================ EXTENTIONS =====================================================================
==Note: only works with block=1 and angle_bar=0 (circular bars)
handle_show		-(true or false) determins wherther or not the handle is shown
			all parameters of handle only matters if this is set true	
handle_size		- (number >0) determins the width of the handle
handle_color		- colour of the handle, default= {0x00FF00,1}
handle_length		- (number > width) determines the length of the handle
handle_flip		- (true or false) if length is set puts the handle out of the bar on the other side

==Note: not available for circular bars
=== note: txt_offsety and txt_offset are affected by txt_angle, every position is possible just play a bit with them
txt_show		- (true or false) determins wherther or not the text is shown 
			all parameters of txt only matters if this is set true.
txt_angle		- (in degree) rotates text, note the angle is not intuitive. (also see note above)
txt_color		- colour of the handle, default= {0x00FF00,1}
txt_size		- (number >0) size of the text
txt_offset		- (number) adds/substacts an extra offset to the x coordinate of the text (relative to the normal position of the text)
txt_offsety		- (number) adds/substacts an extra offset to the y coordinate of the text (relative to the normal position of the text)
txt_flip		- (true or false) puts the text on the other side of the bar if true
txt_font		- Sets the font of the txt (make sure it is put between "fontname"), default="ubuntu"
txt_add			- Adds aditional text behind the value (you might wan to include a space, example " Seconds"), 
			make sure the text is set between " ".
txt_alarm		- (true or false) if an alarm value is set the color of the text will change to the same color of the alarm
			if the value passes (or equals) the alarm value.

BUGS:
===========
- skew_x + skew_y doesnet work

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"
V2.2 (XX XXXX 2013) [FORKED] Added txt and handle support

--      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={
		{	--[ CPU 1 Bar Graph ]--
			name="cpu",
			arg="cpu0",
			max=100,
			alarm=80,
		        alarm_colour={0x104E8B,0.72},
		        bg_colour={0x35586C,0.25},
		        fg_colour={0x87CEEB,0.25},
		        mid_colour={{0.45,0x3299CC,0.70}},
			x=120,y=60,
                        cap="r",
                        blocks=36,
			space=2,
		        height=2,width=10,
			angle=90,
			smooth=true,
			draw_me=true
			},
		{	--[ CPU 2 Bar Graph ]--
			name="cpu",
			arg="cpu1",
			max=100,
			alarm=80,
		        alarm_colour={0x104E8B,0.72},
		        bg_colour={0x35586C,0.25},
		        fg_colour={0x87CEEB,0.25},
		        mid_colour={{0.45,0x3299CC,0.70}},
			x=120,y=73,
			blocks=36,
                        cap="r",
			space=2,
			height=2,width=10,
			angle=90,
			smooth=true,
			draw_me=true
			},
		{	--[ CPU 3 Bar Graph ]--
			name="cpu",
			arg="cpu2",
			max=100,
			alarm=80,
		        alarm_colour={0x104E8B,0.72},
		        bg_colour={0x35586C,0.25},
		        fg_colour={0x87CEEB,0.25},
		        mid_colour={{0.45,0x3299CC,0.70}},
			x=120,y=86,
			blocks=36,
                        cap="r",
			space=2,
			height=2,width=10,
			angle=90,
			smooth=true,
			draw_me=true
			},
		{	--[ CPU 4 Bar Graph ]--
			name="cpu",
			arg="cpu3",
			max=100,
			alarm=80,
		        alarm_colour={0x104E8B,0.72},
		        bg_colour={0x35586C,0.25},
		        fg_colour={0x87CEEB,0.25},
		        mid_colour={{0.45,0x3299CC,0.70}},
			x=120,y=99,
			blocks=36,
                        cap="r",
			space=2,
			height=2,width=10,
			angle=90,
			smooth=true,
			draw_me=true
			},
		{	--[ MEMORY Bar Graph ]--
			name="memperc",
			arg="",
			max=100,
			alarm=80,
		        alarm_colour={0xFF0000,0.72},
		        bg_colour={0x35586C,0.25},
		        fg_colour={0x87CEEB,0.25},
		        mid_colour={{0.45,0x3299CC,0.70}},
			x=185,y=127,
			blocks=35,
			space=2,
			height=2,width=10,
			angle=90,
			smooth=true,
			draw_me=true
			},
		
		 }	
-----------END OF PARAMETERS--------------

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

end

function draw_multi_bar_graph(t)
	cairo_save(cr)
	--check values
	if t.draw_me == true then t.draw_me = nil end
	if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end	
	if t.name==nil and t.arg==nil then 
		print ("No input values ... use parameters 'name' with 'arg' or only parameter 'arg' ") 
		return
	end
	if t.max==nil then
		print ("No maximum value defined, use 'max'")
		return
	end
	if t.name==nil then t.name="" end
	if t.arg==nil then t.arg="" end

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

	if t.mid_colour ~= nil then	
		for i=1, #t.mid_colour do    
		    if #t.mid_colour[i]~=3 then 
		    	print ("error in mid_color table")
		    	t.mid_colour[i]={1,0xFFFFFF,1} 
		    end
		end
    	end
	
	if t.alarm==nil then t.alarm = t.max end --0.8*t.max end
	if t.smooth == nil then t.smooth = false end

	--handle
	if t.handle_show == nil		then t.handel_show=false end
	if t.handle_size == nil		then t.handle_size=t.width/2 end
	if t.handle_color == nil	then t.handle_color={0x00FF01,1} end
	if #t.handle_color ~= 2		then t.handle_color={0x00FF01,1} end
	if t.handle_length == nil or t.handle_length < t.width	then t.handle_length=t.width end
	if t.handle_flip == nil		then t.handle_flip=false end

	--txt
	if t.txt_show == nil		then t.txt_show=false end
	if t.txt_angle == nil		then t.txt_angle=0 end
	if t.txt_color == nil		then t.txt_color={0x00FF01,1} end
	if #t.txt_color ~= 2		then t.txt_color={0x00FF01,1} end
	if t.txt_size == nil		then t.txt_size=t.width end
	if t.txt_offset == nil		then t.txt_offset=0 end
	if t.txt_flip == nil		then t.txt_flip=false end
	if t.txt_font == nil		then t.txt_font="ubuntu" end
	if t.txt_add == nil		then t.txt_add="" end
	if (t.txt_alarm == nil) or (t.alarm == t.max)		then t.txt_alarm= false end
	if t.txt_offsety == nil		then t.txt_offsety=0 end
	if t.txt_weight == nil		then t.txt_weight=0 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.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
	
	-- Function to return r g b color
 	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

	--this fucntion is used for bars with a single block (blocks=1)
	local function draw_single_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)
			if (not t.handle_show) then
				cairo_rectangle(cr,0,0,t.width,y1)
			else
				if (y1 <= -t.handle_size) then
					cairo_rectangle(cr,0,0,t.width,y1+t.handle_size)
				end
			end
			cairo_fill(cr)
			cairo_pattern_destroy(pat)

			--block for handle
			if (t.handle_show) then
				local offsetx = 0
				if t.handle_flip then offsetx= t.handle_length-t.width end
				pat = cairo_pattern_create_rgba (rgb_to_r_g_b(t.handle_color))
				cairo_set_source(cr,pat)
				if (y1 >= -t.handle_size) then
					cairo_rectangle(cr,0-offsetx,0,t.handle_length,y1)
				else
					cairo_rectangle(cr,0-offsetx,y1+t.handle_size,t.handle_length,-t.handle_size)	
				end
				cairo_fill(cr)
				cairo_pattern_destroy(pat)
			end
			
			-- 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
	
	--function used for bars with 2 or more blocks
	local function draw_multi_bar()
		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
					if pct>=(100*t.alarm/t.max) and (pcb*pt)>(100*t.alarm/t.max) then 	-- Check whether the value is in the alarm range
						col_alp = t.alarm_colour 
						col_led = t.alarm_led 
					else
						-- Not in alarm range
						col_alp = t.fg_colour
						col_led = t.fg_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
	
	
	
	--function used to retrieve the value to display and to set the cairo structure
	local function setup_bar_graph()
		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
	
		-- Value checks
		if value==nil then value =0 end
		if value > t.max then 
			print ("value retrieved from conky: " .. value .. " is bigger than max: " .. t.max .. ", value is set to max.")
			value=t.max
		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

		--block for TXT
		-- -- Must be drawn after "bar" is assigned to matrix to avoid reflection of the text
		if (t.txt_show and t.angle_bar==0) then
			local ypos=0
			local barnr=0
			if (t.blocks == 1) then		--Determine the y position of the txt
				ypos = -t.height*pct/100 - t.txt_offsety
			else
				--Inefficient, feel free to replace with a formula (get block of the value)
				if (value <  (t.max/t.blocks)) then
					ypos= 0
				elseif (value > (t.max - (t.max/t.blocks))) then
					ypos= -(t.blocks-1)*(t.height+t.space)
				else
					for bar = 1,t.blocks do
						if not ((pct>=(100/t.blocks) or pct>0) and (pct>=(pcb*(bar-1)))) then --ligth on or not the block	
							barnr=bar					
							break
						end
					end
					ypos= -(barnr-2)*(t.height+t.space) - t.txt_offsety
				end
			end
			cairo_save(cr)	
			cairo_select_font_face(cr, t.txt_font, CAIRO_FONT_SLANT_NORMAL, t.txt_weight)
    			cairo_set_font_size(cr, t.txt_size)
			if (t.txt_alarm and value >= t.alarm) then
				cairo_set_source_rgba(cr, rgb_to_r_g_b(t.alarm_colour))
			else
				cairo_set_source_rgba(cr, rgb_to_r_g_b(t.txt_color))
			end
			if (t.txt_flip) then
				cairo_move_to (cr, -(t.width+t.txt_offset), ypos+10)
			else
				cairo_move_to (cr, t.width+t.txt_offset, ypos+10)
			end
			cairo_rotate(cr,t.txt_angle)
			cairo_show_text(cr, (pct/100*t.max) .. t.txt_add)
			cairo_restore(cr)
		end

		--dot for reminder (uncomment to debug, indicates 0,0)
		--[[		
		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)
			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

			cairo_transform(cr,matrix1)

			if t.blocks==1 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)
			cairo_rectangle(cr,pts[1],pts[2],pts[3],pts[4])

			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
files_ring_hdd.lua:

Code : Tout sélectionner

--==============================================================================
--                            seamod_rings.lua
--
--  Date    : 05/02/2012
--  Author  : SeaJey
--  Version : v0.1
--  License : Distributed under the terms of GNU GPL version 2 or later
--
--  This version is a modification of lunatico_rings.lua wich is modification of conky_orange.lua 
--
--  conky_orange.lua:    http://gnome-look.org/content/show.php?content=137503&forumpage=0
--  lunatico_rings.lua:  http://gnome-look.org/content/show.php?content=142884
--==============================================================================
require 'cairo'


--------------------------------------------------------------------------------
--                                                                    gauge DATA
gauge = {
{
    name='fs_used_perc',            arg='',                  max_value=100,
    x=80,                          y=90,
    graph_radius=20,
    graph_thickness=5,
    graph_start_angle=90,
    graph_unit_angle=3,          graph_unit_thickness=2.7,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
    graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.3,
    hand_fg_colour=0x1793d0,       hand_fg_alpha=1.0,
    txt_radius=30,
    txt_weight=0,                  txt_size=9.0,
    txt_fg_colour=0x1793d0,        txt_fg_alpha=1.0,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
    caption='System',
    caption_weight=1,              caption_size=12.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},
{
    name='fs_used_perc',            arg='/home',                  max_value=100,
    x=80,                          y=90,
    graph_radius=40,
    graph_thickness=5,
    graph_start_angle=120,
    graph_unit_angle=3,          graph_unit_thickness=2.7,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
    graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.3,
    hand_fg_colour=0x1793d0,       hand_fg_alpha=1.0,
    txt_radius=50,
    txt_weight=0,                  txt_size=9.0,
    txt_fg_colour=0x1793d0,        txt_fg_alpha=1.0,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
    caption='Home',
    caption_weight=1,              caption_size=12.0,
    caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
},
}

-------------------------------------------------------------------------------
--                                                                 rgb_to_r_g_b
-- converts color in hexa to decimal
--
function rgb_to_r_g_b(colour, alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

-------------------------------------------------------------------------------
--                                                            angle_to_position
-- convert degree to rad and rotate (0 degree is top/north)
--
function angle_to_position(start_angle, current_angle)
    local pos = current_angle + start_angle
    return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end


-------------------------------------------------------------------------------
--                                                              draw_gauge_ring
-- displays gauges
--
function draw_gauge_ring(display, data, value)
    local max_value = data['max_value']
    local x, y = data['x'], data['y']
    local graph_radius = data['graph_radius']
    local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
    local graph_start_angle = data['graph_start_angle']
    local graph_unit_angle = data['graph_unit_angle']
    local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
    local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
    local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
    local graph_end_angle = (max_value * graph_unit_angle) % 360

    -- background ring
    cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
    cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
    cairo_set_line_width(display, graph_thickness)
    cairo_stroke(display)

    -- arc of value
    local val = value % (max_value + 1)
    local start_arc = 0
    local stop_arc = 0
    local i = 1
    while i <= val do
        start_arc = (graph_unit_angle * i) - graph_unit_thickness
        stop_arc = (graph_unit_angle * i)
        cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
        cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
        cairo_stroke(display)
        i = i + 1
    end
    local angle = start_arc

    -- hand
    start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2)
    stop_arc = (graph_unit_angle * val)
    cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
    cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
    cairo_stroke(display)

    -- graduations marks
    local graduation_radius = data['graduation_radius']
    local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
    local graduation_unit_angle = data['graduation_unit_angle']
    local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
    if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
        local nb_graduation = graph_end_angle / graduation_unit_angle
        local i = 0
        while i < nb_graduation do
            cairo_set_line_width(display, graduation_thickness)
            start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
            stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
            cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
            cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
            cairo_stroke(display)
            cairo_set_line_width(display, graph_thickness)
            i = i + 1
        end
    end

    -- text
    local txt_radius = data['txt_radius']
    local txt_weight, txt_size = data['txt_weight'], data['txt_size']
    local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
    local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
    local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
    cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight)
    cairo_set_font_size (display, txt_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
    cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
    cairo_show_text (display, value)
    cairo_stroke (display)

    -- caption
    local caption = data['caption']
    local caption_weight, caption_size = data['caption_weight'], data['caption_size']
    local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
    local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
    local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
    cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight);
    cairo_set_font_size (display, caption_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
    cairo_move_to (display, x + tox + 5, y + toy + 1)
    -- bad hack but not enough time !
    if graph_start_angle < 105 then
        cairo_move_to (display, x + tox - 30, y + toy + 1)
    end
    cairo_show_text (display, caption)
    cairo_stroke (display)
end


-------------------------------------------------------------------------------
--                                                               go_gauge_rings
-- loads data and displays gauges
--
function go_gauge_rings(display)
    local function load_gauge_rings(display, data)
        local str, value = '', 0
        str = string.format('${%s %s}',data['name'], data['arg'])
        str = conky_parse(str)
        value = tonumber(str)
        draw_gauge_ring(display, data, value)
    end
    
    for i in pairs(gauge) do
        load_gauge_rings(display, gauge[i])
    end
end

-------------------------------------------------------------------------------
--                                                                         MAIN
function conky_system()
    if conky_window == nil then 
        return
    end

    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local display = cairo_create(cs)
    
    local updates = conky_parse('${updates}')
    update_num = tonumber(updates)
    
    if update_num > 5 then
        go_gauge_rings(display)
    end

    cairo_surface_destroy(cs)
    cairo_destroy(display)

end
net_graph.lua:

Code : Tout sélectionner

require 'cairo'

function set_settings()
	graph_settings={

        {--Upload Bar
        name="upspeedf",
        arg="enp2s0",
        max=100,
        autoscale=true,
        x=50,        y=90,
        width=228,
        height=32,
        nb_values=500,
        background =false,
        fg_colour={ {0,0x0F5E85,1}, {1,0x1793d0,1}},
        fg_orientation="ww"
        },

        {--Download Bar
        name="downspeedf",
        arg="enp2s0",
        max=100,
        autoscale=true,
        x=278,        y=95,
        width=228,
        height=32,
        nb_values=500,
	inverse=true,
        background =false,
        fg_colour={ {0,0x0F5E85,1}, {1,0x1793d0,1}},
        fg_orientation="ww",
	angle=180
        },
                                                                                       
       }
end


function check_settings(t)
    --tables are check only when conky start
	if t.name==nil and t.arg==nil then 
		print ("No input values ... use parameters 'name'" .. 
			" with 'arg' or only parameter 'arg' ") 
		return 1
	end

	if t.max==nil then
		print ("No maximum value defined, use 'max'")
		print ("for name=" .. t.name .. " with arg=" .. t.arg)
		return 1
	end
	if t.name==nil then t.name="" end
	if t.arg==nil then t.arg="" end
	return 0
end

function conky_main_graph()

    if conky_window == nil then return end
	    
    local w=conky_window.width
    local h=conky_window.height
    local cs=cairo_xlib_surface_create(conky_window.display, 
            conky_window.drawable, conky_window.visual, w, h)
    cr=cairo_create(cs)

    updates=tonumber(conky_parse('${updates}'))
    --start drawing after "updates_gap" updates
    --prevent segmentation error for cpu
    updates_gap=5
    flagOK=0
    if updates==1 then    
        set_settings()
	    
	    flagOK=0
		for i in pairs(graph_settings) do
			if graph_settings[i].width==nil then graph_settings[i].width=100 end
        	if graph_settings[i].nb_values==nil then  
        	    graph_settings[i].nb_values= graph_settings[i].width
        	end
			--create an empty table to store values
			graph_settings[i]["values"]={}
			--beginning point
			graph_settings[i].beg = graph_settings[i].nb_values
			--graph_settings[i].beg = 0
			for j =1, graph_settings[i].nb_values do
			    graph_settings[i].values[j]=0
			end
		    graph_settings[i].flag_init=true
		    flagOK=flagOK + check_settings(graph_settings[i])

		end
    end

    if flagOK>0 then 
        --abort script if error in one of the tables
        print ("ERROR : Check the graph_setting table")
        return
    end

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

    cairo_destroy(cr)
    cairo_surface_destroy(cs)
	updates=nil
	updates_gap=nil
end


function draw_graph(t)
    --drawing function

    local function rgb_to_r_g_b(colour)
        return ((colour[2] / 0x10000) % 0x100) / 255., ((colour[2] / 0x100) % 0x100) / 255., (colour[2] % 0x100) / 255., colour[3]
    end
 
	local function linear_orientation(o,w,h)
	    --set gradient for bg and bg border
	    local p
		if o=="nn" then
			p={w/2,h,w/2,0}
		elseif o=="ne" then
			p={w,h,0,0}
		elseif o=="ww" then
			p={0,h/2,w,h/2}
		elseif o=="se" then
			p={w,0,0,h}
		elseif o=="ss" then
			p={w/2,0,w/2,h}
		elseif o=="ee" then
			p={w,h/2,0,h/2}		
		elseif o=="sw" then
			p={0,0,w,h}
		elseif o=="nw" then
			p={0,h,w,0}
		end
		return p
	end

	local function linear_orientation_inv(o,w,h)
	    --set gradient for fg and fg border
	    local p
		if o=="ss" then
			p={w/2,h,w/2,0}
		elseif o=="sw" then
			p={w,h,0,0}
		elseif o=="ee" then
			p={0,h/2,w,h/2}
		elseif o=="nw" then
			p={w,0,0,h}
		elseif o=="nn" then
			p={w/2,0,w/2,h}
		elseif o=="ww" then
			p={w,h/2,0,h/2}		
		elseif o=="ne" then
			p={0,0,w,h}
		elseif o=="se" then
			p={0,h,w,0}
		end
		return p
	end


	--set default values
	
    --cancel drawing if not needed
	if t.draw_me~=nil and conky_parse(tostring(t.draw_me)) ~= "1" then 
		return
	end
	

	
	if t.height==nil	then t.height=20 end
	--checked in previous part : width and nb_values
		
	if t.background==nil    then t.background=true end
	if t.bg_bd_size==nil	then t.bg_bd_size=0 end
	if t.x==nil 		    then t.x=t.bg_bd_size end
	if t.y==nil 		    then t.y=conky_window.height -t.bg_bd_size end
	if t.bg_colour==nil 	then t.bg_colour={{0,0x000000,.5},{1,0xFFFFFF,.5}} end
	if t.bg_bd_colour==nil 	then t.bg_bd_colour={{1,0xFFFFFF,1}} end
	
	if t.foreground==nil    then t.foreground=true end
	if t.fg_colour==nil 	then t.fg_colour={{0,0x00FFFF,1},{1,0x0000FF,1}} end
	
	if t.fg_bd_size==nil	then t.fg_bd_size=0 end	
	if t.fg_bd_colour==nil  then t.fg_bd_colour={{1,0xFFFF00,1}} end
	
	if t.autoscale==nil     then t.autoscale=false end
	if t.inverse==nil       then t.inverse=false end
	if t.angle==nil         then t.angle=0 end
	
	if t.bg_bd_orientation==nil then t.bg_bd_orientation="nn" end
	if t.bg_orientation==nil then t.bg_orientation="nn" end
	if t.fg_bd_orientation==nil then t.fg_bd_orientation="nn" end
	if t.fg_orientation==nil then t.fg_orientation="nn" end

    --check colours tables
	for i=1, #t.fg_colour do    
        if #t.fg_colour[i]~=3 then 
        	print ("error in fg_colour table")
        	t.fg_colour[i]={1,0x0000FF,1} 
        end
    end
	
	for i=1, #t.fg_bd_colour do    
        if #t.fg_bd_colour[i]~=3 then 
        	print ("error in fg_bd_colour table")
        	t.fg_bd_colour[i]={1,0x00FF00,1} 
        end
    end
    
	for i=1, #t.bg_colour do    
        if #t.bg_colour[i]~=3 then 
        	print ("error in background color table")
        	t.bg_colour[i]={1,0xFFFFFF,0.5} 
        end
    end    

	for i=1, #t.bg_bd_colour do    
        if #t.bg_bd_colour[i]~=3 then 
        	print ("error in background border color table")
        	t.bg_bd_colour[i]={1,0xFFFFFF,1} 
        end
    end    

    --calculate skew parameters if needed
    if t.flag_init then
	    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
	    t.flag_init=false
	end

    cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
    cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND)

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

	cairo_translate(cr,t.x,t.y)
	cairo_rotate(cr,t.angle*math.pi/180)
	cairo_scale(cr,1,-1)

	--background
	if t.background then
	    local pts=linear_orientation(t.bg_orientation,t.width,t.height)
		local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
		for i=1, #t.bg_colour do
			--print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
		    cairo_pattern_add_color_stop_rgba (pat, t.bg_colour[i][1], rgb_to_r_g_b(t.bg_colour[i]))
		end
		cairo_set_source (cr, pat)
		cairo_rectangle(cr,0,0,t.width,t.height)	
		cairo_fill(cr)	
		cairo_pattern_destroy(pat)
	end
	
    --autoscale
    cairo_save(cr)
	if t.autoscale then
		t.max= t.automax*1.1
	end
	
    local scale_x = t.width/(t.nb_values-1)
	local scale_y = t.height/t.max
	
    --define first point of the graph
	if updates-updates_gap <t.nb_values then 
		t.beg = t.beg - 1
    	--next line prevent segmentation error when conky window is redraw 
		--quicly when another window "fly" over it
		if t.beg<0 then t.beg=0 end
	else
		t.beg=0
	end
    if t.inverse then cairo_scale(cr,-1,1)
    cairo_translate(cr,-t.width,0) end

	--graph foreground
	if t.foreground then
	    local pts_fg=linear_orientation_inv(t.fg_orientation,t.width,t.height)
	    local pat = cairo_pattern_create_linear (pts_fg[1],pts_fg[2],pts_fg[3],pts_fg[4])
		for i=1,#t.fg_colour,1 do
			cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_colour[i][1], rgb_to_r_g_b(t.fg_colour[i]))
		end
		cairo_set_source (cr, pat)

		cairo_move_to(cr,t.beg*scale_x,0)
		cairo_line_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
		for i=t.beg, t.nb_values-1 do
			cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)		
		end
		cairo_line_to(cr,(t.nb_values-1)*scale_x,0)
		cairo_close_path(cr)
		cairo_fill(cr)
		cairo_pattern_destroy(pat)
	end

	--graph_border
	if t.fg_bd_size>0 then
    	local pts=linear_orientation_inv(t.fg_bd_orientation,t.width,t.height)
		local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
		for i=1,#t.fg_bd_colour,1 do
			cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_bd_colour[i][1], rgb_to_r_g_b(t.fg_bd_colour[i]))
		end
		cairo_set_source (cr, pat)
		cairo_move_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
		for i=t.beg, t.nb_values-1 do
			cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)		
		end
		cairo_set_line_width(cr,t.fg_bd_size)
		cairo_stroke(cr)
		cairo_pattern_destroy(pat)
	end
	cairo_restore(cr)

	--background border
	if t.bg_bd_size>0 then
    	local pts=linear_orientation(t.bg_bd_orientation,t.width,t.height)
		local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
		for i=1, #t.bg_bd_colour do
			--print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
		    cairo_pattern_add_color_stop_rgba (pat, t.bg_bd_colour[i][1], rgb_to_r_g_b(t.bg_bd_colour[i]))
		end
		cairo_set_source (cr, pat)
		cairo_rectangle(cr,0,0,t.width,t.height)	
		cairo_set_line_width(cr,t.bg_bd_size)
		cairo_stroke(cr)
		cairo_pattern_destroy(pat)	
	end	

	cairo_restore(cr)

end
Linux mint 19 cinnamon x64 - kernel 4.19.0-041900-generic
CPU: i7 3770 - CM: GA-B75M-D3H-16go ram
GPU: MSI nvidia gtx 660 - driver: 410.66

Avatar du membre
Cyrrus
Messages : 402
Enregistré le : mar. 29 nov. 2016 01:09
Localisation : French County

Re: Nos conky 2017

Message par Cyrrus » sam. 21 janv. 2017 10:31

Hello, très chouette le tien ! Je vais essayer de m'en compiler un avec tes codes.
Merci ;)

Avatar du membre
toryx
Messages : 165
Enregistré le : dim. 11 sept. 2016 21:57

Re: Nos conky 2017

Message par toryx » sam. 21 janv. 2017 13:14

j'espere que tu t'y retrouver dans mon bordel :roll: j'ai fait au mieux selon mes capacités
et en passant pas mal non plus les tiens, chouette avec les icons
Linux mint 19 cinnamon x64 - kernel 4.19.0-041900-generic
CPU: i7 3770 - CM: GA-B75M-D3H-16go ram
GPU: MSI nvidia gtx 660 - driver: 410.66

Avatar du membre
Cyrrus
Messages : 402
Enregistré le : mar. 29 nov. 2016 01:09
Localisation : French County

Re: Nos conky 2017

Message par Cyrrus » sam. 21 janv. 2017 13:43

Merci ! Je n'ai fait que les récupérer sur le net et changer les couleurs, je n'ai pas de mérite ! :mrgreen:

Avatar du membre
Dickanom
Messages : 233
Enregistré le : mer. 17 août 2016 18:32
Localisation : Villeneuve-Loubet

Re: Nos conky 2017

Message par Dickanom » dim. 22 janv. 2017 14:13

Salut a tous

mon petit conky de débutent rien a voir avec les vôtres messieurs.. ;)

Image
Image

Répondre