无他,据蛋蛋改的conky及lua(部分修改)

桌面秀,不同桌面、不同风格。
putputput
帖子: 25
注册时间: 2008-05-01 15:50

无他,据蛋蛋改的conky及lua(部分修改)

#1

帖子 putputput »

20110511重新改的,因为发现我后面改的东西都没上传上来。。。
系统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
2. 给圈圈加了个外框,貌似好看点了~~

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
    }
4. function draw_ring(cr,t,pt) 函数修改如下:

代码: 全选

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
5. 添加新函数(实现渐变及边框绘制)

代码: 全选

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
6. 加了小玩意,绘制时辰显示效果,图中左下角附近

修改后的conky配置和lua见附件,可能用到的字体为zekton~~
。。。本人变量名严重无视匈牙利法,,为不易记的酱油法,看过就算啊~~ :em06
ps。public ipv4的检测我注释掉了,要的自己加吧,学校网速不成。。。 :em20 :em20
附件
myconky.tar.gz
(6.74 KiB) 已下载 203 次
效果演示
效果演示
上次由 putputput 在 2011-05-11 11:43,总共编辑 2 次。
头像
wowoto
帖子: 3050
注册时间: 2009-04-11 12:17
系统: windows7

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#2

帖子 wowoto »

奢华 :em01
wowoto>ubuntu8.04>ubuntu9.04>Archlinux>FreeBSD8.0>Archlinux & end here.
v4xyz
帖子: 11
注册时间: 2009-04-28 21:22

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#4

帖子 v4xyz »

这个好喜欢
头像
nerver
帖子: 2061
注册时间: 2009-11-19 19:35

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#5

帖子 nerver »

好多蛋 :em04
——nerver is not never
头像
Dim
帖子: 640
注册时间: 2009-04-06 15:03

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#6

帖子 Dim »

这个一定收藏
,
autocup
帖子: 408
注册时间: 2010-01-23 20:36

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#7

帖子 autocup »

Dim 写了:这个一定收藏
ubuntu
oudiyaya
帖子: 81
注册时间: 2011-01-09 12:06
来自: 福州

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#8

帖子 oudiyaya »

DIY的不错哦 :em11
lubcat
帖子: 2061
注册时间: 2010-09-27 12:59

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#9

帖子 lubcat »

圈不在多。一正一反。一阴一阳。天地万物。皆涵盖于内。
生活里,有很多转瞬即逝,像在车站的告别,刚刚还相互拥抱,转眼已各自天涯。很多时候,你不懂,我也不懂,就这样,说着说着就变了,听着听着就倦了,看着看着就厌了,跟着跟着就慢了,走着走着就散了,爱着爱着就淡了,想着想着就算了。
redlhl
帖子: 334
注册时间: 2008-06-27 20:47

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#10

帖子 redlhl »

我本不想conky的。。。
redlhl
帖子: 334
注册时间: 2008-06-27 20:47

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#11

帖子 redlhl »

楼主看看这个错误是什么原因阿
Conky: llua_do_call: function conky_clock_rings execution failed: /home/red/.lua/scripts/clock_rings.lua:297: attempt to perform arithmetic on local 'colour' (a nil value)
看了下效果,那个时钟指针没了
附件
抓图13.png
上次由 redlhl 在 2011-02-27 10:35,总共编辑 1 次。
头像
momova
帖子: 3381
注册时间: 2007-07-11 21:43
系统: archlinux
来自: 东江边

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#12

帖子 momova »

截取选区_079.jpeg
看看我这个
截取选区_080.jpeg
我来了,我看见了,我征服了!
求勾搭,不管饭。
hu31346017
帖子: 5
注册时间: 2011-02-17 4:36

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#13

帖子 hu31346017 »

都不错哈~
头像
momova
帖子: 3381
注册时间: 2007-07-11 21:43
系统: archlinux
来自: 东江边

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#14

帖子 momova »

你看到的是gnome-look上下载的,直接使用,home下本来是天气预报,不过没有我所在地区的天气,我就雄起了
我来了,我看见了,我征服了!
求勾搭,不管饭。
putputput
帖子: 25
注册时间: 2008-05-01 15:50

Re: 无他,据蛋蛋改的conky及lua(部分修改)

#15

帖子 putputput »

20110511更新~~ :em06 :em06
回复