SEARCH

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

You are not logged in.

#7251 2014-03-27 10:50:51

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

lua_load $HOME/.Conky/cronograph/scripts/clock_rings.lua
lua_draw_hook_pre clock_rings
lua_load $HOME/.Conky/cronograph/scripts/multi_rings.lua
lua_draw_hook_post main

TEXT
${execi 500 bash $HOME/.Conky/cronograph/accuweather/accuw_script}

Offline

Be excellent to each other!

#7252 2014-03-27 11:40:15

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: Conky v1.9 Thread

}--closes table
local interval=10--conky updates before switching
--set positions

Last edited by Joe90 (2014-03-27 11:41:19)

Offline

#7253 2014-03-27 13:05:08

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Last edited by Sector11 (2014-03-27 13:06:43)

Offline

#7254 2014-03-27 14:09:02

ragamatrix
#! Junkie
From: Earth
Registered: 2012-12-05
Posts: 286

Re: Conky v1.9 Thread

Offline

#7255 2014-03-27 14:59:05

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: Conky v1.9 Thread

Last edited by Joe90 (2014-03-27 17:33:48)

Offline

#7256 2014-03-27 15:02:11

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Offline

#7257 2014-03-27 15:42:42

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Offline

#7258 2014-03-27 16:53:54

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: Conky v1.9 Thread

Last edited by Joe90 (2014-03-27 16:57:57)

Offline

#7259 2014-03-27 17:58:28

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

Offline

#7260 2014-03-27 18:28:47

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: Conky v1.9 Thread

@dk75

Thanks for the suggestions, if I get off my arse and learn lua scripting this could work for me, and with everything working OK as it is, it would be a labour of love smile  I have things tied down to a cpu spike @ once a minute, this is conky and lua doing their thing, which they have to do anyway for everything to work wink

For me it is about feeding the lua script with the bash randomising solutions. can it not be done inside the lua script ?

Last edited by Joe90 (2014-03-27 18:30:57)

Offline

#7261 2014-03-27 18:35:25

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

#!/bin/bash
cd ~/images/0-9
r9=$((RANDOM%9))
cp ~/images/0-9/$r9.png ~/images/0-9/current.png
exit 0

Offline

#7262 2014-03-27 18:37:16

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Offline

#7263 2014-03-27 19:42:50

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

Offline

#7264 2014-03-27 19:47:06

ragamatrix
#! Junkie
From: Earth
Registered: 2012-12-05
Posts: 286

Re: Conky v1.9 Thread

Offline

#7265 2014-03-27 20:24:25

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

#!/bin/bash
cd ~/images/0-9
r4=$((RANDOM%4))
cp ~/images/0-9/text.$r4.txt ~/images/0-9/current.txt
exit 0

Offline

#7266 2014-03-27 20:41:15

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Offline

#7267 2014-03-28 03:34:34

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

you would think that conky and lua should be playing nice after all this time together but no!

in conkyrc

### Minimum size of window: width height
minimum_size 600 300

### Maximum width of window 
maximum_width 600

### Gap between text and screen borders.
gap_x 0 ##Gap, in pixels, between right or left border of screen
gap_y 0 ##Gap, in pixels, between top or bottom border of screen

so im expecting the conky window to be 600 pixels wide and 300 pixels high, just like the settings BUT

in lua

print (conky_window.width, conky_window.height)

the output is

610   310

where could that additional 10 be coming from??

Offline

#7268 2014-03-28 10:50:57

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

It's from Conky borders, which are always on, and we have no means to disable them.

Try this:

 --[[
 test75.lua snippet
 testing LUA/Conky window geometry
 --]]
 
 do
 	--print("test")
 
 	function conky_main()
 		local updates = tonumber(conky_parse('${updates}'))
 		if updates <= 5 then return end
 		if conky_window == nil then return end
 		print("Width:", conky_window.width, "Text width:", conky_window.text_width, "Height:", conky_window.height, "Text height:", conky_window.text_height)
 	end
 end

Offline

