SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1151 2015-05-29 13:00:30

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: interactive conky

^ It is complicated to do it.
I have done it before but that was adding buttons to scripts I wrote myself so I knew what I was modifying.

You could also try running the rings with "lua_draw_hook_post" which will draw them after the things run in the "TEXT" section instead of before like "lua_draw_hook_pre" does.
Drawing it this way will put it on top of everything else it overlaps though.

Offline

Be excellent to each other!

#1152 2015-05-29 13:13:40

dancaer69
New Member
Registered: 2015-05-29
Posts: 9

Re: interactive conky

In "lua_draw_hook_post" I run the text.lua file which draws the text, so then I have the rings but no text. Here is the rings.lua script:

v1.0 (08 Aug. 2010) original release

]]


require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={

	{
	--Ring 1 :seconds
	name="time",
	arg="%S",
	max=60,
	xc=108,
	yc=145,
	radius=71,
	thickness=12,
	sectors=59,
	gap_sectors=2,
	fill_sector=true,
	bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
	fg_colour1={{0,0XE3C22D,0},{0.5,0xE3C22D,1}, {1,0xE89827,0}},
	bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
	},

	{
	--left half ring 2 : cpu1
	name="cpu",
	arg="cpu0",
	max=100,
	xc=108,
	yc=304,
	radius=70,
	thickness=12,
	start_angle=360,
	end_angle=180,
	inverse_arc=false,
	sectors=30,
	fill_sector=true,
	bg_colour2={{0,0X111111,1},{0.5,0x111111,1}, {1,0x999999,1}},
	bg_colour1={{0,0X999999,1},{0.5,0x999999,1}, {1,0x111111,1}},
	fg_colour1={{0,0xFFC125,1},{0.5,0xFFC125,1}, {1,0xFFFFFF,1}},
	fg_colour2={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFC125,1}},
	bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
	},
	
	{
	--right half ring 2 : cpu0
	name="cpu",
	arg="cpu1",
	max=100,
	xc=108,
	yc=304,
	radius=70,
	thickness=12,
	end_angle=180,
	inverse_arc=true,
	sectors=30,
	fill_sector=true,
	bg_colour1={{0,0X111111,1},{0.5,0x111111,1}, {1,0x999999,1}},
	bg_colour2={{0,0X999999,1},{0.5,0x999999,1}, {1,0x111111,1}},
	fg_colour1={{0,0XFF4500,1},{0.5,0xFF4500,1}, {1,0xFFFFFF,1}},
	fg_colour2={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFF4500,1}},
	bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
	},
	{
	--ring 3 : memory
	name="memperc",
	arg="",
	max=100,
	xc=108,
	yc=462,
	radius=70,
	thickness=12,
	start_angle=-120,
	end_angle=120,
	sectors=20,
	bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
	fg_colour1={{0,0XFFFF00,0},{0.5,0xFFFF00,1}, {1,0xFFFF00,0}},
	fg_colour2={{0,0XFF0000,0},{0.5,0xFF0000,1}, {1,0xFF0000,0}},
	bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
	},		

	{
	--right half ring 5 : download speed
	name="downspeedf",
	arg="eth0",
	max=3000,
	xc=108,
	yc=623,
	radius=70,
	thickness=12,
	end_angle=180,
	sectors=30,
	fill_sector=true,
	bg_colour1={{0,0X111111,1},{0.5,0x111111,1}, {1,0x999999,1}},
	bg_colour2={{0,0X999999,1},{0.5,0x999999,1}, {1,0x111111,1}},
	fg_colour1={{0,0XFF4500,1},{0.5,0xFF4500,1}, {1,0xFFFFFF,1}},
	fg_colour2={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFF4500,1}},
	bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
	},
	
	
	{
	--left half ring 5 : upload speed
	name="upspeedf",
	arg="eth0",
	max=200,
	xc=108,
	yc=623,
	radius=70,
	thickness=12,
	start_angle=360,
	end_angle=180,
	inverse_arc=true,
	sectors=30,
	fill_sector=true,
	bg_colour2={{0,0X111111,1},{0.5,0x111111,1}, {1,0x999999,1}},
	bg_colour1={{0,0X999999,1},{0.5,0x999999,1}, {1,0x111111,1}},
	fg_colour1={{0,0xFFC125,1},{0.5,0xFFC125,1}, {1,0xFFFFFF,1}},
	fg_colour2={{0,0XFFFFFF,1},{0.5,0xFFFFFF,1}, {1,0xFFC125,1}},
	bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
	},
		
	{
	--ring 6 : volume
	name="execi 3 ~/.conky/Metropolis_eth0/vol.sh",
	arg="",
	max=100,
	xc=108,
	yc=779,
	radius=70,
	thickness=12,
	start_angle=-180,
	end_angle=180,
	sectors=20,
	fill_sector=true,
	bg_colour1={{0,0x999999,0},{0.5,0x999999,1}, {1,0x999999,0}},
	fg_colour1={{0,0XFFFF00,0},{0.5,0xFFFF00,1}, {1,0xFFFF00,0}},
	fg_colour2={{0,0XFF0000,0},{0.5,0xFF0000,1}, {1,0xFF0000,0}},
	bd_colour1={{0,0X00FF00,1},{0.5,0x00FF00,1}, {1,0x00FF00,1}},
	},
	
	
			
}
--END OF PARAMETERS HERE

