系统U10.10,conky为源里的all,具体修改自:
viewtopic.php?f=12&t=280236
菜鸟打酱油修改。。娱乐。。
主要修改:
1. 给圈圈绘制提供了顺时针和逆时针两种,图中CPU1为顺时针,CPU2为逆时针;交换区也是逆时针(本人无SWAP。。)
具体代码(看起始转角和最终转角的大小关系判断顺时针与否):
代码: 全选
if angle_0>angle_f then
cairo_arc_negative(cr,xc,yc,ring_r,angle_0,angle_f)
else
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
end
3. 为绘制的弧线进度条提供渐变(含透明度,颜色等)效果,具体settings_table内容修改如下:
代码: 全选
{
name='time',
arg='%I.%M',
max=12,
-- "bg_colour" is the colour of the base ring.
bg_colour=0xffffff,
-- "bg_alpha" is the alpha value of the base ring.
bg_alpha=0.1,
-- "fg_colour" is the colour of the indicator part of the ring.
fg_colour=0x3399cc,
-- "fg_alpha" is the alpha value of the indicator part of the ring.
fg_alpha=0.2,
--自己修改的进度条:0 不开启;1 仅开启进度条变色;2 仅开启透明度变化;3 开启1、2;4 仅开启边框;5 仅开启颜色透明度过渡;6 开启4、5;
change_color=4,
start_alpha=0.2,
end_alpha=0.2,
startcolor=0x3399cc,
endcolor=0x3399cc,
-- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
x=100, y=170,
-- "radius" is the radius of the ring.
radius=50,
-- "thickness" is the thickness of the ring, centred around the radius.
thickness=5,
-- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
start_angle=0,
-- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
end_angle=360
}
代码: 全选
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 cr1,t1,pt1=cr,t,pt
local set_o=pt['change_color']
local stc,edc=pt['startcolor'],pt['endcolor']
local t_color=edc-stc
local d_c=t*t_color+stc
local sta,eda=pt['start_alpha'],pt['end_alpha']
local t_alpha=eda-sta
local d_a=t*t_alpha+sta
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
if angle_0>angle_f then
cairo_arc_negative(cr,xc,yc,ring_r,angle_0,angle_f)
else
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
end
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
if angle_0>angle_f then
cairo_arc_negative(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
else
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
end
if set_o==3 then
cairo_set_source_rgba(cr,rgb_to_r_g_b(d_c,d_a))
else
if set_o==2 then
cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,d_a))
else
if set_o==1 then
cairo_set_source_rgba(cr,rgb_to_r_g_b(d_c,fga))
else
if set_o==0 then
cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
else
if set_o==4 then
change_clr_alpha(cr1,t1,pt1,1)
else
if set_o==5 then
change_clr_alpha(cr1,t1,pt1,2)
else
change_clr_alpha(cr1,t1,pt1,3)
end
end
end
end
end
end
--cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
cairo_stroke(cr)
end
代码: 全选
function change_clr_alpha(cr,t,pt,num1)
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 n1=pt['max']
if n1<60 then
n1=60 --最小分段数量为60,保证过渡平滑
end
local set_o=pt['change_color']
local stc,edc=pt['startcolor'],pt['endcolor']
local t_color=tonumber(edc-stc)
local d_c=t*t_color+stc
local sta,eda=pt['start_alpha'],pt['end_alpha']
local t_alpha=eda-sta
local d_a=t*t_alpha+sta
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)
cairo_new_path(cr)
--进度条边框部分
if num1==1 or num1==3 then
if angle_0>angle_0+t_arc then
cairo_arc_negative(cr,xc,yc,ring_r+ring_w/2,angle_0,angle_0+t_arc)
cairo_line_to(cr,xc+(ring_r-ring_w/2)*math.cos(angle_0+t_arc),yc+(ring_r-ring_w/2)*math.sin(angle_0+t_arc))
cairo_arc(cr,xc,yc,ring_r-ring_w/2,angle_0+t_arc,angle_0)
cairo_line_to(cr,xc+(ring_r+ring_w/2)*math.cos(angle_0),yc+(ring_r+ring_w/2)*math.sin(angle_0))
cairo_set_source_rgba(cr,1,1,1,0.5) --边框颜色
cairo_set_line_width(cr,1)
cairo_stroke_preserve(cr)
cairo_stroke(cr)
else
cairo_arc(cr,xc,yc,ring_r+ring_w/2,angle_0,angle_0+t_arc)
cairo_line_to(cr,xc+(ring_r-ring_w/2)*math.cos(angle_0+t_arc),yc+(ring_r-ring_w/2)*math.sin(angle_0+t_arc))
cairo_arc_negative(cr,xc,yc,ring_r-ring_w/2,angle_0+t_arc,angle_0)
cairo_line_to(cr,xc+(ring_r+ring_w/2)*math.cos(angle_0),yc+(ring_r+ring_w/2)*math.sin(angle_0))
cairo_set_source_rgba(cr,1,1,1,0.5) --边框颜色
cairo_set_line_width(cr,1)
cairo_stroke_preserve(cr)
cairo_stroke(cr)
end
end
--进度条填充部分
if num1==2 or num1==3 then
cairo_new_path(cr)
local angle_k,d_k=angle_0,stc
local sp_angle= (angle_f-angle_0)/n1 --t_arc/n
local f_angle=t*n1
local r_k,g_k,b_k,a_k=rgb_to_r_g_b(d_k)
local a_k=sta
local r_ke,g_ke,b_ke=rgb_to_r_g_b(edc)
local a_ke=eda
local sp_dr,sp_dg,sp_db,sp_a=(r_ke-r_k)/n1,(g_ke-g_k)/n1,(b_ke-b_k)/n1,(a_ke-a_k)/n1
for i=1,f_angle do
if angle_k<angle_k+sp_angle then
cairo_arc(cr,xc,yc,ring_r,angle_k,angle_k+sp_angle)
else
cairo_arc_negative(cr,xc,yc,ring_r,angle_k,angle_k+sp_angle)
end
cairo_set_source_rgba(cr,r_k,g_k,b_k,a_k)
cairo_set_line_width(cr,ring_w-2)
angle_k=angle_k+sp_angle
r_k=r_k+sp_dr
g_k=g_k+sp_dg
b_k=b_k+sp_db
a_k=a_k+sp_a
cairo_stroke(cr)
cairo_new_path(cr)
end
end
end
修改后的conky配置和lua见附件,可能用到的字体为zekton~~
。。。本人变量名严重无视匈牙利法,,为不易记的酱油法,看过就算啊~~

ps。public ipv4的检测我注释掉了,要的自己加吧,学校网速不成。。。