#7269 2014-03-28 11:30:08

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

Ok.
I've done some testing.

You can't set window border lower than "1" - if set to "0" it will be still "1"
If not set, border inner margin is set to "3" and border outer margin is set to "1"

To conclude, you have additional 5px border around text area, which adds 10px to Conky window geometry.
It's Conky thing, not LUA.

The problem is, you can make LUA surface to be an dimension of conky_text area only, but it starts at point 0x0 of Conky window, thus starts at border area and I know no means to change that. One would need to modify "conky_window.drawable" structure I think.

So, this is my test bed, modify "cairo_init" second line

local width, height = conky_window.text_width, conky_window.text_height

in order to either to use "conky_window.height/width" or "conky_window.text_height/width" for Cairo surface, and change Conky inner margins and border in order to see differences:

# ~/.conkyrc-test75

#-----Conky settings
background no
no_buffers yes
#	out_to_console yes
top_cpu_separate no
#	cpu_avg_samples 10
#	net_avg_samples 10
#	max_port_monitor_connections 10
update_interval 1
total_run_times 0

#-----Text setings
use_xft yes
xftfont DejaVu Sans Mono:bold:size=12
xftalpha 0.8
#	uppercase no
#	override_utf8_locale yes
format_human_readable yes
#	short_units
#	max_user_text 64
#	text_buffer_size 1024

#-----Window settings
own_window yes
own_window_type normal
own_window_argb_visual yes
own_window_argb_value 255
own_window_transparent no
own_window_colour pink
own_window_hints undecorated,below,skip_taskbar,skip_pager,sticky
own_window_class Conky
own_window_title Conky

#----Layout settings
minimum_size 600 300
maximum_width 600
alignment top_left
use_spacer right
gap_x 20
gap_y 50

#-----Graphics settings
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
stippled_borders 0
#	border_inner_margin 0
#	border_outer_margin 0
border_width 0
double_buffer yes
#	max_specials 64
#	imlib_cache_size 0

#-----Color settings
default_color white
default_shade_color black
default_outline_color black
color0 ff0000
color1 00ff88
color2 000000
color3 ffff00
color4 0022ff
color6 0022ff
color7 aa8800

#-----LUA
lua_load $HOME/.conky/lua/test75.lua
lua_draw_hook_pre conky_main