--main function

	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)

	if tonumber(conky_parse('${updates}'))>3 then
		for i in pairs(rings_settings) do
			draw_ring(rings_settings[i])
		end
	end

	cairo_destroy(cr)

end




function draw_ring(t)

	local function rgba_to_r_g_b_a(tcolour)
		colour,alpha=tcolour[2],tcolour[3]
		return ((colour / 0x10000) % 0x100) / 255., 
			((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
	end
			
			
	local function calc_delta(tcol1,tcol2)
		--calculate deltas P R G B A to table_colour 1

		for x = 1, #tcol1 do
			tcol1[x].dA	= 0
			tcol1[x].dP = 0
	 		tcol1[x].dR = 0
			tcol1[x].dG = 0
			tcol1[x].dB = 0
			if tcol2~=nil and #tcol1 == #tcol2 then
				local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
				local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
				tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
		 		tcol1[x].dR = (r2-r1)/t.sectors
				tcol1[x].dG = (g2-g1)/t.sectors
				tcol1[x].dB = (b2-b1)/t.sectors
				tcol1[x].dA = (a2-a1)/t.sectors		
				
			end
		end
		
		return tcol1
	end

	--check values
	local function setup(t)
		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'")
			print ("for name=" .. t.name)
			print ("with arg=" .. t.arg)
			return
		end
		if t.name==nil then t.name="" end
		if t.arg==nil then t.arg="" end

		if t.xc==nil then t.xc=conky_window.width/2 end
		if t.yc==nil then t.yc=conky_window.height/2 end
		if t.thickness ==nil then t.thickness = 10 end
		if t.radius ==nil then t.radius =conky_window.width/4 end
		if t.start_angle==nil then t.start_angle =0 end
		if t.end_angle==nil then t.end_angle=360 end
		if t.bg_colour1==nil then 
			t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
		end
		if t.fg_colour1==nil then
			t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
		end
		if t.bd_colour1==nil then
			t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
		end
		if t.sectors==nil then t.sectors=10 end
		if t.gap_sectors==nil then t.gap_sectors=1 end 
		if t.fill_sector==nil then t.fill_sector=false end
		if t.sectors==1 then t.fill_sector=false end
		if t.border_size==nil then t.border_size=0 end
		if t.cap==nil then t.cap="p" end
		--some checks
		if t.thickness>t.radius then t.thickness=t.radius*0.1 end
		t.int_radius = t.radius-t.thickness

		--check colors tables 
		for i=1, #t.bg_colour1 do 
			if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
		end
		for i=1, #t.fg_colour1 do 
			if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
		end
		for i=1, #t.bd_colour1 do 
			if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
		end
	
		if t.bg_colour2~=nil then
			for i=1, #t.bg_colour2 do 
				if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
			end
		end
		if t.fg_colour2~=nil then
			for i=1, #t.fg_colour2 do 
				if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
			end
		end
		if t.bd_colour2~=nil then
			for i=1, #t.bd_colour2 do 
				if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
			end
		end 	
		
		if t.start_angle>=t.end_angle then
		 local tmp_angle=t.end_angle
		 t.end_angle= t.start_angle
		 t.start_angle = tmp_angle
		 -- print ("inversed angles")
			if t.end_angle-t.start_angle>360 and t.start_angle>0 then
				t.end_angle=360+t.start_angle
				print ("reduce angles")
			end
		
			if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
				t.end_angle=360+t.start_angle
				print ("reduce angles")
			end
		
			if t.int_radius<0 then t.int_radius =0 end
			if t.int_radius>t.radius then
				local tmp_radius=t.radius
				t.radius=t.int_radius
				t.int_radius=tmp_radius
				print ("inversed radius")
			end
			if t.int_radius==t.radius then
				t.int_radius=0
				print ("int radius set to 0")
			end 
		end
		
		t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
		t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
		t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
	end
	
	--initialize table
	setup(t)
	--[[grid
	h=conky_window.height
	w=conky_window.width
	cairo_set_source_rgba(cr,1,1,1,1)
	cairo_set_line_width(cr,0.5)
	cairo_move_to(cr,0,t.yc)
	cairo_line_to(cr,w,t.yc)
	cairo_stroke(cr)
	cairo_move_to(cr,t.xc,0)
	cairo_line_to(cr,t.xc,h)
	cairo_stroke(cr)
	cairo_move_to(cr,t.xc,t.yc)
	cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
	cairo_stroke(cr)
	cairo_move_to(cr,0,t.yc-t.radius)
	cairo_line_to(cr,w,t.yc-t.radius)
	cairo_stroke(cr)
	cairo_move_to(cr,0,t.yc-t.int_radius)
	cairo_line_to(cr,w,t.yc-t.int_radius)
	cairo_stroke(cr)
	cairo_move_to(cr,0,t.yc-t.gap_sectors)
	cairo_line_to(cr,w,t.yc-t.gap_sectors)
	cairo_stroke(cr)
	cairo_set_source_rgba(cr,1,0,0,0.5)
	cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
	cairo_stroke(cr)
	cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)	
	cairo_stroke(cr)	
	cairo_set_source_rgba(cr,0,1,0,1)	
	cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
	cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
	cairo_stroke(cr)
	--END GRID
	]]
	
	--initialize cairo context
	cairo_save(cr)
	cairo_translate(cr,t.xc,t.yc)
	cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
	cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)

	--get value
	local value = 0
	if t.name ~="" then
		value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
	else
		value = tonumber(t.arg)
	end
	if value==nil then value =0 end

	--initialize sectors
	--angle of a sector :
	angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
	--value of a sector : 
	valueA = t.max/t.sectors
	--first angle of a sector : 
	lastAngle = t.start_angle*math.pi/180


	local function draw_sector(type_arc,angle0,angle,valpc, idx)
	 
		--this function draws a portion of arc
	 	--type of arc, angle0 = strating angle, angle= angle of sector,
	 	--valpc = percentage inside the sector, idx = sctor number #
		 if type_arc=="bg" then 		--background
			 if valpc==1 then return end
		 	tcolor=t.bg_colour1
		 elseif type_arc=="fg" then	--foreground
		 	if valpc==0 then return end
		 	tcolor=t.fg_colour1
		 elseif type_arc=="bd" then	--border
		 	tcolor=t.bd_colour1
		 end 

		--angles equivalents to gap_sector
		local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
		local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))

		--angles of arcs
		local ext_angle=(angle-ext_delta*2)*valpc
		local int_angle=(angle-int_delta*2)*valpc

		--define colours to use for this sector
		if #tcolor==1 then 
			--plain color
			local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
			cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
									vG+tcolor[1].dG*idx,
									vB+tcolor[1].dB*idx,
									vA+tcolor[1].dA*idx	)
		else
			--radient color
			local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
			for i=1, #tcolor do
				local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
				cairo_pattern_add_color_stop_rgba (pat, 
									vP+tcolor[i].dP*idx,
									vR+tcolor[i].dR*idx,
									vG+tcolor[i].dG*idx,
									vB+tcolor[i].dB*idx,
									vA+tcolor[i].dA*idx	)
			end
			cairo_set_source (cr, pat)
			cairo_pattern_destroy(pat)
		end

		--start drawing
		 cairo_save(cr)
		--x axis is parrallel to start of sector
		cairo_rotate(cr,angle0-math.pi/2)

		local ri,re = t.int_radius ,t.radius

		--point A 
		local angle_a
	
		if t.cap == "p" then 
			angle_a = int_delta
			if t.inverse_arc and type_arc ~="bg" then
				angle_a = angle-int_angle-int_delta
			end
			if not(t.inverse_arc) and type_arc =="bg" then
				angle_a = int_delta+int_angle
			end
		else --t.cap=="r"
			angle_a = ext_delta
			if t.inverse_arc and type_arc~="bg" then
				angle_a = angle-ext_angle-ext_delta
			end
			if not(t.inverse_arc) and type_arc=="bg" then
				angle_a = ext_delta+ext_angle
			end
		end
		local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)


		--point B
		local angle_b = ext_delta
		if t.cap == "p" then 
			if t.inverse_arc and type_arc ~="bg" then
				angle_b = angle-ext_angle-ext_delta
			end
			if not(t.inverse_arc) and type_arc=="bg" then
				angle_b = ext_delta+ext_angle
			end
		else
			if t.inverse_arc and type_arc ~="bg" then
				angle_b = angle-ext_angle-ext_delta
			end
			if not(t.inverse_arc) and type_arc=="bg" then
				angle_b = ext_delta+ext_angle
			end
		end
		local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)

		-- EXTERNAL ARC B --> C
		if t.inverse_arc then
			if type_arc=="bg" then
				b0,b1= ext_delta, angle-ext_delta-ext_angle
			else
				b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
			end
		else
			if type_arc=="bg" then
				b0,b1= ext_delta+ext_angle, angle-ext_delta
			else
				b0,b1= ext_delta, ext_angle+ext_delta
			end
		end
		
		---POINT D
		local angle_c 
		if t.cap == "p" then 
			angle_d = angle-int_delta
			if t.inverse_arc and type_arc=="bg" then
				angle_d = angle-int_delta-int_angle	
			end
			if not(t.inverse_arc) and type_arc~="bg" then
				angle_d=int_delta+int_angle
			end
		else
			angle_d = angle-ext_delta
			if t.inverse_arc and type_arc=="bg" then
				angle_d =angle-ext_delta-ext_angle
			end
			if not(t.inverse_arc) and type_arc~="bg" then
				angle_d = ext_angle+ext_delta
			end
		end
		local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
		
		-- INTERNAL ARC D --> A
		if t.cap=="p" then	
			if t.inverse_arc then	
				if type_arc=="bg" then
					d0,d1= angle-int_delta-int_angle,int_delta
				else
					d0,d1= angle-int_delta, angle- int_angle-int_delta
				end
			else
				if type_arc=="bg" then
					d0,d1= angle-int_delta, int_delta+int_angle
				else
					d0,d1= int_delta+int_angle, int_delta
				end
			end
		else
			if t.inverse_arc then	
				if type_arc=="bg" then	
					d0,d1= angle-ext_delta-ext_angle,ext_delta
				else
					d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
				end
			else
				if type_arc=="bg" then	
					d0,d1= angle-ext_delta,ext_delta+ext_angle
				else	
					d0,d1= ext_angle+ext_delta, ext_delta
				end
			end			
		end
			
		--draw sector
		cairo_move_to(cr,ax,ay)
		cairo_line_to(cr,bx,by)
		cairo_arc(cr,0,0,re,b0,b1)
		cairo_line_to(cr,dx,dy) 
		cairo_arc_negative(cr,0,0,ri,d0,d1)
		 cairo_close_path (cr);

		--stroke or fill sector
		 if type_arc=="bd" then
		 	cairo_set_line_width(cr,t.border_size)
		 	cairo_stroke(cr)
		 else
			 cairo_fill(cr)
		 end

		 cairo_restore(cr)

	 end
	--draw sectors
	local n0,n1,n2 = 1,t.sectors,1
	if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
	local index = 0
	for i = n0,n1,n2 do 
		index = index +1
		local valueZ=1
		local cstA, cstB = (i-1),i
		if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
		
		if value>valueA *cstA and value<valueA*cstB then
			if not t.fill_sector then
				valueZ = (value-valueA*cstA)/valueA
			end
		else
			if value<valueA*cstB then valueZ=0 end
		end
		
		local start_angle= lastAngle+(i-1)*angleA
		if t.foreground ~= false then 
			draw_sector("fg",start_angle,angleA,valueZ, index)
		end
		if t.background ~= false then 
			draw_sector("bg",start_angle,angleA,valueZ, i)
		end
		if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
	end

	cairo_restore(cr)
