分页: 1 / 2

conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-10-26 0:56
Vanishing
有图有真相
最里面3个环是时间(秒针,分针,时针)
第4个:wireless signal
5:battery%
6: memory%
7:cpu%
可以加filesystem.
requirement:conky 1.7.2 with Cairo and lua enabled when compiling,或者源里的conky-all(推荐,全功能,不是半残版本。。)

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-10-26 1:18
wyddr
怎么弄的,给发个配置看看 :em50

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-10-26 1:20
Vanishing
wyddr 写了:怎么弄的,给发个配置看看 :em50

代码: 全选

--[[
Clock Rings by londonali1010 (2009)
modified by Vanishing
]]

settings_table = {
	{
		name='cpu',
		arg='cpu0',
		max=100,
		bg_colour=0xFFFFFF,
		bg_alpha=0,
		fg_colour=0xFFFFFF,
		fg_alpha=0.3,
		x=75, y=75,
		radius=63,
		thickness=13,
		start_angle=0,
		end_angle=360
	},
	{
		name='memperc',
		arg='',
		max=100,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.8,
		x=75, y=75,
		radius=55,
		thickness=3,
		start_angle=0,
		end_angle=360
	},
	{
		name='battery_percent',
		arg="BAT0",
		max=100,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.6,
		x=75, y=75,
		radius=50,
		thickness=3,
		start_angle=0,
		end_angle=360
	},
	{
		name='wireless_link_qual_perc',
		arg='wlan0',
		max=100,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.9,
		x=75, y=75,
		radius=40,
		thickness=13,
		start_angle=0,
		end_angle=360
	},
	{
		name='time',
		arg='%I',
		max=12,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.5,
		x=75, y=75,
		radius=30,
		thickness=3,
		start_angle=0,
    	end_angle=360
	},
	{
		name='time',
		arg='%M',
		max=60,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.6,
		x=75, y=75,
		radius=24,
		thickness=5,
		start_angle=0,
    	end_angle=360
	},
	{
		name='time',
		arg='%S',
		max=60,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.9,
		x=75, y=75,
		radius=10,
		thickness=18,
		start_angle=0,
		end_angle=360
	},
}

-- Use these settings to define the origin and extent of your clock.

clock_r=125

-- "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=195	
clock_y=195

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/60
		
	-- Draw hour hand
	
	xh=xc+0.2*clock_r*math.sin(hours_arc)
	yh=yc-0.2*clock_r*math.cos(hours_arc)
	cairo_move_to(cr,xc,yc)
	cairo_line_to(cr,xh,yh)
	
	cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
	cairo_set_line_width(cr,5)
	cairo_set_source_rgba(cr,1,1,1,0.8)
	cairo_stroke(cr)
	
	-- Draw minute hand
	
	xm=xc+clock_r*math.sin(mins_arc)*0.4
	ym=yc-clock_r*math.cos(mins_arc)*0.4
	cairo_move_to(cr,xc,yc)
	cairo_line_to(cr,xm,ym)
	
	cairo_set_line_width(cr,3)
	cairo_stroke(cr)
	
	-- Draw seconds hand
	
	if show_seconds then
		xs=xc+clock_r*math.sin(secs_arc)*0.5
		ys=yc-clock_r*math.cos(secs_arc)*0.5
		cairo_move_to(cr,xc,yc)
		cairo_line_to(cr,xs,ys)
	
		cairo_set_line_width(cr,1)
		cairo_stroke(cr)
	end
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,75,75)
end
这个是lua文件,可以自己改。
另存为到~/scripts/rings.lua
然后再conky里加载lua:(在TEXT之前)

代码: 全选

# -- Lua Load -- #
lua_load ~/scripts/rings.lua
lua_draw_hook_pre clock_rings

TEXT
 

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-10-26 1:37
princelai
这个时钟不错mark

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-11-13 22:32
edifierxyz
sdgsadgfdhgsdhgsdf

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-11-13 23:18
jxhow
这个时钟不错mark :em11 很赞

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-11-13 23:22
t3swing
这个看得就有蛮费劲哈

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-11-14 10:33
东方不坏
不但眼睛要好才看得清,而且显示器差了也不行。

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2009-12-10 6:36
COPING
收藏了

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2010-01-18 2:08
炎岩风火
Conky: llua_do_call: function conky_clock_rings execution failed: attempt to call a nil value
想必LZ在调试时也遇到过吧,我从Conky Hardcore!上也看到这个环的做法了,那篇文章的作者也在脚本前面的注释里说了这个错误的原因,但我看得不怎么明白。
还有,我是1024X768的屏幕,单核CPU,就想做一个跟你差不多的,只带有时、分、CPU使用、内存使用的环,放在右下角,怎么调试?谢谢

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2010-01-18 9:39
eexpress
cairo的,就适合作环。
可conky里面带这个,是折腾。带lua就是折腾。
放桌面的时钟,那么多漂亮的,都不用。
那点阵的,换一个字体,就可以文本实现的。

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2010-01-18 10:02
黄美姬
这么多环,被放环多次 :em04 :em04 :em04

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2010-01-18 10:16
tenzu
神太打击LZ了

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2010-01-18 22:47
Vanishing
tenzu 写了:神太打击LZ了
不是让你躲着点么?又在这j什么?

Re: conky 时钟,cpu,wireless, battery, memory合体。。哇哈哈

发表于 : 2010-01-19 0:15
karllv
lz把完整的配置贴出来吧