#1501 Le 04/06/2012, à 16:38
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Merci beaucoup ça fonctionne
Bonne fin de journée
Hors ligne
#1502 Le 05/06/2012, à 16:33
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
bonjour je voudrai supprimer la partie conky eth0 du conky de droite
pour la parti conkyrc rien de difficile mais la partie lua je n'y comprend rien si quelqu'un peut m'aider
conkyrc_5
#==============================================================================
# conkyrc_7
#
# author : CAYMUS
# version : v20120420-07
# license : Distributed under the terms of GNU GPL version 2 or later
#
#==============================================================================
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius
double_buffer yes
no_buffers yes
text_buffer_size 2048
gap_x 10
gap_y 30
minimum_size 190 700
#maximum_width 190
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_argb_visual yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment tr
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
override_utf8_locale yes
use_xft yes
xftfont caviar dreams:size=8
xftalpha 0.5
uppercase no
default_color 666666
color1 888888
color2 AAAAAA
color3 DDDDDD
color4 CC3333
lua_load ~/.conky/conky19/conky_8.lua
lua_draw_hook_pre main_bars
lua_draw_hook_post main_box
TEXT
${goto 5}${font caviar dreams:size=12,weight:bold}${color #F09000}$sysname ${font caviar dreams:size=7,weight:bold}${color}$kernel on $machine
${voffset 8}
${goto 5}${font caviar dreams:size=12,weight:bold}${color}CPU
${goto 5}${font caviar dreams:size=7,weight:normal}${color}core 1:${goto 50}${cpu cpu1}%
${goto 5}${font caviar dreams:size=7,weight:normal}${color}core 2:${goto 50}${cpu cpu2}%
${goto 5}${font caviar dreams:size=7,weight:normal}${color2}${top name 1}${goto 100}${top pid 1}${goto 135}${top cpu 1}%
${goto 5}${font caviar dreams:size=7,weight:normal}${color}${top name 2}${goto 100}${top pid 2}${goto 135}${top cpu 2}%
${goto 5}${font caviar dreams:size=7,weight:normal}${color}${top name 3}${goto 100}${top pid 3}${goto 135}${top cpu 3}%
${goto 5}${font caviar dreams:size=7,weight:normal}${color}${threads} process
${goto 5}${cpugraph 10,100 AAAAAA AAAAAA}
${voffset 0}
${goto 5}${font caviar dreams:size=12,weight:bold}${color}MEM
${goto 5}${font caviar dreams:size=7,weight:normal}${color}RAM ${goto 40}$mem
${goto 5}${font caviar dreams:size=7,weight:normal}${color}SWAP ${goto 40}$swap
${goto 5}${font caviar dreams:size=7,weight:normal}${color2}${top_mem name 1}${goto 100}${top_mem pid 1}${goto 135}${top_mem mem 1}%
${goto 5}${font caviar dreams:size=7,weight:normal}${color}${top_mem name 2}${goto 100}${top_mem pid 2}${goto 135}${top_mem mem 2}%
${goto 5}${font caviar dreams:size=7,weight:normal}${color}${top_mem name 3}${goto 100}${top_mem pid 3}${goto 135}${top_mem mem 3}%
${voffset 3}
${goto 5}${font caviar dreams:size=12,weight:bold}${color}DISKS
${goto 5}${font caviar dreams:size=7,weight:normal}${color}/home${goto 45}${fs_used /home}
${goto 5}${font caviar dreams:size=7,weight:normal}${color}/${goto 45}${fs_used /}
${goto 5}${diskiograph 10,100 AAAAAA AAAAAA}
${voffset 4}
${goto 5}${font caviar dreams:size=12,weight:bold}${color}NET
${goto 5}${color1}${font caviar dreams:size=7,weight:bold}eth0 ${addr eth0}
${goto 5}${color}${font caviar dreams:size=7,weight:normal}Down: ${downspeed eth0}
${goto 5}${color}${font caviar dreams:size=7,weight:normal}Up: ${upspeed eth0}
${goto 5}Total Down: ${totaldown eth0}
${goto 5}Total Up: ${totalup eth0}
${voffset 2}
${goto 5}${color1}${font caviar dreams:size=7,weight:bold}wifi ${addr wlan0}
${goto 5}${color}${font caviar dreams:size=7,weight:normal}AP: ${wireless_essid wlan0} ${goto 125}Speed: ${wireless_bitrate wlan0}
${goto 5}Mode: ${wireless_mode wlan0} ${goto 125}Quality: ${wireless_link_qual_perc wlan0}%
${goto 5}Down: ${downspeed wlan0}
${goto 5}Up: ${upspeed wlan0}
${goto 5}Total Down: ${totaldown wlan0}
${goto 5}Total Up: ${totalup wlan0}
${goto 5}${font caviar dreams:size=7,weight:bold}${color}open ports: ${tcp_portmon 1 65535 count}
${goto 5}${font caviar dreams:size=7,weight:bold}${color}${offset 10}URL${goto 160}PORT
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 0} ${goto 160} ${tcp_portmon 1 65535 rport 0}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 1} ${goto 160} ${tcp_portmon 1 65535 rport 1}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 2} ${goto 160} ${tcp_portmon 1 65535 rport 2}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 3} ${goto 160} ${tcp_portmon 1 65535 rport 3}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 4} ${goto 160} ${tcp_portmon 1 65535 rport 4}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 5} ${goto 160} ${tcp_portmon 1 65535 rport 5}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 6} ${goto 160} ${tcp_portmon 1 65535 rport 6}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 7} ${goto 160} ${tcp_portmon 1 65535 rport 7}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 8} ${goto 160} ${tcp_portmon 1 65535 rport 8}
${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rhost 9} ${goto 160} ${tcp_portmon 1 65535 rport 9}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 0}${alignr 1}${tcp_portmon 1 65535 rport 0}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 1}${alignr 1}${tcp_portmon 1 65535 rport 1}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 2}${alignr 1}${tcp_portmon 1 65535 rport 2}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 3}${alignr 1}${tcp_portmon 1 65535 rport 3}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 4}${alignr 1}${tcp_portmon 1 65535 rport 4}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 5}${alignr 1}${tcp_portmon 1 65535 rport 5}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 6}${alignr 1}${tcp_portmon 1 65535 rport 6}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 7}${alignr 1}${tcp_portmon 1 65535 rport 7}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 8}${alignr 1}${tcp_portmon 1 65535 rport 8}
#${goto 5}${font caviar dreams:size=7,weight:normal}${color1}${tcp_portmon 1 65535 rip 9}${alignr 1}${tcp_portmon 1 65535 rport 9}
conky_8.lua
--[[ BARGRAPH WIDGET
v2.1 by wlourf (07 Jan. 2011)
edited by Caymus
this widget draws a bargraph with different effects
http://u-scripts.blogspot.com/2010/07/bargraph-widget.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/bargraph.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display, for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable, for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach, for example, for {$cpu cpu0}, just write max=100
Optional parameters:
x,y - coordinates of the starting point of the bar, default = middle of the conky window
cap - end of cap line, ossibles values are r,b,s (for round, butt, square), default="b"
http://www.cairographics.org/samples/set_line_cap/
angle - angle of rotation of the bar in degress, default = 0 (i.e. a vertical bar)
set to 90 for an horizontal bar
skew_x - skew bar around x axis, default = 0
skew_y - skew bar around y axis, default = 0
blocks - number of blocks to display for a bar (values >0) , default= 10
height - height of a block, default=10 pixels
width - width of a block, default=20 pixels
space - space between 2 blocks, default=2 pixels
angle_bar - this angle is used to draw a bar on a circular way (ok, this is no more a bar !) default=0
radius - for cicular bars, internal radius, default=0
with radius, parameter width has no more effect.
Colours below are defined into braces {colour in hexadecimal, alpha}
fg_colour - colour of a block ON, default= {0x00FF00,1}
bg_colour - colour of a block OFF, default = {0x00FF00,0.5}
alarm - threshold, values after this threshold will use alarm_colour colour , default=max
alarm_colour - colour of a block greater than alarm, default=fg_colour
smooth - (true or false), create a gradient from fg_colour to bg_colour, default=false
mid_colour - colours to add to gradient, with this syntax {position into the gradient (0 to1), colour hexa, alpha}
for example, this table {{0.25,0xff0000,1},{0.5,0x00ff00,1},{0.75,0x0000ff,1}} will add
3 colurs to gradient created by fg_colour and alarm_colour, default=no mid_colour
led_effect - add LED effects to each block, default=no led_effect
if smooth=true, led_effect is not used
possibles values : "r","a","e" for radial, parallelel, perdendicular to the bar (just try!)
led_effect has to be used with theses colours :
fg_led - middle colour of a block ON, default = fg_colour
bg_led - middle colour of a block OFF, default = bg_colour
alarm_led - middle colour of a block > ALARM, default = alarm_colour
reflection parameters, not avaimable for circular bars
reflection_alpha - add a reflection effect (values from 0 to 1) default = 0 = no reflection
other values = starting opacity
reflection_scale - scale of the reflection (default = 1 = height of text)
reflection_length - length of reflection, define where the opacity will be set to zero
calues from 0 to 1, default =1
reflection - position of reflection, relative to a vertical bar, default="b"
possibles values are : "b","t","l","r" for bottom, top, left, right
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
v1.0 (10 Feb. 2010) original release
v1.1 (13 Feb. 2010) numeric values can be passed instead conky stats with parameters name="", arg = numeric_value
v1.2 (28 Feb. 2010) just renamed the widget to bargraph
v1.3 (03 Mar. 2010) added parameters radius & angle_bar to draw the bar in a circular way
v2.0 (12 Jul. 2010) rewrite script + add reflection effects and parameters are now set into tables
v2.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation version 3 (GPLv3)
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-- MA 02110-1301, USA.
]]
require 'cairo'
----------------START OF PARAMETERS ----------
function conky_main_bars()
local bars_settings={
{
name="cpu",
arg="cpu1",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=80,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu2",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=90,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="memperc",
arg="",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=225,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="swapperc",
arg="",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=235,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/home",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=350,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=360,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="downspeedf",
arg="eth0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=450,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="eth0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=460,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="downspeedf",
arg="wlan0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=560,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="wlan0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=570,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
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
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne
#1503 Le 05/06/2012, à 17:30
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bonjour ljere,
Dans ton conky tu supprime (ou tu met en remarque #) les lignes suivantes
${voffset 4}
${goto 5}${font caviar dreams:size=12,weight:bold}${color}NET
${goto 5}${color1}${font caviar dreams:size=7,weight:bold}eth0 ${addr eth0}
${goto 5}${color}${font caviar dreams:size=7,weight:normal}Down: ${downspeed eth0}
${goto 5}${color}${font caviar dreams:size=7,weight:normal}Up: ${upspeed eth0}
${goto 5}Total Down: ${totaldown eth0}
${goto 5}Total Up: ${totalup eth0}
Dans le lua tu supprime (ou met en remarque --[[ zonne en remarque ]]--) les lignes suivantes
{
name="downspeedf",
arg="eth0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=450,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="eth0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=460,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
il y a un truc étrange dans ce script, les zones ou le texte est en gris ne sont pas gérées par le conky mais par des rectangle dessinés par le script lua.
Il faudra certainement supprimer l'une des lignes suivante, et modifier la position de certaines après la modification.
---------------------- 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" } ,
}
a mon avis sa ce joura sur les deux dernières certainement comme ceci, mais je suis pas sure.
---------------------- 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=150, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
}
Hors ligne
#1504 Le 05/06/2012, à 19:00
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
merci Didier-T grâce à ton intervention j'ai réussi à modifier ce conky pour qu'il soit parfait pour mon cas
voici ce que j'ai modifié
--[[ {
name="downspeedf",
arg="eth0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=450,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="eth0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=460,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},]]--
{
name="downspeedf",
arg="wlan0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=474,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="wlan0",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=484,
blocks=20,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
}
l'autre partie n'a aucun effet donc je l'ai remise comme à l'origine
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne
#1505 Le 05/06/2012, à 20:25
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
merci Didier-T grâce à ton intervention j'ai réussi à modifier ce conky pour qu'il soit parfait pour mon cas
voici ce que j'ai modifié--[[ { name="downspeedf", arg="eth0", max=100, alarm=80, bg_colour={0x00ff00,0.25}, fg_colour={0x00ff00,1}, alarm_colour={0xff0000,1}, x=95,y=450, blocks=20, height=3,width=6, angle=90, smooth=true, cap="e", skew_y=15, mid_colour={{0.5,0xffff00,1}} }, { name="upspeedf", arg="eth0", max=100, alarm=80, bg_colour={0x00ff00,0.25}, fg_colour={0x00ff00,1}, alarm_colour={0xff0000,1}, x=95,y=460, blocks=20, height=3,width=6, angle=90, smooth=true, cap="e", skew_y=15, mid_colour={{0.5,0xffff00,1}} },]]-- { name="downspeedf", arg="wlan0", max=100, alarm=80, bg_colour={0x00ff00,0.25}, fg_colour={0x00ff00,1}, alarm_colour={0xff0000,1}, x=95,y=474, blocks=20, height=3,width=6, angle=90, smooth=true, cap="e", skew_y=15, mid_colour={{0.5,0xffff00,1}} }, { name="upspeedf", arg="wlan0", max=100, alarm=80, bg_colour={0x00ff00,0.25}, fg_colour={0x00ff00,1}, alarm_colour={0xff0000,1}, x=95,y=484, blocks=20, height=3,width=6, angle=90, smooth=true, cap="e", skew_y=15, mid_colour={{0.5,0xffff00,1}} }, }
l'autre partie n'a aucun effet donc je l'ai remise comme à l'origine
en fait l'autre partie semble éclaircir le texte dans certaines zones en ajoutant une sorte de claque, tu devrais donc te retrouver avec une partie des port ouvert en noir et le reste en gris.
Dernière modification par Didier-T (Le 05/06/2012, à 20:27)
Hors ligne
#1506 Le 06/06/2012, à 05:57
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
d'accord je regarderai donc cela ce soir de plus près
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne
#1507 Le 06/06/2012, à 10:14
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Salut,
En fait la 2eme partie du lua, c' est un 2eme script, de wlourf "box" elles affichent bien des rectangles noir transparant.
Ce que je ne comprends pas, c' est que tu parles de conkyrc_5 et de conky_8.lua
à la base c' etait conky_7b si je me rappel bien.
Si les box noir ne s' affichent pas du tout, malgré qu' elles sont biens presentes dans le lua c' est probable que tu aies oublié:
lua_draw_hook_post main_box
dans le conky.
Enfin sinon je voix pas trop car c' est un peu confu, sur ton image, on dirait que tu utilises conky_7a.lua, et dans ton code pasté sur le forum, c' est conky_7b.lua que tu as renomé conky_8.lua
il y a un truc étrange dans ce script, les zones ou le texte est en gris ne sont pas gérées par le conky mais par des rectangle dessinés par le script lua
Bien en fait si tu parles des 1ere lignes d' info, en gris claire, la couleur est bien geré par le conky:
default_color 666666
color1 888888
color2 AAAAAA
color3 DDDDDD
color4 CC3333
${color2}${top name 1}
${color}${top name 2}
par exemple, et ainsi de suite.
Dernière modification par caymus (Le 06/06/2012, à 10:25)
Hors ligne
#1508 Le 06/06/2012, à 10:20
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Salut,
En fait la 2eme partie du lua, c' est un 2eme script, de wlourf "box" elles affichent bien des rectangles noir transparant.
Ce que je ne comprends pas, c' est que tu parles de conkyrc_5 et de conky_8.lua
à la base c' etait conky_7b si je me rappel bien.
Si les box noir ne s' affichent pas du tout, malgré qu' elles sont biens presentes dans le lua c' est probable que tu aies oublié:lua_draw_hook_post main_box
dans le conky.
Enfin sinon je voix pas trop car c' est un peu confu, sur ton image, on dirait que tu utilises conky_7a.lua, et dans ton code pasté sur le forum, c' est conky_7b.lua que tu as renomé conky_8.lua
en fait les box n'apparaissent pas a couse de cette argument dans le conky
own_window_argb_visual yes
la fenêtre étant gérée en vrais transparence tous ce qui est dedans est transparent (voir invisible), a mon avis le choix de cette solution tient au fais que de xfce la fausse transparence de conky ne fonctionnait pas jusqu’à la version 4.10
Hors ligne
#1509 Le 06/06/2012, à 10:28
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Ok, un moment tu m' as fais peur je croyais que j' avais merdé dans mes conkyrc, surtout que je les avaient fait à la chaine, mais j ai bien:
#own_window_argb_visual
dans les originaux.
xfce j' avais pas essayé, j' utilises gnome 3, gnome2 et openbox, pour tester.
Toujours bon à savoir pour xfce, merci de l' info
Dernière modification par caymus (Le 06/06/2012, à 10:36)
Hors ligne
#1510 Le 06/06/2012, à 10:43
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Ok, un moment tu m' as fais peur je croyais que j' avais merdé dans mes conkyrc, surtout que je les avaient fait à la chaine, mais j ai bien:
#own_window_argb_visual
dans les originaux.
xfce j' avais pas essayé, j' utilises gnome 3, gnome2 et openbox, pour tester.
Toujours bon à savoir pour xfce, merci de l' info
Excuse moi j'avais pas fait attention tu est l'auteur du conky, en fait il est super actif ce forum, il y a plein de créateur, c'est cool.
Une petite question tu n'a s jamais essayé de rendre tes conky évolutif.
Je m'explique, dans le cas de ljere le eth0 ne sert à rien, certainement car il ne ce sert que du Wifi, dans mon cas ce serait le contraire, et je suppose que dans ton cas tous ne sert pas en même temps, du coups ce serais sympa si ton conky n'affichait que ce qui les infos utile à l’utilisateur.
Si tu as besoins d'aide pour modifier le script lua, je suis là, bien que d'autres pourrais le faire aussi
Hors ligne
#1511 Le 06/06/2012, à 11:12
- caymus
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Oui j' y avais deja pensé dans le conkyrc_3
${goto 600}${font 6x10:size=12,weight:bold}${color}NET
${voffset -43}
${goto 650}${color1}${font 6x10:size=7,weight:bold}${if_existing /proc/net/route eth0}eth0 ${addr eth0}
${goto 650}${color}${font 6x10:size=7,weight:normal}Down: ${downspeed eth0}
${goto 650}${color}${font 6x10:size=7,weight:normal}Up: ${upspeed eth0}
${goto 650}${color1}${font 6x10:size=7,weight:bold}${else}${if_existing /proc/net/route wlan0}wifi ${addr wlan0}
${goto 650}${color}${font 6x10:size=7,weight:normal}AP: ${wireless_essid wlan0} ${goto 730}Speed: ${wireless_bitrate wlan0}
${goto 650}Mode: ${wireless_mode wlan0} ${goto 730}Quality: ${wireless_link_qual_perc wlan0}%
${goto 650}Down: ${downspeed wlan0}
${goto 650}Up: ${upspeed wlan0} ${else} "Network Unavailable"
${endif}
Mais je butais sur 2 choses:
1er le conky, ce qui venait derriere wlan 0 disparaissait aussi, on sait résoudre cela par un double {endif} puis continuer le conky normalement? Enfin ca je peux essayer cela ne me prendra pas beaucoup de temps.
Par contre la ou je sechais, c' etait pour faire de meme dans un lua sur les "bars et rings" j' avais essayé cette methode mais je dois coder comme mes pieds car j' avais des erreurs nil.
Si tu sais comment faire, je me ferai un plaisir de corriger tous les conky
Hors ligne
#1512 Le 06/06/2012, à 11:13
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bonjour
Je reviens vers vous parce que j'ai un petit problème avec un conky. Celui-ci ne veut pas se lancer pendant les 5 premières minutes d'utilisation du pc et me met une erreur de segmentation, et a partir de 5min 01 d'utilisation plus de problème pour le lancer.
En espérant que vous pourrez m'aider
Voici les fichiers:
Conkyrc
# Conky settings #
background no
update_interval 1
cpu_avg_samples 4
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
#imlib_cache_size 0
temperature_unit fahrenheit
# Window specifications #
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
minimum_size 275 1000
maximum_width 280
alignment top_right
# Graphics settings #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# Text settings #
use_xft yes
override_utf8_locale yes
xftfont Neuropolitical:size=8
xftalpha 0.8
uppercase no
temperature_unit celsius
default_color FFFFFF
# Lua Load #
lua_load ~/.config/hybryde/Hy-lua/hy2.lua
lua_draw_hook_pre clock_rings
TEXT
${color FFFFFF}${font Neuropolitical:size=14}Médias
${voffset 30}
${color 5f66cb}${goto 25}${font Neuropolitical:size=8}Espace
${color 5f66cb}${goto 30}${font Neuropolitical:size=8}utilisé
${goto 5}${color FFFFFF}${goto 35}${fs_used_perc /}%
Activité : $color${diskio /dev/sda}/s
${if_mounted /media/Nicolas_PNY}${voffset 25}PNY: ${fs_used_perc /media/Nicolas_PNY}% ${fs_free /media/Nicolas_PNY}
${color 5f66cb}${fs_bar 5,100 /media/Nicolas_PNY}%
Activité : $color${diskio /dev/sdc}/${endif}
${if_mounted /media/test}${voffset 25}Test: ${fs_used_perc /media/test}% ${fs_free /media/test}
${color 5f66cb}${fs_bar 5,100 /media/test}
Activité : $color${diskio /dev/sdb}/s${endif}
${color 5f66cb}${hr}
${color FFFFFF}${font Neuropolitical:size=14}Mails
${color 5f66cb}${font Neuropolitical:size=12}Gmail: ${color FFFFFF}${font Neuropolitical:size=10}${execpi 300 python ~/.config/hybryde/Hy-lua/gmail.py}
${color 5f66cb}${font Neuropolitical:size=12}Laposte: ${color FFFFFF}${font Neuropolitical:size=10}${imap_unseen imap.laposte.net ****** ****** -i 60}
${color 5f66cb}${hr}
${color FFFFFF}${font Neuropolitical:size=14}Infos réseau
${color 5f66cb}${font Neuropolitical:size=10}${texeci 300 wget http://checkip.dyndns.org -O - -o /dev/null | cut -d : -f 2 | cut -d \< -f 1}
${addr wlan0}
${color 5f66cb}${hr}
${color FFFFFF}${font Neuropolitical:size=14}Calendrier
${color 5f66cb}${font Neuropolitical:size=12}${execpi 300 conkyGoogleCalendar --username=****** --password=****** --daysahead=7 --dateformat="%a %d %b, %y" --requestCalendarNames="nicolas" --template=~/.config/hybryde/Hy-lua/conkyGoogleCalendar.template}
${color 5f66cb}${hr}
hy2.lua
--[[
Hy-lua by S3B.
Réinterprétation purement graphique du Mint-lua de despot77 pour Hybryde.
Changelog:
+ v1.0 -- Original release (30.09.2009)
+ v1.1p -- Jpope edit londonali1010 (05.10.2009)
+ v Mint-lua -- reEdit despot77 (18.02.2011)
+ Hy-lua -- Reedit by S3B (11.01.2012)
]]
settings_table = {
{
name='fs_used_perc',
arg='/',
max=100,
bg_colour=0xffffff,
bg_alpha=0.2,
fg_colour=0x5f66cb,
fg_alpha=0.8,
x=83, y=70,
radius=25,
thickness=25,
start_angle=-90,
end_angle=180
},
}
-- Use these settings to define the origin and extent of your clock.
clock_r=65
-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.
clock_x=100
clock_y=150
show_seconds=true
require 'cairo'
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function draw_ring(cr,t,pt)
local w,h=conky_window.width,conky_window.height
local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
local angle_0=sa*(2*math.pi/360)-math.pi/2
local angle_f=ea*(2*math.pi/360)-math.pi/2
local t_arc=t*(angle_f-angle_0)
-- Draw background ring
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
cairo_set_line_width(cr,ring_w)
cairo_stroke(cr)
-- Draw indicator ring
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
cairo_stroke(cr)
end
function draw_clock_hands(cr,xc,yc)
local secs,mins,hours,secs_arc,mins_arc,hours_arc
local xh,yh,xm,ym,xs,ys
secs=os.date("%S")
mins=os.date("%M")
hours=os.date("%I")
secs_arc=(2*math.pi/60)*secs
mins_arc=(2*math.pi/60)*mins+secs_arc/60
hours_arc=(2*math.pi/12)*hours+mins_arc/12
end
function conky_clock_rings()
local function setup_rings(cr,pt)
local str=''
local value=0
str=string.format('${%s %s}',pt['name'],pt['arg'])
str=conky_parse(str)
value=tonumber(str)
pct=value/pt['max']
draw_ring(cr,pct,pt)
end
-- Check that Conky has been running for at least 5s
if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)
local cr=cairo_create(cs)
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num>5 then
for i in pairs(settings_table) do
setup_rings(cr,settings_table[i])
end
end
draw_clock_hands(cr,clock_x,clock_y)
end
PS: c'est surement pas très beau, j'ai modifié ce que je comprenais ^^
Hors ligne
#1513 Le 06/06/2012, à 12:58
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bonjour n1c0la5,
Tu pourrais nous donner la copie du message d'erreur obtenu en lançant ton conky en Terminal ?
Hors ligne
#1514 Le 06/06/2012, à 13:05
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Oui j' y avais deja pensé dans le conkyrc_3
${goto 600}${font 6x10:size=12,weight:bold}${color}NET ${voffset -43} ${goto 650}${color1}${font 6x10:size=7,weight:bold}${if_existing /proc/net/route eth0}eth0 ${addr eth0} ${goto 650}${color}${font 6x10:size=7,weight:normal}Down: ${downspeed eth0} ${goto 650}${color}${font 6x10:size=7,weight:normal}Up: ${upspeed eth0} ${goto 650}${color1}${font 6x10:size=7,weight:bold}${else}${if_existing /proc/net/route wlan0}wifi ${addr wlan0} ${goto 650}${color}${font 6x10:size=7,weight:normal}AP: ${wireless_essid wlan0} ${goto 730}Speed: ${wireless_bitrate wlan0} ${goto 650}Mode: ${wireless_mode wlan0} ${goto 730}Quality: ${wireless_link_qual_perc wlan0}% ${goto 650}Down: ${downspeed wlan0} ${goto 650}Up: ${upspeed wlan0} ${else} "Network Unavailable" ${endif}
Mais je butais sur 2 choses:
1er le conky, ce qui venait derriere wlan 0 disparaissait aussi, on sait résoudre cela par un double {endif} puis continuer le conky normalement? Enfin ca je peux essayer cela ne me prendra pas beaucoup de temps.Par contre la ou je sechais, c' etait pour faire de meme dans un lua sur les "bars et rings" j' avais essayé cette methode mais je dois coder comme mes pieds car j' avais des erreurs nil.
Si tu sais comment faire, je me ferai un plaisir de corriger tous les conky
En fait dans lua ce sera un peut plus compliqué que dans le conkyrc, car nous mettons les infos pour l'affichage dans un tableau, donc pas de code à cette endroit ci, mais sa peut se faire, j'en suis persuadé.
Il faut que je retrouve tes conkys et je regarderais ça.
Edit ; il manque un end_if dans ton conky (toutes condition doit être fermée, la tu utilise deux condition imbriqués l'une dans l’autre, tu doit donc fermer les deux)
Une fois corrigé sa donne sa
${goto 600}${font 6x10:size=12,weight:bold}${color}NET
${voffset -43}
${goto 650}${color1}${font 6x10:size=7,weight:bold}${if_existing /proc/net/route eth0}eth0 ${addr eth0}
${goto 650}${color}${font 6x10:size=7,weight:normal}Down: ${downspeed eth0}
${goto 650}${color}${font 6x10:size=7,weight:normal}Up: ${upspeed eth0}
${goto 650}${color1}${font 6x10:size=7,weight:bold}${else}${if_existing /proc/net/route wlan0}wifi ${addr wlan0}
${goto 650}${color}${font 6x10:size=7,weight:normal}AP: ${wireless_essid wlan0} ${goto 730}Speed: ${wireless_bitrate wlan0}
${goto 650}Mode: ${wireless_mode wlan0} ${goto 730}Quality: ${wireless_link_qual_perc wlan0}%
${goto 650}Down: ${downspeed wlan0}
${goto 650}Up: ${upspeed wlan0} ${else} "Network Unavailable"
${endif}${endif}
Dernière modification par Didier-T (Le 06/06/2012, à 13:29)
Hors ligne
#1515 Le 06/06/2012, à 14:09
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
@ caymus,
voici le script lua modifié
--[[ BARGRAPH WIDGET
v2.1 by wlourf (07 Jan. 2011)
edited by Caymus
this widget draws a bargraph with different effects
http://u-scripts.blogspot.com/2010/07/bargraph-widget.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/bargraph.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display, for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable, for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach, for example, for {$cpu cpu0}, just write max=100
Optional parameters:
x,y - coordinates of the starting point of the bar, default = middle of the conky window
cap - end of cap line, ossibles values are r,b,s (for round, butt, square), default="b"
http://www.cairographics.org/samples/set_line_cap/
angle - angle of rotation of the bar in degress, default = 0 (i.e. a vertical bar)
set to 90 for an horizontal bar
skew_x - skew bar around x axis, default = 0
skew_y - skew bar around y axis, default = 0
blocks - number of blocks to display for a bar (values >0) , default= 10
height - height of a block, default=10 pixels
width - width of a block, default=20 pixels
space - space between 2 blocks, default=2 pixels
angle_bar - this angle is used to draw a bar on a circular way (ok, this is no more a bar !) default=0
radius - for cicular bars, internal radius, default=0
with radius, parameter width has no more effect.
Colours below are defined into braces {colour in hexadecimal, alpha}
fg_colour - colour of a block ON, default= {0x00FF00,1}
bg_colour - colour of a block OFF, default = {0x00FF00,0.5}
alarm - threshold, values after this threshold will use alarm_colour colour , default=max
alarm_colour - colour of a block greater than alarm, default=fg_colour
smooth - (true or false), create a gradient from fg_colour to bg_colour, default=false
mid_colour - colours to add to gradient, with this syntax {position into the gradient (0 to1), colour hexa, alpha}
for example, this table {{0.25,0xff0000,1},{0.5,0x00ff00,1},{0.75,0x0000ff,1}} will add
3 colurs to gradient created by fg_colour and alarm_colour, default=no mid_colour
led_effect - add LED effects to each block, default=no led_effect
if smooth=true, led_effect is not used
possibles values : "r","a","e" for radial, parallelel, perdendicular to the bar (just try!)
led_effect has to be used with theses colours :
fg_led - middle colour of a block ON, default = fg_colour
bg_led - middle colour of a block OFF, default = bg_colour
alarm_led - middle colour of a block > ALARM, default = alarm_colour
reflection parameters, not avaimable for circular bars
reflection_alpha - add a reflection effect (values from 0 to 1) default = 0 = no reflection
other values = starting opacity
reflection_scale - scale of the reflection (default = 1 = height of text)
reflection_length - length of reflection, define where the opacity will be set to zero
calues from 0 to 1, default =1
reflection - position of reflection, relative to a vertical bar, default="b"
possibles values are : "b","t","l","r" for bottom, top, left, right
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
v1.0 (10 Feb. 2010) original release
v1.1 (13 Feb. 2010) numeric values can be passed instead conky stats with parameters name="", arg = numeric_value
v1.2 (28 Feb. 2010) just renamed the widget to bargraph
v1.3 (03 Mar. 2010) added parameters radius & angle_bar to draw the bar in a circular way
v2.0 (12 Jul. 2010) rewrite script + add reflection effects and parameters are now set into tables
v2.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation version 3 (GPLv3)
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-- MA 02110-1301, USA.
]]
require 'cairo'
----------------START OF PARAMETERS ----------
function conky_main_bars()
local bars_settings={
{
name="cpu",
arg="cpu1",
exist="",--Doit retourner Ok pour afficher les données de ce tableau (où ne doit pas avoir de condition
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=120,y=13,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="cpu",
arg="cpu2",
exist="",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=120,y=23,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="memperc",
arg="",
exist="",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=280,y=13,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="swapperc",
arg="",
exist="",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=280,y=23,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/home",
exist="",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=460,y=13,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="fs_used_perc",
arg="/",
exist="",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=460,y=23,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="downspeedf",
arg="eth0",
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",--Doit retourner Ok pour afficher les données de ce tableau (où ne doit pas avoir de condition
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=450,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="eth0",
exist="${if_existing /proc/net/route eth0}Ok${else}Nil${endif}",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=460,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="downspeedf",
arg="wlan0",
exist="${if_existing /proc/net/route eth0}Nil${else}${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}${endif}",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=560,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
mid_colour={{0.5,0xffff00,1}}
},
{
name="upspeedf",
arg="wlan0",
exist="${if_existing /proc/net/route eth0}Nil${else}${if_existing /proc/net/route wlan0}Ok${else}Nil${endif}${endif}",
max=100,
alarm=80,
bg_colour={0x00ff00,0.25},
fg_colour={0x00ff00,1},
alarm_colour={0xff0000,1},
x=95,y=570,
blocks=5,
height=3,width=6,
angle=90,
smooth=true,
cap="e",
skew_y=15,
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
if bars_settings[i].exist==nil then bars_settings[i].exist="" end
if bars_settings[i].exist~="" then
if conky_parse(bars_settings[i].exist)=="Ok" then
draw_multi_bar_graph(bars_settings[i])
end
else
draw_multi_bar_graph(bars_settings[i])
end
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=0,w=490,h=35, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=590,y=0,w=220,h=70, 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
Je me suis contenter d'ajouter une variable contenant un test conky dans le tableau, si le test renvoi Ok alors le bloc de donnés du tableau est traité sinon il est simplement ignoré. (attention ce doit être Ok pas ok, OK où oK).
Hors ligne
#1516 Le 06/06/2012, à 14:10
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bonjour n1c0la5,
Tu pourrais nous donner la copie du message d'erreur obtenu en lançant ton conky en Terminal ?
Voilà:
nicolas64@nicolas64-HP-G62-Notebook-PC:~$ conky -c .config/hybryde/Hy-lua/conkyrc_droite
Conky: statfs '/media/Nicolas_PNY': No such file or directory
Conky: diskio device 'sdc' does not exist
Conky: statfs '/media/test': No such file or directory
Conky: diskio device 'sdb' does not exist
Conky: desktop window (100001d) is subwindow of root window (150)
Conky: window type - desktop
Conky: drawing to created window (0x2400001)
Conky: drawing to double buffer
Conky: statfs '/media/test': No such file or directory
Conky: statfs '/media/Nicolas_PNY': No such file or directory
Erreur de segmentation
EDIT: et quand ça fonctionne après 5 minutes:
Conky: statfs '/media/Nicolas_PNY': No such file or directory
Conky: diskio device 'sdc' does not exist
Conky: statfs '/media/test': No such file or directory
Conky: diskio device 'sdb' does not exist
Conky: desktop window (100001d) is subwindow of root window (150)
Conky: window type - desktop
Conky: drawing to created window (0x2800001)
Conky: drawing to double buffer
Conky: statfs '/media/test': No such file or directory
Conky: statfs '/media/Nicolas_PNY': No such file or directory
connect: Success
Dernière modification par n1c0la5 (Le 06/06/2012, à 14:14)
Hors ligne
#1517 Le 06/06/2012, à 14:16
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Didier-T a écrit :Bonjour n1c0la5,
Tu pourrais nous donner la copie du message d'erreur obtenu en lançant ton conky en Terminal ?
Voilà:
nicolas64@nicolas64-HP-G62-Notebook-PC:~$ conky -c .config/hybryde/Hy-lua/conkyrc_droite Conky: statfs '/media/Nicolas_PNY': No such file or directory Conky: diskio device 'sdc' does not exist Conky: statfs '/media/test': No such file or directory Conky: diskio device 'sdb' does not exist Conky: desktop window (100001d) is subwindow of root window (150) Conky: window type - desktop Conky: drawing to created window (0x2400001) Conky: drawing to double buffer Conky: statfs '/media/test': No such file or directory Conky: statfs '/media/Nicolas_PNY': No such file or directory Erreur de segmentation
donc conky nous dit que tu n'as pas de sdc ni de sdb, pour les autres répertoires, je suppose qu'ils existent, mais que la partition les contenants n'est pas monté.
Hors ligne
#1518 Le 06/06/2012, à 14:19
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Non ils n'existent pas les clés usb ne sont pas branchées. Ça serait ça le problème?
PS: j'ai édité mon message d'avant pour voir les messages quand ça fonctionne.
Hors ligne
#1519 Le 06/06/2012, à 14:23
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Non ils n'existent pas les clés usb ne sont pas branchées. Ça serait ça le problème?
PS: j'ai édité mon message d'avant pour voir les messages quand ça fonctionne.
en théorie non, c'était juste pour limiter les erreurs, et peut être empêcher le conky de planté suite a un trop grand nombre de problèmes.
Tu peut faire une capture de ton conky.
Hors ligne
#1520 Le 06/06/2012, à 14:27
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bon alors dans mon conky j'ai tenté en supprimant petits bouts par petits bouts après TEXt, mais toujours la même erreur, en supprimant l'intégralité après TEXT il veut bien se lancer (bon ya rien par contre ^^)
Ça se peut qu'il y ait un conflit entre 2 choses affichées?
Hors ligne
#1521 Le 06/06/2012, à 14:31
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bon en fait je serai affecté par ce bug si je comprends bien ce que je lis?
https://bugs.launchpad.net/ubuntu/+sour … ug/1003727
Hors ligne
#1522 Le 06/06/2012, à 14:31
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
essaye de mettre dans ton conky cette ligne si en remarque pour voir.
${color 5f66cb}${font Neuropolitical:size=12}Laposte: ${color FFFFFF}${font Neuropolitical:size=10}${imap_unseen imap.laposte.net ****** ****** -i 60}
Hors ligne
#1523 Le 06/06/2012, à 14:33
- n1c0la5
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
essaye de mettre dans ton conky cette ligne si en remarque pour voir.
${color 5f66cb}${font Neuropolitical:size=12}Laposte: ${color FFFFFF}${font Neuropolitical:size=10}${imap_unseen imap.laposte.net ****** ****** -i 60}
Après redémarrage ça ne change rien
Hors ligne
#1524 Le 06/06/2012, à 14:34
- Didier-T
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
Bon en fait je serai affecté par ce bug si je comprends bien ce que je lis?
https://bugs.launchpad.net/ubuntu/+sour … ug/1003727
ce bug devrait affecter tous tes conky, mais en effet sa semble venir de là donc patience sa sera réglé avec une prochaine mise a jour de ubuntu.
Hors ligne
#1525 Le 06/06/2012, à 14:42
- ljere
Re : (4) Conky : Postez vos conkyrc ou certaines parties intéressantes
bonjour j'ai donc commenté
# own_window_argb_visual yes
ce qui donne ce résultat
si j'ai bien compris je dois donc jouer avec le tableau pour avoir quelque chose de correct
ancien PC Toshiba satellite_c670d-11 / Linux Mint 21 Vanessa
Nouveau PC ASUS TUF GAMING A17 GPU RTX 4070 CPU AMD Ryzen 9 7940HS w/ Radeon 780M Graphics / Linux Mint 21.2 Victoria / Kernel: 6.4.8-1-liquorix / Desktop: Cinnamon
Hors ligne