end


--[[END OF RING-SECTORS WIDGET]]


function axis(ctx,alpha)
	cairo_set_line_width(ctx,1)
	cairo_set_source_rgba(ctx,1,0,0,alpha)
	cairo_move_to(ctx,0,0)
	cairo_line_to(ctx,150,0)
	cairo_stroke(ctx)
	cairo_set_source_rgba(ctx,0,1,0,alpha)
	cairo_move_to(ctx,0,0)
	cairo_line_to(ctx,0,150)
	cairo_stroke(ctx)
end

the button_script is same from post 322 with these functions for buttons:

--setup buttons here
function button_settings()
button1=do_button({btype=3,bname="conkybutton1",blx_off=75,bly_off=740,bw_off=50,bh_off=30,draw=0,text=1,fcol_off={"0xE89827"},txt_off={"ΑΥΞ+"}})
if(button1==1) then
os.execute("~/tmp/volplus.sh")
print ("vol up")
end
button2=do_button({btype=3,bname="conkybutton2",blx_off=115,bly_off=740,bw_off=50,bh_off=30,draw=0,text=1,fcol_off={"0xE89827"},txt_off={"ΜΕΙ-"}})
if(button2==1) then
os.execute("~/tmp/volminus.sh")
print ("vol down")
end

end--function button_settings