TEXT
it's a test of Conky window
${lua bg {color=0x00000, alpha=0.5, radius=0}}
 --[[
 test75.lua snippet
 testing LUA/Conky window geometry
 
 LUA Background script
 
 usage:
 #####################################################################################################
 lua_load $HOME/.conky/lua/bg.lua
 
 TEXT
 ${lua conky_bg {offsetX=20, offsetY=5, width=200, height=100, radius=5, color=0xff00ff, alpha=0.7} }
 #####################################################################################################
 
 offsetX	- how many pixels from left border to start to draw (if not set, default to "0")
 offsetY	- how many pixels from top border to start to draw (if not set, default to "0")
 width		- background width (if not set, default to Conky width)
 height		- background height (if not set, default to Conky height)
 radius		- radius of corner rounding in percent (if not set, default to 7.5%, 100% means half width/height)
 color		- color of background in hex code (if not set, default to black - 0x000000)
 alpha		- transparency, from 0.0 (fully transparent) to 1.0 (fully opaque) (if not set,, default to 0.5)
 
 You could arrange arguments in any order, it not matters. If some arguments is not set, then default walues will be used, eg:
 ${lua conky_bg}					- black, whole Conky window, 7.5px rounding, 0.5 transparent;
 $(lua conky_bg {color=0xff0000, alpha=0.7, radius=0} }	- red, whole Conky window, square corners, 0.7 transparent;
 --]]

 do
 	require 'cairo'
 	local cr, cs, cwidth, cheight = nil
 	
 	function cairo_init()
 		if conky_window == nil then return end
		--local width, height = conky_window.width, conky_window.height
		local width, height = conky_window.text_width, conky_window.text_height
 		if cs == nil or cairo_xlib_surface_get_width(cs) ~= width or cairo_xlib_surface_get_height(cs) ~= height then
 			if cs then cairo_surface_destroy(cs) end
 			cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, width, height)
 		end
 		if cr then cairo_destroy(cr) end
 		cr = cairo_create(cs)
		return cr, cs, width, height
 	end
 	
 	function cairo_clean()
 		if cr then cairo_destroy(cr) end
 		if cs then cairo_surface_destroy(cs) end
 		cr, cs = nil
 	end
 	
 	function rgb2rgba(colour,alpha) -- colour = hex color code, alpha = float [0.0 - 1.0] transparency factor
 		return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
 		-- returns color used by "cairo_set_rgba()" function
 		end
 
 	function draw_box(cr, x, y, width, height, radius, color, alpha, nofill, lwidth)
 		local length, lradius = nil, {tl=nil, tr=nil, br=nil, bl=nil,}
 		if width < height then length = width else length = height end
 		for i in pairs(radius) do lradius[i] = math.floor(length * radius[i] / 200) end
 		cairo_save(cr)
 		--
 		cairo_arc(cr, x+lradius.tl, y+lradius.tl, lradius.tl, 3.1415926535898, 4.7123889803847)
 		cairo_arc(cr, x+width-lradius.tr, y+lradius.tr, lradius.tr, 4.7123889803847, 0)
 		cairo_arc(cr, x+width-lradius.br, y+height-lradius.br, lradius.br, 0, 1.5707963267949)
 		cairo_arc(cr, x+lradius.bl, y+height-lradius.bl, lradius.bl, 1.5707963267949, 3.1415926535898)
 		--]]
 		cairo_close_path(cr)
 		cairo_set_source_rgba(cr, rgb2rgba(color, alpha))
 		if nofill then
 			if lwidth == nil then lwidth = math.sqrt(math.pow(width, 2) + math.pow(height, 2)) / 40 end
 			cairo_set_line_width (cr, lwidth); cairo_stroke(cr)
 		else cairo_fill(cr)
 		end
 		cairo_restore(cr)
 	end
 
 	function conky_bg(t)
 		if tonumber(conky_parse("${updates}")) < 5 then return "" end
 	
 		local cr, cs, cwidth, cheight = cairo_init(cr, cs)
 		if t and t[1]==nil then t=loadstring("return" .. t)()
 		else if not t then t={} end end
 		if t.radius==nil then t.radius={ tl=7.5, tr=7.5, br=7.5, bl=7.5, }
 		else t.radius={ tl=t.radius, tr=t.radius, br=t.radius, bl=t.radius, }; end
 		if t.offsetX==nil then t.offsetX=0 end
 		if t.offsetY==nil then t.offsetY=0 end
 		if t.width==nil or t.width==0 or (t.width+t.offsetX)>tonumber(cwidth) then t.width=tonumber(cwidth)-t.offsetX end
 		if t.height==nil or t.height==0 or (t.height+t.offsetY)>tonumber(cheight) then t.height=tonumber(cheight)-t.offsetY end
 		if t.color==nil or t.color==0 then t.color=0x000000 end
 		if t.alpha==nil then t.alpha=0.5 end
 		draw_box(cr, t.offsetX, t.offsetY, t.width, t.height, t.radius, t.color, t.alpha, t.nofill, t.lwidth)
 	
 		cairo_clean(cr, cs)
 		return ""
	end
 	
 	
 	
 	function conky_main()
 		local updates = tonumber(conky_parse('${updates}'))
 		if updates <= 5 then return end
 		if conky_window == nil then return end
 		print("Width:", conky_window.width, "Text width:", conky_window.text_width, "Height:", conky_window.height, "Text height:", conky_window.text_height)
		print("Border width:", conky_window.border_width, "Inner margin:", conky_window.border_inner_margin, "Outer margin:", conky_window.border_outer_margin)
 	end
 end

Offline

#7270 2014-03-28 14:33:17

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

@dk75, very interesting
thanks for the info!

Offline

#7271 2014-03-28 14:44:49

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