and here is the conkyrc file:

background no
use_xft yes
xftfont Roboto:size=9
xftalpha 0.8
update_interval 1
total_run_times 0

##############################################
# Compositing tips:
# Conky can play strangely when used with
# different compositors. I have found the
# following to work well, but your mileage
# may vary. Comment/uncomment to suit.
##############################################
own_window yes
own_window_transparent yes

## no compositor
#own_window_type override
#own_window_argb_visual no

## xcompmgr
#own_window_type override
#own_window_argb_visual yes

## cairo-compmgr
own_window_type dock
own_window_argb_visual no
#own_window_class conky-semi

own_window_argb_value 0
own_window_colour 000000
##############################################
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_title Metropolis_4
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
stippled_borders 0
border_margin 5
border_width 1
default_color 000000
default_shade_color 000000
default_outline_color 000000
alignment top_right
minimum_size 200 900
maximum_width 600
gap_x 1100
gap_y 100
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 2
short_units yes
text_buffer_size 2048
use_spacer none
override_utf8_locale yes
color1 white
color2 121111
color3 E82A2A

# -- Lua load -- #
lua_load ~/.conky/Metropolis_eth0/rings.lua
lua_load ~/.conky/Metropolis_eth0/text.lua
#lua_draw_hook_pre main_rings
lua_draw_hook_post draw_text

## Set the path to button_script.lua here ##
############################################
lua_load ~/.conky/Metropolis_eth0/button_script.lua
##################################
## activate mouse click logging ##
##################################
lua_draw_hook_pre get_mouse {"Metropolis_4","/tmp/xdo"} 
## after function call, table containing window title and path to click log file
## before running script create a blank log file first.  In the example above "/tmp/xdo" create a blank file called xdo in your /tmp directory 
###################################################
## restart click logging on conkyrc save/startup ##
###################################################
lua_startup_hook start_xdo /tmp/xdo
## send click file location following function call if not set up in lua script
###################################################
## kill xdotool process on conkyrc save/shutdown ##
###################################################
lua_shutdown_hook stop_xdo
#######################################################
## Set the path to lua_functions.lua here (optional) ##
#######################################################
lua_load ~/.conky/Metropolis_eth0/lua_functions.lua





##############################################
#  Output
##############################################

TEXT

${image ~/.conky/Metropolis_eth0/bg.png -p 6,40 -s 195x195}
${image ~/.conky/Metropolis_eth0/bg.png -p 6,200 -s 195x195}
${image ~/.conky/Metropolis_eth0/bg.png -p 6,360 -s 195x195}
${image ~/.conky/Metropolis_eth0/bg.png -p 6,520 -s 195x195}
${image ~/.conky/Metropolis_eth0/bg.png -p 6,680 -s 195x195}
${image ~/.conky/Metropolis_eth0/gloss.png -p 0,38 -s 206x206}
${image ~/.conky/Metropolis_eth0/gloss.png -p 0,196 -s 206x206}
${image ~/.conky/Metropolis_eth0/gloss.png -p 0,355 -s 206x206}
${image ~/.conky/Metropolis_eth0/gloss.png -p 0,515 -s 206x206}
${image ~/.conky/Metropolis_eth0/gloss.png -p 0,673 -s 206x206}