@ dk75 and mrpeachy.

Yea, very interesting indeed.  I never knew that about the 'border' although there have been times using the image command with "-p 0,0" I wondered why it looked to be outside the 'window'.  Now we know.

Thanks dk75

Offline

#7272 2014-03-28 15:55:05

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 459

Re: Conky v1.9 Thread

the actual nasa-image of the day looks better now:

require 'cairo'
run=1
count=1
function conky_main()
if conky_window == nil then return end
local updates=tonumber(conky_parse("${updates}"))
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)
--#########################################################################################################
--settings #####################################################


local interval=10--conky updates before switching
--set positions

------------------------------------------------------
-- download image ------------------------------------
------------------------------------------------------
local url=get_image()
local hdd="/home/alexander/iotd.jpg"
local iv=20

local updates = tonumber(conky_parse('${updates}'))
 if (math.mod(updates, iv) == 0) then
  os.execute("wget  -q -O "..hdd..' "'..url..'"') -- download image

  os.execute("mogrify -format png /home/alexander/iotd.jpg")
 end -- of update
--------------------------------------------------------

  os.execute("mv /home/alexander/iotd.png /home/alexander/bazinga/tmp/iotd.png")

--setup rounded image border
local r=20--corner radius
local border_width=4
local imagefolder="/home/alexander/bazinga/tmp/"
local imagefile="iotd.png"
local imgf=imagefolder..imagefile

local img_w=300
local img_h=300

local img_x=0
local img_y=0
local scaled="yes"
local scale_size=300



---------------------------------------------------------
-- very useful if height of the image differs -----------
---------------------------------------------------------
if scaled=="yes" then
local show = imlib_load_image(imgf)
  if show == nil then return 	end
  imlib_context_set_image(show)
  imgwidth= imlib_image_get_width()
  imgheight=imlib_image_get_height()
  img_w=scale_size
  img_h=(img_w*imgheight)/imgwidth
  imlib_free_image_and_decache()
end -- of scaled ----------------------------------------


--CODE #######################################################

local updates=tonumber(conky_parse('${updates}'))
local timer=(updates %tonumber(interval))
if timer==0 or run==1 then
	if run==1 then count=1 end
	run=nil
end--timed section
--#########################################################################################################

if border_width==0 then
 w,h=img_w,img_h
 x,y=img_x,img_y
else
 w=img_w-(border_width*2)
 h=img_h-(border_width*2)
 x=border_width
 y=border_width
end

	local xtl=x+r
	local ytl=y+r
	--top right mid circle
	local xtr=(x+r)+((w)-(2*r))
	local ytr=y+r
	--bottom right mid circle
	local xbr=(x+r)+((w)-(2*r))
	local ybr=(y+r)+((h)-(2*r))
	--bottom right mid circle
	local xbl=(x+r)
	local ybl=(y+r)+((h)-(2*r))
	-----------------------------

cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_clip (cr);

cairo_new_path (cr); --/* path not consumed by clip()*/
image = cairo_image_surface_create_from_png (imgf);
iw = cairo_image_surface_get_width (image);
ih = cairo_image_surface_get_height (image);
cairo_scale (cr, w/iw, h/ih);
cairo_set_source_surface (cr, image, x, y);
cairo_paint (cr);
cairo_surface_destroy (image);
ny=0

cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end--end main function

it would look better with a colored border smile any ideas?

Offline

#7273 2014-03-28 17:04:28

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: Conky v1.9 Thread

Offline

#7274 2014-03-28 17:23:12

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Offline

Help fund CrunchBang, donate to the project!

#7275 2014-03-28 19:48:04

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: Conky v1.9 Thread

I am preparing myself for a big write up of everything I have done with you guys over the last couple of weeks:

1. Simple Digital Photo Frame (Nitrogen and Conky)
2. Text Information Display & Rotation (conky & lua)
3. Photo Display & Rotation (conky & lua)
4. Weather  (conky & lua)

5. Digital information Display Combined

Got a bit of writing to do!

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