Last edited by dancaer69 (2015-05-29 13:15:53)

Offline

#1153 2015-05-29 14:14:14

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: interactive conky

^ You have three separate Lua scripts now, not just the buttons and rings you mentioned originally?
In that case you will have to write some Lua yourself to combine two of them so they can both run off one of the "lua_draw_hook_*" options.
I don't have enough free time to do that for you since it is complicated and would require me taking the time to become familiar with all the Lua scripts you are using.

Offline

#1154 2015-05-29 14:49:32

dancaer69
New Member
Registered: 2015-05-29
Posts: 9

Re: interactive conky

Thanks for trying to help.
I've managed to load it though, modifying button_script "get_mouse" function like this:

function conky_get_mouse(rc_info)--###############################################################################################################
package.path = "~/.conky/Metropolis_eth0/?.lua"
dofile "/home/username/.conky/Metropolis_eth0/rings.lua"
conky_main_rings()
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)
--##########################################################################
if rc_info~=nil then
rc_info=loadstring("return" .. rc_info)()

end

I had some problems defing home directory with ~/, but it works when I wrote the full path.
Now the only problem is that the ring doesn't load only for the object in which the buttons are.

Last edited by dancaer69 (2015-05-29 14:54:47)

Offline

#1155 2015-05-29 15:24:56

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: interactive conky

Offline

#1156 2015-05-29 15:40:59

dancaer69
New Member
Registered: 2015-05-29
Posts: 9

Re: interactive conky

I have 5 objects(time, cpu, memory, network, volume). Every object has a rounded background, a  grey ring in front of it and an animated colored ring in front.  In the object of volume I have only the grey ring layer, not the animated which displayed fine in all others.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: bleh

Debian Logo