SEARCH

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

You are not logged in.

#4751 2013-02-09 20:12:49

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

Re: The New Monster Conky Thread

chepioq wrote:
lionhead wrote:

i really hope that the owner of this site programmed the site that it always look like now!

but i think that the sentences depends on the current time. because it looked different when i opened the site hours ago.

The command I send you don't work ?
I try this two hours ago and now for same result...


i will try it in the morning. i hope that i was wrong. i really hope that it's same like now!!!!

Offline

Be excellent to each other!

#4752 2013-02-10 06:44:42

chepioq
Member
Registered: 2013-01-09
Posts: 38

Re: The New Monster Conky Thread

lionhead wrote:
chepioq wrote:
lionhead wrote:

i really hope that the owner of this site programmed the site that it always look like now!

but i think that the sentences depends on the current time. because it looked different when i opened the site hours ago.

The command I send you don't work ?
I try this two hours ago and now for same result...


i will try it in the morning. i hope that i was wrong. i really hope that it's same like now!!!!

I test this morning, and that don't work ( there is problem with "will be" and "was", which are not in the same place ).

Try this code, I think that work all the time :

wget -q http://www.gco.org.au/weather/weather.html -O weather.html -O - | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | grep "Sunrise" | sed -n 2p | tr -d [a-z][A-Z] | awk '{print $1,$3}'

Offline

#4753 2013-02-10 08:42:05

chepioq
Member
Registered: 2013-01-09
Posts: 38

Re: The New Monster Conky Thread

New code for sunset and sunrise for today and tomorrow :

wget -q http://www.gco.org.au/weather/weather.html -O weather.html -O - | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed -n '/Solar /,/Moon/p' | sed '1d' | sed '$d' | sed 's/,//g' |  sed '/^$/d' | sed "s/\s\+/\n/g" | sed '/./!d' | sed '{:a;$!N;s_\n_ _;ta}' | sed 's/&nbsp/ /g' |  awk '{print $13$14,$11,$17,$12,$18,$19$20,$11,$23,$12,$24}'

Output :

SunRise Today 06:31:40 Tomorrow 06:32:39 SunSet Today 20:01:18 Tomorrow 20:00:24

Offline

#4754 2013-02-10 11:02:05

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

Re: The New Monster Conky Thread

because of the reason i want to display the result of this operation in lua. how can i realize this in lua?

i started with this:

local updates = tonumber(conky_parse('${updates}'))
if (math.mod(updates, 30) == 0) then
os.execute("wget -q http://www.gco.org.au/weather/weather.html -O weather.html -O - | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | grep \"Sunrise\" | sed -n 2p | tr -d [a-z][A-Z] | awk '{print $1,$3}'")
end

because i only need the daily information about sunrise/sunset i use this command smile can i save the result within a variable?

i asked the owner where he got the information from.

Last edited by lionhead (2013-02-10 15:43:28)

Offline

#4755 2013-02-10 12:17:53

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

Re: The New Monster Conky Thread

chepioq wrote:

New code for sunset and sunrise for today and tomorrow :

wget -q http://www.gco.org.au/weather/weather.html -O weather.html -O - | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed -n '/Solar /,/Moon/p' | sed '1d' | sed '$d' | sed 's/,//g' |  sed '/^$/d' | sed "s/\s\+/\n/g" | sed '/./!d' | sed '{:a;$!N;s_\n_ _;ta}' | sed 's/&nbsp/ /g' |  awk '{print $13$14,$11,$17,$12,$18,$19$20,$11,$23,$12,$24}'

Output :

SunRise Today 06:31:40 Tomorrow 06:32:39 SunSet Today 20:01:18 Tomorrow 20:00:24

or, use just one GAWK:

wget -q http://www.gco.org.au/weather/weather.html -O - | gawk '/Solar \/ Lunar/ {_start=NR} _start && /Moon/ {_stop=NR} _start && !_stop && /..:..:../ {i=i+1; x[i]=gensub(/.*(..:..:..).*/, "\\1", $0)} END{printf "\nToday:\t\tSunrise at %s\tSunset at %s\nTomorow:\tSunrise at %s\tSunset at %s\n\n", x[1], x[3], x[2], x[4]}'

Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#4756 2013-02-10 15:55:42

chepioq
Member
Registered: 2013-01-09
Posts: 38

Re: The New Monster Conky Thread

dk75 wrote:
chepioq wrote:

New code for sunset and sunrise for today and tomorrow :

wget -q http://www.gco.org.au/weather/weather.html -O weather.html -O - | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed -n '/Solar /,/Moon/p' | sed '1d' | sed '$d' | sed 's/,//g' |  sed '/^$/d' | sed "s/\s\+/\n/g" | sed '/./!d' | sed '{:a;$!N;s_\n_ _;ta}' | sed 's/&nbsp/ /g' |  awk '{print $13$14,$11,$17,$12,$18,$19$20,$11,$23,$12,$24}'

Output :

SunRise Today 06:31:40 Tomorrow 06:32:39 SunSet Today 20:01:18 Tomorrow 20:00:24

or, use just one GAWK:

wget -q http://www.gco.org.au/weather/weather.html -O - | gawk '/Solar \/ Lunar/ {_start=NR} _start && /Moon/ {_stop=NR} _start && !_stop && /..:..:../ {i=i+1; x[i]=gensub(/.*(..:..:..).*/, "\\1", $0)} END{printf "\nToday:\t\tSunrise at %s\tSunset at %s\nTomorow:\tSunrise at %s\tSunset at %s\n\n", x[1], x[3], x[2], x[4]}'

Ok... good... tongue
I don't control gawk, I go learn man gawk...

Offline

#4757 2013-02-10 18:55:21

I-sty
New Member
Registered: 2013-01-28
Posts: 7

Re: The New Monster Conky Thread

I use this code of conky:

# — Conky settings — #

background yes

update_interval 1
total_run_times 0
net_avg_samples 2

override_utf8_locale yes

double_buffer yes
no_buffers yes

text_buffer_size 2048
imlib_cache_size 0


# — Window specifications — #

#own_window_class Conky
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

border_inner_margin 0
border_outer_margin 0

minimum_size 300 300
maximum_width 300

alignment bottom_right

gap_x 5
gap_y 5


# — Graphics settings — #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

# — Text settings — #
use_xft yes
xftfont hooge 05_53:size=6
xftalpha 0.5

default_color FFFFFF

uppercase no
use_spacer right


# — Lua Load — #

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}
${voffset 35}${alignc}BAT: ${battery_percent BAT1}% - ${battery_time BAT1}
${voffset 16}${goto 65}${font hooge 05_53:size=12}${time %H:%M}${font}${goto 140}${execi 1 nc localhost 7634 | cut -c 34-35;}°C${goto 185}UPTIME:
${voffset 2}${goto 65}${time %d %b %Y}${goto 185}${uptime}
${voffset 3}${goto 65}${time %A}
${voffset -7}${alignc}HDD
${voffset 14}${alignc}${fs_free}/${fs_size} 
${voffset 23}${goto 74}${freq}${goto 200}${mem}
${voffset 7}${goto 69}${cpu cpu0}%${goto 91}${cpu cpu1}%${goto 221}${memperc}%
${voffset 4}${goto 75}CPU${goto 205}RAM
${voffset 31}${alignc}${wireless_link_qual_perc wlp2s0}%
${voffset 1}${alignc}${wireless_bitrate wlp2s0}
#${voffset 15}${alignc}WLAN
${voffset 6}${alignc}${addr wlp2s0}
#${voffset -8}${goto 15}${font ConkyWeather:style=Bold:size=10}${execi 600 conkyForecast --location=FIXX0020 --datatype=WF}${font}
#${voffset -52}${goto 100}${font Weather:size=10}y${font}   ${voffset -38}${font Trebuchet MS:size=6}${execi 600 conkyForecast --location=FIXX0020 --datatype=HT}${font}


#${voffset 20}${goto 90}${font hooge 05_53:size=12}${execpi 600 sed -n '1285p' $HOME/.Conky/cronograph/accuweather/curr_cond_raw | cut -c 31-31}°
#${voffset -32}${goto 125}${font conkyweather:size=40}${execpi 600 sed -n '1285p' $HOME/.Conky/cronograph/accuweather/curr_cond_raw | cut -c 31-32}${font}
#${voffset -12}${goto 185}${execpi 600 sed -n '3p' $HOME/.Conky/cronograph/accuweather/curr_cond_raw}${voffset 12}${goto 185}${font conkyweather:size=20}
#${voffset 7}${goto 80}${execpi 600 sed -n '7p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}${goto 135}${execpi 600 sed -n '12p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}${goto 185}${execpi 600 sed -n '17p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}${font}
#${voffset 6}${goto 84}${execpi 600 sed -n '9p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}°/${execpi 600 sed -n '10p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}°${goto 140}${execpi 600 sed -n '14p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}°/${execpi 600 sed -n '15p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}°${goto 190}${execpi 600 sed -n '19p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}°/${execpi 600 sed -n '20p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}°
#${voffset 7}${goto 85}${execpi 600 sed -n '6p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}${goto 140}${execpi 600 sed -n '11p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}${goto 190}${execpi 600 sed -n '16p' $HOME/.Conky/cronograph/accuweather/tod_ton_raw}
#${execpi 1 cat $HOME/.Conky/cronograph/scripts/blinkingLED}

But in terminal I got many-many error aka unknown variable.

[i-sty@localhost ~]$ killall conky
[i-sty@localhost ~]$ .Conky/cronograph/start_conky.sh 
[i-sty@localhost ~]$ Conky: forked to background, pid is 24576

Conky: desktop window (120002a) is subwindow of root window (d7)
Conky: window type - normal
Conky: drawing to created window (0x1600002)
Conky: drawing to double buffer
Conky: unknown variable 
Conky: unknown variable 
Conky: unknown variable 
....

What is wrong in my code?
I checked all conky comman (alignment, size, etc) but always are exited on the man pages.
I have error on my two lua scripts?

Offline

#4758 2013-02-10 20:05:52

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

Re: The New Monster Conky Thread

lionhead wrote:

because of the reason i want to display the result of this operation in lua. how can i realize this in lua?

i started with this:

local updates = tonumber(conky_parse('${updates}'))
if (math.mod(updates, 30) == 0) then
os.execute("wget -q http://www.gco.org.au/weather/weather.html -O weather.html -O - | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | grep \"Sunrise\" | sed -n 2p | tr -d [a-z][A-Z] | awk '{print $1,$3}'")
end

because i only need the daily information about sunrise/sunset i use this command smile can i save the result within a variable?

i asked the owner where he got the information from.

use that instead

 --[[
 Sunrise and Sunset time from http://www.gco.org.au/weather/weather.html page
 
 usage:
 	default interval=3600 of conky updates (1h if conky_updates=1)
 		lua_load $HOME/path-to-script/sunriseset.lua
 		lua_draw_hook_pre conky_sunriseset
 
 	set custom interval=4000 of conky updates (1h 10m if conky_updates=1)
 		lua_load $HOME/path-to-script/sunriseset.lua
 		lua_draw_hook_pre conky_sunriseset 4000
 --]]
 
 local file_uri, file = "http://www.gco.org.au/weather/weather.html", "/tmp/weather.html"
 local def_sunrise, def_sunset, startup, def_interval, fTab = "06:00:00", "18:00:00", false, 3600, {}
 local sunrise, sunset = nil
 
 local function fetch_weather(updates, interval)
 	if startup then if (updates % interval) ~= 0 then return "100" end else startup=true end
 	os.execute("wget -q "..file_uri.." -O "..file.." &")
 end
 
 local function fetch_file(fw, updates, interval)
 	if ( fw ~= "100" and fTab[1] ~= nil ) or (updates % interval) ~= 0 then return "" end
 	i=0
 	local f=io.open(file, 'r')
 	if f then io.close(f) else return "200" end
 	for line in io.lines(file) do
 		i=i+1
 		fTab[i]=line
 	end
 end
 
 local function parse_table(ff)
 	if ff == "200" or fTab[1] == nil then return "300" end
 	local t, i, k, v = {}, 0, nil
 	for k, v in pairs(fTab) do
 		if string.find(v, ">Sunrise") then
 			for k in string.gmatch(v, "%d%d:%d%d:%d%d") do i=i+1; t[i]=k end
 		end
 	end
 	if t[1] and t[2] then return "", t[1], t[2] else return "300", nil, nil end
 end
 
 function conky_sunriseset(interval)
 	if conky_window == nil then return "0" end
 	local updates=tonumber(conky_parse('${updates}'))
 	if updates <= 5 then return "0" end
 	if not interval or tonumber(interval) < 3600 then interval=def_interval else interval=tonumber(interval) end
 	
 	fw=fetch_weather(updates, interval)
 	ff=fetch_file(fw, updates, 15)
 	pt, sunrise, sunset = parse_table(ff)
 	if not sunrise or pt == "300" then sunrise=def_sunrise end
 	if not sunset or pt == "300" then sunset=def_sunset end
 	if fw ~= "100" then fTab={} end
 
 	print("Sunrise = "..sunrise,"Sunset = "..sunset)
 end

Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#4759 2013-02-10 20:53:46

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

Re: The New Monster Conky Thread

i want to save the content of the file 'weather.html' (only the necessary datas) within a variable. then i want to display it as text in lua.

Offline

#4760 2013-02-10 21:05:23

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

Re: The New Monster Conky Thread

weather.html is saved into fTab table.
I've parsed it in parse_table() function to take Sunrise and Sunset time.
You could change parse_table() to fetch whatever information you want.


Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#4761 2013-02-10 23:29:58

VDP76
#! Bean Roaster
Registered: 2012-04-12
Posts: 826

Re: The New Monster Conky Thread

hi,

in my current setup, conky's window is positioned in the wrong place at startup...if I change gap_y 0 to gap_y 10, save, revert back to gap_y 0 and save again, the window is magically placed where it should be. It seems to be a known bug...
the solution that works for me is just to add to openbox autostart

(sleep 5s && conky_fix) &

conky_fix is simply

#!/bin/bash
sed -i 's/gap_y 0/gap_y 0/g' /home/mattia/.conky/conkyrc_bars

It is not an amazing fix, but I hope it will be useful to someone.. smile

Last edited by VDP76 (2013-02-11 15:51:59)


#!#!#! Forum etiquette #!#!#!
Are you a new member!? Have you introduced yourself?!
CLI basics | LVM | smxi | chrooting | multiarch

Offline

#4762 2013-02-11 16:18:52

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

Re: The New Monster Conky Thread

i have a problem with quotes (again)

local grab_file = io.popen("curl -s http://www.nasa.gov/rss/image_of_the_day.rss | grep 'url=' | sed 's/^.*url="//' | sed 's/\".*$//'`")

can u please help me?

Offline

#4763 2013-02-11 17:23:01

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

Re: The New Monster Conky Thread

lionhead wrote:

i have a problem with quotes (again)

local grab_file = io.popen("curl -s http://www.nasa.gov/rss/image_of_the_day.rss | grep 'url=' | sed 's/^.*url="//' | sed 's/\".*$//'`")

can u please help me?

function get_image(uri)
	local f = assert(io.popen('curl -s '..uri, 'r'))
	local s = assert(f:read('*a'))
	f:close()
	s, f = string.gsub(s, ".*image\/jpeg.*(http://.*\.jpg).*", "%1")
	return s
end

local grab_file = get_image('http://www.nasa.gov/rss/image_of_the_day.rss')

Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#4764 2013-02-11 17:46:59

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

Re: The New Monster Conky Thread

it works fine. i have an extra function to display external images (like the image of the day):

function extern_img(wb)
-- define variables
img_x=(wb.posx or 0)
img_y=(wb.posy or 0)
img_w=(wb.imgw or 200)
img_h=(wb.imgh or 200)
s=wb.imgurl -- url of the webcam
img_nw=(wb.imghdd or "external_img.jpg")
img_file='/home/'..username.."/"..img_nw
img_intervall=(wb.imgiv or 60)
-- grab external image from url and save it to hdd
local updates = tonumber(conky_parse('${updates}'))
if (math.mod(updates, img_intervall) == 0) then
os.execute("wget  -q -O "..img_file..' "'..s..'"')
end
-- load and display image from harddisk
if img_file==nil then print("set image file") end
image({x=img_x,y=img_y,w=img_w,h=img_h,file=img_file})
end--of function to display external images 

i call the both functions like this:

local nasa_url=get_image('http://www.nasa.gov/rss/image_of_the_day.rss')
extern_img({posx=205,posy=0,imgw=200,imgh=200,imgurl=nasa_url,imghdd="nasa.jpg",imgiv=60})

Offline

#4765 2013-02-15 20:03:12

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

Re: The New Monster Conky Thread

@lionhead, check your PM


VSIDO | SolusOS

Words That Build Or Destroy

Offline

#4766 2013-02-15 21:01:04

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,087
Website

Re: The New Monster Conky Thread

VDP76 wrote:

hi,

in my current setup, conky's window is positioned in the wrong place at startup...if I change gap_y 0 to gap_y 10, save, revert back to gap_y 0 and save again, the window is magically placed where it should be. It seems to be a known bug...
the solution that works for me is just to add to openbox autostart

(sleep 5s && conky_fix) &

conky_fix is simply

#!/bin/bash
sed -i 's/gap_y 0/gap_y 0/g' /home/mattia/.conky/conkyrc_bars

It is not an amazing fix, but I hope it will be useful to someone.. smile

You are starting the conky on the top left of your screen

alignment top_left

and moving it

gap_x 860

to the right.

Then you are telling conky to use a "window" that is at a minimum 1000 pixels wide.

minimum_size 1000 5

On my 1280 screen that moved the start of the conky back to the ±280 (closer to 265) position
adp7bvTY.jpg

Now if I comment out that minimum width of 1000:
abonbhpF.jpg
Your conky always goes where it is told to go.

NOTE: Since conky v1.8.0, conky does not always refresh the "window size" properly on "saving" while editing, so after saving in a terminal it's best to kill your conky and restart it:
Example:

killall conky && conky -c /media/5/conky/VDP76.conky &

#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Offline

#4767 2013-02-16 10:48:05

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

Re: The New Monster Conky Thread

i want to center an image within my conky-window. i know how to center text but i do not how the code to center images. because i do not know the necessary code. does have imlib2 has a similar parameter like x_bearing ?

my screenshot: http://ompldr.org/vaGhkbQ

this are the functions to load images:

-- ##################################################################################
-- ## display local images from hdd #################################################
-- ##################################################################################
function image(im)
x=nil
x=(im.x or 0)
y=nil
y=(im.y or 0)
w=nil
w=(im.w or default_image_width)
h=nil
h=(im.h or default_image_height)
file=nil
file=tostring(im.file)
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(w)
end
if tonumber(h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image_and_decache()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x, y)
imlib_free_image_and_decache()
show=nil
end--function image 

-- ###############################################################################
-- ## display external images ####################################################
-- ###############################################################################
function extern_img(wb)
-- define variables
img_x=(wb.posx or 0)
img_y=(wb.posy or 0)
img_w=(wb.imgw or 200)
img_h=(wb.imgh or 200)
s=wb.imgurl -- url of the webcam
img_nw=(wb.imghdd or "external_img.jpg")
img_file='/home/'..username.."/"..img_nw
img_intervall=(wb.imgiv or 60)
img_hubble=(wb.img_hubble or 'no')
-- grab external image from url and save it to hdd
local updates = tonumber(conky_parse('${updates}'))
if (math.mod(updates, img_intervall) == 0) then
os.execute("wget  -q -O "..img_file..' "'..s..'"')
end

if img_hubble=="yes" then
	local show = imlib_load_image(img_nw)
	if show == nil then return end
	imlib_context_set_image(show)
	width=imlib_image_get_width() 
	height=imlib_image_get_height() 
	-- load and display image from harddisk
	if img_file==nil then print("set image file") end
	image({x=0,y=img_y,w=width,h=height,file=img_file})
else
	-- load and display image from harddisk
	if img_file==nil then print("set image file") end
	image({x=img_x,y=img_y,w=img_w,h=img_h,file=img_file})
end -- of if

end--of function 

can u help me to find the necessary parameters?

Offline

#4768 2013-02-16 19:21:52

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

Re: The New Monster Conky Thread

^ Use

local image_width = imlib_image_get_width()

to get the width of the image in pixels.
If you resize the image use the width of your resized image for "image_width" instead.

Then get the width of the conky window.

local conkyWidth = conky_window.width - conky_window.text_start_x - conky_window.border_width

This calculation works best for the way I have my .conkyrc setup but you might need to change it to work well with yours.
I may also not be quite right for imlib2, I have only used it with cairo.

Now you can calculate where to place the left side of the image to center it like this.

local image_leftx = (conkyWidth - image_width)/2

You use that number like this to center the image

imlib_render_image_on_drawable(image_leftx, y)

You can do the same thing for the "y" position using "imlib_image_get_height()" and "conky_window.height".

Last edited by arclance (2013-02-16 19:30:51)

Online

#4769 2013-02-18 08:35:25

lwfitz
#! Die Hard
From: Monrovia, CA
Registered: 2012-01-19
Posts: 886
Website

Re: The New Monster Conky Thread

2013-02-18--13611751051918x1079scrot.png

conky_weather2

### Thanks to everyone at the VSIDO Forums #####
### Thanks to TeoBigusGeekus for the accuweather script #####
### Accuweather images edited by lwfitz ####
### allcombined.lua written by mrpeachy ####
### clock background image by Doruletz ####
max_specials 10000
max_user_text 15000
background no
use_xft yes
xftfont sans:size=9
xftalpha 1
total_run_times 0
own_window yes
own_window_argb_visual yes
own_window_transparent yes
own_window_type normal
own_window_title conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 375 1020
maximum_width 375
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_shade_color black
default_outline_color white
alignment top_left
gap_x 15
gap_y 20
no_buffers yes
uppercase no
cpu_avg_samples 6
override_utf8_locale yes
text_buffer_size 100000
top_name_width 5
update_interval 1
default_color FFFFFF
temperature_unit fahrenheit
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
format_human_readable yes
short_units yes
update_interval 1
imlib_cache_size 0

#   Maximum size of user text buffer, i.e. layout below TEXT line in config file
#  (default is 16384 bytes)
# max_user_text 16384

# Desired output unit of all objects displaying a temperature. Parameters are
# either "fahrenheit" or "celsius". The default unit is degree Celsius.
temperature_unit Fahrenheit

----------------------------

################### LUA #######################################

lua_load ~/Conky/allcombined_2.lua


## lua funcions
## background ##################################################################
#${lua draw_bg {corner_radius,x_position,y_position,width,height,color,alpha,draw_type,line_width,outline_color,outline_alpha}}
#note for background: set width=0 - width will be conky window width, set height=0 - height will be conky window height
# draw_type: 1=fill, 2=outline(must specify line_width), 3=outline and fill (must specify line_width, outline_color and outline_alpha)
## gradient bars ###############################################################
#${lua gradbar {x_position,y_position,"conky_object",object_max_value,number_of_divisions,division_width,division_height,division_gap,bg_color,bg_alpha,start_color,start_alpha,mid_color,mid_alpha,end_color,end_alpha}}
## calendar ###############################################################
#${lua luacal {x_position,y_position,"title_font",title_fontsize,title_color,title_alpha,"dates_font",dates_fontsize,dates_color,dates_alpha,"highlight_font",highlight_fontsize,highlight_color,highlight_alpha,"spacer",colum_gap,title_gap,row_gap,start_day}
#note for calendar: start day... 0=sunday, 1=monday ... "spacer" can help align calendar with non fix width fonts
## textured background ###############################################################
#${lua tex_bg {corner_radius,x_position,y_position,width,height,"/path/to/texture.png"}}
## lua draw images ###############################################################
#${lua luaimage {x_position,y_position,width,height,"/path/to/image"}}
#note for images: set width=0 - width will be image width, set height=0 - height will be image height
## lua draw text ###############################################################
#${lua luatext {x_position,y_position,color,alpha,"font",fontsize,"justify"}}
#note for text: justify can be "r" = right, "c" = center, "l" = left
#${lua draw_bg {10,0,0,0,0,0x000000,0.3}}

##############################  End LUA  ###
TEXT
${image $HOME/Conky/Clock-Flip.png -p 85,-5 -s 100x110}${image $HOME/Conky/Clock-Flip.png -p 185,-5 -s 100x110}
#########################################################################################################
	# (RO) TIME
${font Helvetica LT Std :style=bold:size=58}${color 737373}${goto 100}${time %H}${goto 175}${goto 200}${color 737373}${time %M}${font}${color}
#########################################################################################################
	
	# LOCATION (CITY NAMES) #

${voffset -10}${goto 85}${font Bitstream Vera Sans Mono:style=Bold:size=24:locale=ro}Monrovia,CA${font}${color}

#${lua tex_bg {20,4,20,365,540,"/home/luke/Conky/brushed.png"}}
${lua draw_bg {20,8,23,365,1020,0x737373,.15,2,8}}${voffset -10}${font WhiteRabbit:size=15}${goto 30}Temp ${goto 288}Feels${voffset 10}
${font WhiteRabbit:size=20}${goto 25}${execpi 600 sed -n '4p' $HOME/Accuweather_Conky_USA_Images/curr_cond}°F ${goto 286}${execpi 600 sed -n '5p' $HOME/Accuweather_Conky_USA_Images/curr_cond}°F
${font WhiteRabbit:size=11}${texeci 500 bash $HOME/Accuweather_Conky_USA_Images/acc_usa_images}${image $HOME/Accuweather_Conky_USA_Images/cc.png -p 75,118 -s 240x225}




${font WhiteRabbit:size=15}${goto 30}Dawn ${goto 285}Dusk
${voffset 10}${font WhiteRabbit:size=17}${goto 15}${execpi 600 sed -n '15p' $HOME/Accuweather_Conky_USA_Images/curr_cond}${goto 262}${execpi 600 sed -n '16p' $HOME/Accuweather_Conky_USA_Images/curr_cond}${voffset -10}

${font WhiteRabbit:size=13}${goto 30}${execpi 600 sed -n '6p' $HOME/Accuweather_Conky_USA_Images/tod_ton}${goto 145}${execpi 600 sed -n '11p' $HOME/Accuweather_Conky_USA_Images/tod_ton}${goto 265}${execpi 600 sed -n '16p' $HOME/Accuweather_Conky_USA_Images/tod_ton}

${font WhiteRabbit:size=10}${goto 100}${execpi 600 sed -n '9p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F${goto 215}${execpi 600 sed -n '14p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F${goto 330}${execpi 600 sed -n '19p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F
${voffset 5}${font WhiteRabbit:size=10}${goto 100}${execpi 600 sed -n '10p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F${goto 215}${execpi 600 sed -n '15p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F${goto 330}${execpi 600 sed -n '20p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F${image $HOME/Accuweather_Conky_USA_Images/7.png -p 20,318 -s 80x67}${image $HOME/Accuweather_Conky_USA_Images/12.png -p 138,318 -s 80x67}${image $HOME/Accuweather_Conky_USA_Images/17.png -p 256,318 -s 80x67}${voffset -5}



${font WhiteRabbit:size=13}${goto 30}${execpi 600 sed -n '21p' $HOME/Accuweather_Conky_USA_Images/tod_ton}${goto 145}${execpi 600 sed -n '1p' $HOME/Accuweather_Conky_USA_Images/last_days}${goto 265}${execpi 600 sed -n '6p' $HOME/Accuweather_Conky_USA_Images/last_days}

${font WhiteRabbit:size=10}${goto 100}${execpi 600 sed -n '24p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F${goto 215}${execpi 600 sed -n '4p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${goto 330}${execpi 600 sed -n '9p' $HOME/Accuweather_Conky_USA_Images/last_days}°F
${voffset 5}${font WhiteRabbit:size=10}${goto 100}${execpi 600 sed -n '25p' $HOME/Accuweather_Conky_USA_Images/tod_ton}°F${goto 215}${execpi 600 sed -n '5p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${goto 330}${execpi 600 sed -n '10p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${image $HOME/Accuweather_Conky_USA_Images/22.png -p 20,405 -s 80x67}${image $HOME/Accuweather_Conky_USA_Images/N2.png -p 138,405 -s 80x67}${image $HOME/Accuweather_Conky_USA_Images/N7.png -p 256,405 -s 80x67}${voffset -5}
#
#
#
#${font WhiteRabbit:size=13}${goto 30}${execpi 600 sed -n '11p' $HOME/Accuweather_Conky_USA_Images/last_days}${goto 145}${execpi 600 sed -n '16p' $HOME/Accuweather_Conky_USA_Images/last_days}${goto 265}${execpi 600 sed -n '21p' $HOME/Accuweather_Conky_USA_Images/last_days}
#
#${font WhiteRabbit:size=10}${goto 100}${execpi 600 sed -n '14p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${goto 215}${execpi 600 sed -n '19p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${goto 330}${execpi 600 sed -n '24p' $HOME/Accuweather_Conky_USA_Images/last_days}°F
#${voffset 5}${font WhiteRabbit:size=10}${goto 100}${execpi 600 sed -n '15p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${goto 215}${execpi 600 sed -n '20p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${goto 330}${execpi 600 sed -n '25p' $HOME/Accuweather_Conky_USA_Images/last_days}°F${image $HOME/Accuweather_Conky_USA_Images/N12.png -p 20,492 -s 80x67}${image $HOME/Accuweather_Conky_USA_Images/N17.png -p 138,492 -s 80x67}${image $HOME/Accuweather_Conky_USA_Images/N22.png -p 256,492 -s 80x67}${voffset -5}


${color 737373}${goto 15}${cpubar 1,350 cpu0}${color}

${font WhiteRabbit:size=25}${goto 80}Now Playing





${color 737373}${goto 15}${cpubar 1,350 cpu0}${color}
${image ~/Conky/grey_bar2.png -s 50x90 -p 168,660}
${voffset -30}${goto 15}${font WhiteRabbit:size=13}CPU1${goto 65}${cpu cpu1}%${goto 110}CPU2 ${cpu cpu2}%${goto 207}${font WhiteRabbit:size=20}Memory ${alignr 22}${memperc}%
${goto 15}${font WhiteRabbit:size=13}CPU3${goto 65}${cpu cpu3}%${goto 110}CPU4 ${cpu cpu4}%${voffset 20}${goto 207}${font WhiteRabbit:size=20}Swap ${alignr 22}${swapperc}%${voffset -20}
${goto 15}${font WhiteRabbit:size=13}CPU5${goto 65}${cpu cpu5}%${goto 110}CPU6 ${cpu cpu6}%

${color 737373}${goto 15}${cpubar 1,350 cpu0}${color}

#${font WhiteRabbit:size=25}${goto 125}Storage
${goto 15}${font WhiteRabbit:size=13}/Root${goto 130}${fs_used /}${goto 180} / ${fs_size /} ${alignr 25}${fs_used_perc /}%
${voffset 8}${goto 15}${font WhiteRabbit:size=13}/Home${goto 130}${fs_used /home}${goto 180} / ${fs_size /home} ${alignr 25}${fs_used_perc /home}%
${voffset 8}${goto 15}${font WhiteRabbit:size=13}Backup${goto 130}${fs_used /media/storage}${goto 180} / ${fs_size /media/storage} ${alignr 25}${fs_used_perc /media/storage}%
${voffset 8}${goto 15}${font WhiteRabbit:size=13}Music${goto 130}${fs_used /media/sde6}${goto 180} / ${fs_size /media/sde6} ${alignr 25}${fs_used_perc /media/sde6}%
${voffset 8}${goto 15}${font WhiteRabbit:size=13}External${goto 130}${fs_used /media/sde5}${goto 180} / ${fs_size /media/sde5} ${alignr 25}${fs_used_perc /media/sde5}%
${voffset 8}${goto 15}${font WhiteRabbit:size=13}Videos${goto 130}${fs_used /media/sdc1}${goto 180} / ${fs_size /media/sdc1} ${alignr 25}${fs_used_perc /media/sdc1}%
${voffset 8}${goto 15}${font WhiteRabbit:size=13}Software${goto 130}${fs_used /media/sdb1}${goto 180} / ${fs_size /media/sdb1} ${alignr 25}${fs_used_perc /media/sdb1}%
#${voffset 8}${goto 15}${font WhiteRabbit:size=13}/Home${goto 130}${fs_used /home}${goto 180} / ${fs_size /home} ${alignr 25}${fs_used_perc /home}%

${color 737373}${goto 15}${cpubar 1,350 cpu0}${color}

${goto 15}${voffset -3}Down Speed${goto 175}${downspeed eth0} ${goto 275}${voffset -8}${downspeedgraph eth0 20,75 99CCFF 000099}${color} 
${goto 15}${voffset 8}Up Speed${goto 175}${upspeed eth0} ${goto 275}${voffset -8}${upspeedgraph eth0 20,75 99CCFF 000099}${color}

allcombined_2.lua

--[[ by mrpeachy - 
combines background bar and calendar functions
]]
require 'cairo'
require 'imlib2'

function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end

function conky_gradbar(bartab)
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=tonumber(conky_parse('${updates}'))
if updates>5 then
--#########################################################################################################
--convert to table
local bartab=loadstring("return" .. bartab)()
local bar_startx=bartab[1]
local bar_starty=bartab[2]
local number=bartab[3]
local number=conky_parse(number)
local number_max=bartab[4]
local divisions=bartab[5]
local div_width=bartab[6]
local div_height=bartab[7]
local div_gap=bartab[8]
local bg_col=bartab[9]
local bg_alpha=bartab[10]
local st_col=bartab[11]
local st_alpha=bartab[12]
local mid_col=bartab[13]
local mid_alpha=bartab[14]
local end_col=bartab[15]
local end_alpha=bartab[16]
--color conversion
local br,bg,bb,ba=rgb_to_r_g_b({bg_col,bg_alpha})
local sr,sg,sb,sa=rgb_to_r_g_b({st_col,st_alpha})
local mr,mg,mb,ma=rgb_to_r_g_b({mid_col,mid_alpha})
local er,eg,eb,ea=rgb_to_r_g_b({end_col,end_alpha})
if number==nil then number=0 end
local number_divs=(number/number_max)*divisions
cairo_set_line_width (cr,div_width)
--gradient calculations
for i=1,divisions do
if i<(divisions/2) and i<=number_divs then
colr=((mr-sr)*(i/(divisions/2)))+sr
colg=((mg-sg)*(i/(divisions/2)))+sg
colb=((mb-sb)*(i/(divisions/2)))+sb
cola=((ma-sa)*(i/(divisions/2)))+sa
elseif i>=(divisions/2) and i<=number_divs then
colr=((er-mr)*((i-(divisions/2))/(divisions/2)))+mr
colg=((eg-mg)*((i-(divisions/2))/(divisions/2)))+mg
colb=((eb-mb)*((i-(divisions/2))/(divisions/2)))+mb
cola=((ea-ma)*((i-(divisions/2))/(divisions/2)))+ma
else
colr=br
colg=bg
colb=bb
cola=ba
end
cairo_set_source_rgba (cr,colr,colg,colb,cola)
cairo_move_to (cr,bar_startx+((div_width+div_gap)*i-1),bar_starty)
cairo_rel_line_to (cr,0,div_height)
cairo_stroke (cr)
end
--#########################################################################################################
end-- if updates>5
bartab=nil
colr=nil
colg=nil
colb=nil
cola=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_draw_bg(bgtab)
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)
--#########################################################################################################
--convert to table
local bgtab=loadstring("return" .. bgtab)()
local r=bgtab[1]
local x=bgtab[2]
local y=bgtab[3]
local w=bgtab[4]
local h=bgtab[5]
local color=bgtab[6]
local alpha=bgtab[7]
if w==0 then 
w=tonumber(conky_window.width)
end
if h==0 then
h=tonumber(conky_window.height)
end
cairo_set_source_rgba (cr,rgb_to_r_g_b({color,alpha}))
--top left mid circle
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))
--the drawing part---------------------------
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_fill (cr)
--#########################################################################################################
bgtab=nil
w=nil
h=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_luacal(caltab)
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 caltab=loadstring("return" .. caltab)()
local cal_x=caltab[1]
local cal_y=caltab[2]
local tfont=caltab[3]
local tfontsize=caltab[4]
local tc=caltab[5]
local ta=caltab[6]
local bfont=caltab[7]
local bfontsize=caltab[8]
local bc=caltab[9]
local ba=caltab[10]
local hfont=caltab[11]
local hfontsize=caltab[12]
local hc=caltab[13]
local ha=caltab[14]
local spacer=caltab[15]
local gaph=caltab[16]
local gapt=caltab[17]
local gapl=caltab[18]
local sday=caltab[19]
--convert colors
--local font=string.gsub(font,"_"," ")
local tred,tgreen,tblue,talpha=rgb_to_r_g_b({tc,ta})
--main body text color
local bred,bgreen,bblue,balpha=rgb_to_r_g_b({bc,ba})
--highlight text color
local hred,hgreen,hblue,halpha=rgb_to_r_g_b({hc,ha})
--###################################################
--calendar calcs
local year=os.date("%G")
local today=tonumber(os.date("%d"))
local t1 = os.time( {    year=year,month=03,day=01,hour=00,min=0,sec=0} );
local t2 = os.time( {    year=year,month=02,day=01,hour=00,min=0,sec=0} );
local feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={ 31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local day=tonumber(os.date("%w"))+1-sday
local day_num = today
local remainder=day_num % 7
local start_day=day-(day_num % 7)
if start_day<0 then start_day=7+start_day end     
local month=os.date("%m")
local mdays=monthdays[tonumber(month)]
local x=mdays+start_day
local dnum={}
local dnumh={}
if mdays+start_day<36 then 
dlen=35
plen=29 
else 
dlen=42 
plen=36
end
for i=1,dlen do
	if i<=start_day then 
	dnum[i]="  " 
	else 
	dn=i-start_day
		if dn=="nil" then dn=0 end
		if dn<=9 then dn=(spacer .. dn) end
		if i>x then dn="" end
		dnum[i]=dn
		dnumh[i]=dn
		if dn==(spacer .. today) or dn==today then
		dnum[i]=""
		end 
		if dn==(spacer .. today) or dn==today then
		dnumh[i]=dn
		place=i 
		else dnumh[i]="  " 
		end 
	end
end--for
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tfontsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
if tonumber(sday)==0 then
dys={"SU","MO","TU","WE","TH","FR","SA"}
else
dys={"MO","TU","WE","TH","FR","SA","SU"}
end
--draw calendar titles
for i=1,7 do
cairo_move_to (cr, cal_x+(gaph*(i-1)), cal_y)
cairo_show_text (cr, dys[i])
cairo_stroke (cr)
end
--draw calendar body
cairo_select_font_face (cr, bfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, bfontsize);
cairo_set_source_rgba (cr,bred,bgreen,bblue,balpha)
for i=1,plen,7 do
local fn=i
	for i=fn,fn+6 do
	cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
	cairo_show_text (cr, dnum[i])
	cairo_stroke (cr)
	end
end
--highlight
cairo_select_font_face (cr, hfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, hfontsize);
cairo_set_source_rgba (cr,hred,hgreen,hblue,halpha)
for i=1,plen,7 do
local fn=i
	for i=fn,fn+6 do
	cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
	cairo_show_text (cr, dnumh[i])
	cairo_stroke (cr)
	end
end
--#########################################################################################################
caltab=nil
dlen=nil
plen=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_luaimage(imtab)
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 imtab=loadstring("return" .. imtab)()
local im_x=imtab[1]
local im_y=imtab[2]
local im_w=imtab[3]
local im_h=imtab[4]
local file=imtab[5]
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(im_w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(im_w)
end
if tonumber(im_h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(im_h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(im_x, im_y)
imlib_free_image()
show=nil
--#########################################################################################################
imtab=nil
height=nil
width=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_tex_bg(textab)
local textab=loadstring("return" .. textab)()
local tex_file=textab[6]
local surface = cairo_image_surface_create_from_png(tostring(tex_file))
local cw,ch = conky_window.width, conky_window.height
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, cw,ch)
local cr=cairo_create(cs)
--#########################################################################################################
--convert to table
local r=textab[1]
local x=textab[2]
local y=textab[3]
local w=textab[4]
local h=textab[5]
if w=="0" then
w=cw
end
if h=="0" then
h=ch
end
--top left mid circle
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))
--the drawing part---------------------------
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);
--image part
cairo_set_source_surface (cr, surface, 0, 0)
cairo_paint (cr)
--#########################################################################################################
textab=nil
w=nil
h=nil
cairo_destroy(cr)
cairo_surface_destroy (cs)
cairo_surface_destroy (surface)
cr=nil
return ""
end-- end main function

function conky_luatext(txttab)--x,y,c,a,f,fs,txt,j ##################################################
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)
--#########################################################################################################
--convert to table
local txttab=loadstring("return" .. txttab)()
local x=txttab[1]
local y=txttab[2]
local c=txttab[3]
local a=txttab[4]
local f=txttab[5]
local fs=txttab[6]
local j=txttab[7]
local txt=txttab[8]
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,txt,extents)
local wx=extents.x_advance
cairo_set_source_rgba (cr,rgb_to_r_g_b({c,a}))
if j=="l" then
cairo_move_to (cr,x,y)
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
end
cairo_show_text (cr,txt)
cairo_stroke (cr)
--#########################################################################################################
txttab=nil
cairo_destroy(cr)
cairo_surface_destroy (cs)
cr=nil
return ""
end-- end main function

Teos weather accuweather script w/ my edited images and the clock background
image can be found here

The wallpaper can be found here

Offline

#4770 2013-02-19 11:15:36

timius1
New Member
Registered: 2013-02-19
Posts: 4

Re: The New Monster Conky Thread

ansem_of_nexus wrote:

So I know I have been gone for awhile but I am back and I brought my version of a clock.
http://s5.postimage.org/utjvngikz/2013_02_01_1359742190_240x219_scrot.png
Mine
http://s5.postimage.org/9lasjrthv/2013_02_01_1359742249_216x210_scrot.png
Style set 1
http://s5.postimage.org/br53e9wyb/2013_02_01_1359742277_215x211_scrot.png
style set 2
http://s5.postimage.org/3mwz9jaj7/2013_02_01_1359742336_222x206_scrot.png
Style set 3
http://s5.postimage.org/b466or02b/2013_02_01_1359742360_230x218_scrot.png
Style set 4

I set it up so this clock is completely customizable, so each person can find their own version of the clock. I also labeled the code I copied from mrpeachy. credit where credit is due

--this lua script for use in conky
require 'cairo'
extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
function conky_clock()
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)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--######################################################################
-- Settings ############################################################
--######################################################################
center_x=110
center_y=110
--style set 0 for none or 1, 2, 3, 4, or mine
style_set=1
--clock face 1 or 2
clock_face=2
--hours on the clock 12 or 24
hours=12
--visiblity 1 or 0
hands=1
lights=0
digital=0
chrono=0
gears=0
texts=1
--the second interval displayed 5, 10, or 15
seconds=15
-- Colors
d_font_red=.8
d_font_green=.8
d_font_blue=.8
d_font_alpha=1
br_red=.5
br_green=.5
br_blue=.5
br_alpha=1
bg_red=.05
bg_green=.05
bg_blue=.05
bg_alpha=1
lights_red=.2
lights_green=.2
lights_blue=1
lights_alpha=.75
hands_red=.5
hands_green=.5
hands_blue=.5
hands_ired=.25
hands_igreen=.25
hands_iblue=.25
hands_alpha=1
--######################################################################
-- Style Sets ##########################################################
--######################################################################
if style_set == 1 then
clock_face=1
hours=12
hands=0
lights=1
digital=1
chrono=0
gears=0
texts=1
seconds=5
end
if style_set == 2 then
clock_face=2
hours=12
hands=1
lights=0
digital=0
chrono=0
gears=0
texts=1
seconds=5
end
if style_set == 3 then
clock_face=1
hours=24
hands=0
lights=1
digital=0
chrono=1
gears=1
texts=1
seconds=10
end
if style_set == 4 then
clock_face=2
hours=24
hands=1
lights=0
digital=0
chrono=1
gears=1
texts=1
seconds=10
end
if style_set == mine then
clock_face=2
hours=24
hands=1
lights=1
digital=0
chrono=1
gears=1
texts=1
seconds=5
end
--######################################################################
-- Strings #############################################################
--######################################################################
d_line_width=1
d_math=math.pi/180
d_font="mono"
d_font_size=11
d_font_slant=CAIRO_FONT_SLANT_NORMAL
d_font_face=CAIRO_FONT_WEIGHT_NORMAL
outer_radius=100
year=conky_parse("${time %y}")
month_number=tonumber(conky_parse("${time %m}"))
weekday=conky_parse("${time %u}")
day=conky_parse("${time %a}")
abbr_month=conky_parse("${time %b}")
day_number=conky_parse("${time %d}")
ampm=conky_parse("${time %p}")
second=tonumber(conky_parse("${time %S}"))
minute=tonumber(conky_parse("${time %M}"))
if hours ~= 12 then hours=24 end
if hours == 12 then
hour=tonumber(conky_parse("${time %I}"))
time_hms=conky_parse("${time %r}")
i_start=1
i_end=12
else
hour=tonumber(conky_parse("${time %H}"))
time_hms=conky_parse("${time %T}")
i_start=0
i_end=hours-1
end
--######################################################################
-- Gears ###############################################################
--######################################################################
if gears == 1 then
gear((center_x+45),(center_y+45),25,25,6,second,60,1,.75)
gear((center_x-45),(center_y+45),25,20,6,((minute*60)+second),(60*60),0,.75)
gear((center_x+45),(center_y-45),25,15,6,((hour*60)+(minute*60)+second),(60*60*60),1,.75)
gear((center_x-45),(center_y-45),25,10,6,((day_number*24)+(hour*60)+(minute*60)+second),(60*60*60*24),1,.75)
end
--######################################################################
-- Chrono ##############################################################
--######################################################################
if chrono == 1 then
--left weekday
cairo_set_line_width(cr,2)
cairo_arc(cr,(center_x-35),center_y,25,(0*d_math),(360*d_math))
cairo_arc_negative(cr,(center_x-35),center_y,12,(360*d_math),(0*d_math))
cairo_set_source_rgba(cr,bg_red,bg_green,bg_blue,bg_alpha)
cairo_fill(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,(center_x-35),center_y,25,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,(center_x-35),center_y,12,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_source_rgba(cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
for i=1,7 do
weekdays={"S","M","T","W","T","F","S"}
	x,y=pt((center_x-35),center_y,18.5,((360/7)*(i-1)))
	text({y=y,x=x,t=(weekdays[i]),hj="c",vj="m"})
end--for
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
cairo_stroke(cr)
weekday_position=(-90*d_math)+(((360/7)*weekday)*d_math)
cairo_set_line_width(cr,2)
cairo_move_to(cr,(center_x-35),center_y)
cairo_arc(cr,(center_x-35),center_y,20,weekday_position,weekday_position)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
--up month day
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,(center_y-35),25,(0*d_math),(360*d_math))
cairo_arc_negative(cr,center_x,(center_y-35),12,(360*d_math),(0*d_math))
cairo_set_source_rgba(cr,bg_red,bg_green,bg_blue,bg_alpha)
cairo_fill(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,(center_y-35),25,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,(center_y-35),12,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
month_days={31,28,31,30,31,30,31,31,30,31,30,31}
month_set=month_days[(month_number)]
for i=1,(month_set) do
month_day_marker=(-90*d_math)+(((360/month_set)*i)*d_math)
cairo_set_line_width(cr,1)
cairo_arc(cr,center_x,(center_y-35),25,month_day_marker,month_day_marker)
cairo_arc(cr,center_x,(center_y-35),20,month_day_marker,month_day_marker)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
end--for
cairo_set_source_rgba(cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
cairo_set_font_size (cr,8)
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
for i=1,(month_set) do
	if i == 5 or i == 10 or i == 15 or i == 20 or i == 25 or i == month_set then
	x,y=pt(center_x,(center_y-35),18.5,((360/month_set)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
cairo_stroke(cr)
day_indicator=(-90*d_math)+(((360/month_set)*day_number)*d_math)
cairo_set_line_width(cr,2)
cairo_move_to(cr,center_x,(center_y-35))
cairo_arc(cr,center_x,(center_y-35),20,day_indicator,day_indicator)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
--right year
cairo_set_line_width(cr,2)
cairo_arc(cr,(center_x+35),center_y,25,(0*d_math),(360*d_math))
cairo_arc_negative(cr,(center_x+35),center_y,12,(360*d_math),(0*d_math))
cairo_set_source_rgba(cr,bg_red,bg_green,bg_blue,bg_alpha)
cairo_fill(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,(center_x+35),center_y,25,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,(center_x+35),center_y,12,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
--when the year needs updated replace the start_year with the current year
start_year=13
cairo_set_font_size(cr,9)
cairo_set_source_rgba(cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
for i=1,4 do
	x,y=pt((center_x+35),center_y,18.5,((360/4)*i))
	text({y=y,x=x,t=(start_year+(i-1)),hj="c",vj="m"})
end--for
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
cairo_stroke(cr)
cairo_set_font_size (cr,d_font_size)
year_indicator=(-90*d_math)+(((360/4)*(year-(start_year-1)))*d_math)
cairo_set_line_width(cr,2)
cairo_move_to(cr,(center_x+35),center_y)
cairo_arc(cr,(center_x+35),center_y,20,year_indicator,year_indicator)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
--down month
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,(center_y+35),25,(0*d_math),(360*d_math))
cairo_arc_negative(cr,center_x,(center_y+35),12,(360*d_math),(0*d_math))
cairo_set_source_rgba(cr,bg_red,bg_green,bg_blue,bg_alpha)
cairo_fill(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,(center_y+35),25,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,(center_y+35),12,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
for i=1,12 do
month_indicator_marks=((360/12)*d_math)*i
cairo_set_line_width(cr,1)
cairo_arc(cr,center_x,(center_y+35),25,month_indicator_marks,month_indicator_marks)
cairo_arc(cr,center_x,(center_y+35),20,month_indicator_marks,month_indicator_marks)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
end--for
cairo_set_source_rgba(cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
for i=1,12 do
	if i == 3 or i == 6 or i == 9 or i == 12 then
	x,y=pt(center_x,(center_y+35),18,((360/12)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
cairo_stroke(cr)
month_indicator=(-90*d_math)+(((360/12)*month_number)*d_math)
cairo_set_line_width(cr,2)
cairo_move_to(cr,center_x,(center_y+35))
cairo_arc(cr,center_x,(center_y+35),20,month_indicator,month_indicator)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
end--chrono
--######################################################################
-- Face one ############################################################
--######################################################################
if clock_face == 1 then
--background
cairo_set_line_width(cr,5)
cairo_arc(cr,center_x,center_y,outer_radius,(-90*d_math),(270*d_math))
cairo_arc_negative(cr,center_x,center_y,(outer_radius-35),(270*d_math),(-90*d_math))
cairo_set_source_rgba(cr,bg_red,bg_green,bg_blue,bg_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
--seconds
second_radius1=outer_radius-2.5
second_radius2=second_radius1-10
for i=0,59 do
second_start=((i*(360/60))*d_math)
second_end=second_start+((360/60)*d_math)
second_start_math=(second_end-second_start)/2
second_start1=second_start-second_start_math-(90*d_math)
second_end1=second_start1+((360/60)*d_math)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,center_x,center_y,second_radius1,second_start1,second_end1)
cairo_arc_negative(cr,center_x,center_y,second_radius2,second_end1,second_start1)
cairo_close_path(cr)
if lights == 1 then
if i == second then
cairo_set_source_rgba(cr,lights_red,lights_green,lights_blue,lights_alpha)
cairo_fill_preserve(cr)
end
end--lights
cairo_set_source_rgba(cr,.25,.25,.25,1)
cairo_stroke(cr)
end--for seconds end
--minutes
for i=0,59 do
minute_radius=second_radius2-10
minute_start=((i*(360/60))*d_math)
minute_end=minute_start+((360/60)*d_math)
minute_start_math=(minute_end-minute_start)/2
minute_start1=minute_start-minute_start_math-(90*d_math)
minute_end1=minute_start1+((360/60)*d_math)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,center_x,center_y,second_radius2,minute_start1,minute_end1)
cairo_arc_negative(cr,center_x,center_y,minute_radius,minute_end1,minute_start1)
cairo_close_path(cr)
if lights == 1 then
if i == minute then
cairo_set_source_rgba(cr,lights_red,lights_green,lights_blue,lights_alpha)
cairo_fill_preserve(cr)
end
end--lights
cairo_set_source_rgba(cr,.25,.25,.25,1)
cairo_stroke(cr)
end--for minutes end
--hours
for i=i_start,i_end do
hour_radius=minute_radius-10
hour_start=((i*(360/hours))*d_math)
hour_end=hour_start+((360/hours)*d_math)
hour_start_math=((hour_end-hour_start)/2)
hour_start1=hour_start-hour_start_math-(90*d_math)
hour_end1=hour_start1+((360/hours)*d_math)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,center_x,center_y,minute_radius,hour_start1,hour_end1)
cairo_arc_negative(cr,center_x,center_y,hour_radius,hour_end1,hour_start1)
cairo_close_path(cr)
if lights == 1 then
if i == hour then
cairo_set_source_rgba(cr,lights_red,lights_green,lights_blue,lights_alpha)
cairo_fill_preserve(cr)
end
end--lights
cairo_set_source_rgba(cr,.25,.25,.25,1)
cairo_stroke(cr)
end--for hours end
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
if texts==1 then
cairo_set_source_rgba(cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
if hours==24 then
for i=0,23 do
	if i==0 or i==2 or i==4 or i==6 or i==8 or i==10 or i==12 or i==14 or i==16 or i==18 or i==20 or i==22 then
	x,y=pt(center_x,center_y,(hour_radius+5),((360/24)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
elseif hours==12 then
for i=1,12 do
	x,y=pt(center_x,center_y,(hour_radius+5),((360/12)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
end--for
end--hours
if seconds==5 then
for i=0,59 do
	if i==0 or i==5 or i==10 or i==15 or i==20 or i==25 or i==30 or i==35 or i==40 or i==45 or i==50 or i==55 then
	x,y=pt(center_x,center_y,(second_radius2),((360/60)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
elseif seconds==10 then
for i=0,59 do
	if i==0 or i==10 or i==20 or i==30 or i==40 or i==50 then
	x,y=pt(center_x,center_y,(second_radius2),((360/60)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
elseif seconds==15 then
for i=0,59 do
	if i==0 or i==15 or i==30 or i==45 then
	x,y=pt(center_x,center_y,(second_radius2),((360/60)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
end--second
cairo_stroke(cr)
end--texts
--######################################################################
-- mrpeacy code end ####################################################
--######################################################################
end--clock face one
--######################################################################
-- Face two ############################################################
--######################################################################
if clock_face == 2 then
hour_markers_radius=outer_radius-20
second_markers_radius=outer_radius-10
--background
cairo_set_line_width(cr,1)
cairo_arc(cr,center_x,center_y,outer_radius,(-90*d_math),(270*d_math))
cairo_arc_negative(cr,center_x,center_y,(hour_markers_radius-13),(270*d_math),(-90*d_math))
cairo_set_source_rgba(cr,bg_red,bg_green,bg_blue,bg_alpha)
cairo_fill(cr)
cairo_set_line_width(cr,5)
cairo_arc(cr,center_x,center_y,outer_radius,(-90*d_math),(270*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,center_y,(hour_markers_radius-13),(-90*d_math),(270*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
if texts==1 then
cairo_set_source_rgba(cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
if hours==24 then
for i=0,23 do
	if i==0 or i==2 or i==4 or i==6 or i==8 or i==10 or i==12 or i==14 or i==16 or i==18 or i==20 or i==22 then
	x,y=pt(center_x,center_y,(hour_markers_radius-5),((360/24)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
elseif hours==12 then
for i=1,12 do
	x,y=pt(center_x,center_y,(hour_markers_radius-5),((360/12)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
end--for
end--hours
if seconds==5 then
for i=0,59 do
	if i==0 or i==5 or i==10 or i==15 or i==20 or i==25 or i==30 or i==35 or i==40 or i==45 or i==50 or i==55 then
	x,y=pt(center_x,center_y,second_markers_radius,((360/60)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
elseif seconds==10 then
for i=0,59 do
	if i==0 or i==10 or i==20 or i==30 or i==40 or i==50 then
	x,y=pt(center_x,center_y,second_markers_radius,((360/60)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
elseif seconds==15 then
for i=0,59 do
	if i==0 or i==15 or i==30 or i==45 then
	x,y=pt(center_x,center_y,second_markers_radius,((360/60)*i))
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
end--for
end--seconds
cairo_stroke(cr)
end--texts
--######################################################################
-- mrpeacy code end ####################################################
--######################################################################
--second lights
sl_math1=(-90*d_math)+(((360/60)*second)*d_math)
if lights ==1 then
cairo_set_line_width(cr,3)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,hour_markers_radius,(-90*d_math),sl_math1)
cairo_set_source_rgba(cr,lights_red,lights_green,lights_blue,lights_alpha)
cairo_stroke(cr)
end--lights
--minute
for i=1,60 do
second_markers_position=(-90*d_math)+((i*(360/60))*d_math)
cairo_set_line_width(cr,d_line_width)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_BUTT)
cairo_arc(cr,center_x,center_y,outer_radius,second_markers_position,second_markers_position)
cairo_arc(cr,center_x,center_y,second_markers_radius,second_markers_position,second_markers_position)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
if lights == 1 then
if i == minute then
cairo_set_line_width(cr,6)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,(outer_radius-2),second_markers_position,second_markers_position)
cairo_arc(cr,center_x,center_y,(second_markers_radius-5),second_markers_position,second_markers_position)
cairo_set_source_rgba(cr,lights_red,lights_green,lights_blue,lights_alpha)
cairo_stroke(cr)
end--minute
end--lights
end--for
--hour
for i=i_start,i_end do
hour_markers_position=(-90*d_math)+(i*(360/hours))*d_math
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,center_x,center_y,outer_radius,hour_markers_position,hour_markers_position)
cairo_arc(cr,center_x,center_y,hour_markers_radius,hour_markers_position,hour_markers_position)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
if lights == 1 then
if i == hour then
cairo_set_line_width(cr,6)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,(outer_radius-2),hour_markers_position,hour_markers_position)
cairo_arc(cr,center_x,center_y,(hour_markers_radius-5),hour_markers_position,hour_markers_position)
cairo_set_source_rgba(cr,lights_red,lights_green,lights_blue,lights_alpha)
cairo_stroke(cr)
end--hour
end--lights
end--for hour
--outer ring
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,center_x,center_y,outer_radius,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
end--clock face two
--######################################################################
-- Hands ###############################################################
--######################################################################
if hands == 1 then
hour_hand_radius1=outer_radius-30
hour_hand_radius2=outer_radius-50
hour_position=(-90*d_math)+(((360/(hours*60*60))*((hour*60*60)+(minute*60)+second))*d_math)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,center_x,center_y,10,(hour_position-(20*d_math)),(hour_position+(20*d_math)))
cairo_arc(cr,center_x,center_y,hour_hand_radius2,(hour_position+(5*d_math)),(hour_position+(5*d_math)))
cairo_arc(cr,center_x,center_y,hour_hand_radius1,hour_position,hour_position)
cairo_arc(cr,center_x,center_y,hour_hand_radius2,(hour_position-(5*d_math)),(hour_position-(5*d_math)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,hands_ired,hands_igreen,hands_iblue,hands_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,hands_red,hands_green,hands_blue,hands_alpha)
cairo_stroke(cr)
minute_hand_radius1=outer_radius-15
minute_hand_radius2=outer_radius-35
minute_position=(-90*d_math)+(((360/(60*60))*((minute*60)+second))*d_math)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,center_x,center_y,10,(minute_position-(20*d_math)),(minute_position+(20*d_math)))
cairo_arc(cr,center_x,center_y,minute_hand_radius2,(minute_position+(5*d_math)),(minute_position+(5*d_math)))
cairo_arc(cr,center_x,center_y,minute_hand_radius1,minute_position,minute_position)
cairo_arc(cr,center_x,center_y,minute_hand_radius2,(minute_position-(5*d_math)),(minute_position-(5*d_math)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,hands_ired,hands_igreen,hands_iblue,hands_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,hands_red,hands_green,hands_blue,hands_alpha)
cairo_stroke(cr)
second_hand_radius=outer_radius-5
second_position=(-90*d_math)+(((360/60)*second)*d_math)
cairo_set_line_width(cr,2)
cairo_move_to(cr,center_x,center_y)
cairo_arc(cr,center_x,center_y,second_hand_radius,second_position,second_position)
cairo_set_source_rgba(cr,hands_red,hands_green,hands_blue,hands_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,1)
cairo_arc(cr,center_x,center_y,10,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,.5,.5,.5,1)
cairo_stroke(cr)
--am & pm
if hours == 12 then
cairo_select_font_face (cr,d_font,d_font_slant,d_font_face);
cairo_set_font_size (cr,10)
cairo_set_source_rgba (cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
cairo_move_to (cr,(center_x-6.25),(center_y+3.25))
cairo_show_text (cr,ampm)
cairo_stroke (cr)
else
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,center_y,5,(0*d_math),(360*d_math))
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_fill(cr)
end--am & pm
end-- hands
--######################################################################
-- Digital #############################################################
--######################################################################
if digital == 1 then
ph=15
pw=40
p1x=center_x-pw
p1y=center_y-ph
p2x=center_x+pw
p2y=center_y+ph
pr=10
cairo_set_line_width(cr,2)
cairo_arc(cr,p1x,p1y,pr,(180*d_math),(270*d_math))
cairo_arc(cr,p2x,p1y,pr,(270*d_math),0)
cairo_arc(cr,p2x,p2y,pr,0,(90*d_math))
cairo_arc(cr,p1x,p2y,pr,(90*d_math),(180*d_math))
cairo_close_path(cr)
cairo_set_source_rgba(cr,bg_red,bg_green,bg_blue,bg_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
for i=1,4 do
line=6
x1=center_x-40
y1=center_y-line
x2=center_x
y2=center_y-line
x3=center_x+25
y3=center_y-line
x4=center_x-45
y4=center_y+15
if hours == 12 then time_s=14 else time_s=18 end
s={16,d_font_size,d_font_size,time_s}
x={x1,x2,x3,x4}
y={y1,y2,y3,y4}
t={day,abbr_month,day_number,time_hms}
cairo_select_font_face (cr,d_font,d_font_slant,d_font_face);
cairo_set_font_size (cr,s[i])
cairo_set_source_rgba (cr,d_font_red,d_font_green,d_font_blue,d_font_alpha)
cairo_move_to (cr,x[i],y[i])
cairo_show_text (cr,t[i])
cairo_stroke (cr)
end--for
end--digital
--######################################################################
--######################################################################
--######################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
--######################################################################
--Functions ############################################################
--######################################################################
function gear(position_x,position_y,radius,outer_teeth,inner_teeth,speed,speed_scale,direction,visibility)
gear_red=.75
gear_green=.75
gear_blue=.75
gear_line_width=4
gear_math=(math.pi/180)
gear_start=0
gear_end=360*gear_math
outer_teeth_radius=(radius)+gear_line_width
inner_radius=10
inner_teeth_radius=inner_radius+gear_line_width
--outer gear
cairo_set_line_width(cr,gear_line_width)
cairo_set_source_rgba(cr,gear_red,gear_green,gear_blue,(visibility))
cairo_arc(cr,(position_x),(position_y),(radius),gear_start,gear_end)
cairo_stroke(cr)
--outer gear teeth
for i=1,(outer_teeth) do
tooth_size=(360/(outer_teeth))/3
tooth_space=(360/(outer_teeth))
tooth_math=(((i-1)*tooth_space)+tooth_size)*gear_math
tooth_math2=(((360/(speed_scale))*(speed))*gear_math)
if (direction) == 1 then tooth=tooth_math+tooth_math2 else tooth=tooth_math-tooth_math2 end
teeth_s=tooth-((tooth_size/2)*gear_math)
teeth_e=tooth+((tooth_size/2)*gear_math)
cairo_set_line_width(cr,gear_line_width)
cairo_arc(cr,(position_x),(position_y),outer_teeth_radius,teeth_s,teeth_e)
cairo_set_source_rgba(cr,gear_red,gear_green,gear_blue,(visibility))
cairo_stroke(cr)
end--for loop
--inner gear
cairo_set_line_width(cr,gear_line_width)
cairo_set_source_rgba(cr,gear_red,gear_green,gear_blue,(visibility))
cairo_arc(cr,(position_x),(position_y),inner_radius,gear_start,gear_end)
cairo_stroke(cr)
--inner gear teeth
for i=1,(inner_teeth) do
tooth_size=(360/(inner_teeth))/3
tooth_space=(360/(inner_teeth))
tooth_math=(((i-1)*tooth_space)+tooth_size)*gear_math
tooth_math2=(((360/(speed_scale))*(speed))*gear_math)
if (direction) == 1 then tooth=tooth_math+tooth_math2 else tooth=tooth_math-tooth_math2 end
teeth_s=tooth-((tooth_size/2)*gear_math)
teeth_e=tooth+((tooth_size/2)*gear_math)
cairo_set_line_width(cr,gear_line_width)
cairo_arc(cr,(position_x),(position_y),inner_teeth_radius,teeth_s,teeth_e)
cairo_set_source_rgba(cr,gear_red,gear_green,gear_blue,(visibility))
cairo_stroke(cr)
end--for loop
end
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
function pt(px,py,prad,pdeg)
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1
end
function font(fontt)
local name=fontt.f	or default_font_name	or "mono"
local size=fontt.fs	or default_font_size	or 12
local face=fontt.ff	or default_font_face	or "n"
if face=="n" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="b" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
elseif face=="i" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="bi" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD)
end
cairo_set_font_size(cr,size)
end
function hexcolor(hexcolort)
local col=hexcolort.c	or default_hex_color	or 0xffffff
local a=hexcolort.a	or default_alpha	or 1
local r,g,b=((col/0x10000) % 0x100)/255,((col/0x100) % 0x100)/255,(col % 0x100)/255
cairo_set_source_rgba(cr,r,g,b,a)
end
function text(textt)
local x=textt.x 		or 100
local y=textt.y 		or 100
local t=textt.t 		or "set txt"
local hj=textt.hj 		or default_horizontal_justify		or "l"
local vj=textt.vj 		or default_vertical_justify		or "n"
local r=textt.r			or default_rotation			or 0
cairo_text_extents(cr,t,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
--hl-- l=left, c=center, r=right
if hj=="l" then
xa=x-bx
rad=0
elseif hj=="c" then
xa=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
xa=x-wx
rad=wx-bx
else
print ('hj not set correctly for text: '..t..' - "l", "c" or "r"')
xa=0
rad=0
end
--vj-- n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
ya=y
rad2=0
ry=by
elseif vj=="nb" then
ya=y-by
rad2=-by
ry=by
elseif vj=="m" then
ya=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
ya=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
ya=y+hy-by
rad2=hy-by
ry=0+by
else
print ('vj not set correctly for text: '..t..' - "n", "nb", "m", "mb" or "t"')
ya=0
rad2=0
ry=0
end
--rotation
if r~=0 then
local x2,y2=pt(x,y,rad2,r-180)
local x1,y1=pt(x2,y2,rad,r-90)
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*r)
cairo_show_text (cr,t)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,xa,ya)
cairo_show_text (cr,t)
cairo_stroke (cr)
end--if ro
--set non local variables to nil
xa=nil;ya=nil;rad=nil;rad2=nil;ry=nil
end--function text #####################################################

And how to do work?
That it does not work.
Or that there is not enough in the kit?
Help, please.

Offline

#4771 2013-02-19 15:55:57

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

Re: The New Monster Conky Thread

hello

is it possible to grab the 'picture of the day' from this site: http://spacetelescope.org/

unfortunately the owner of this site doesn't offer a rss-feed. but i do not want to visit the site once a day sad this would be very cool for all people that are astronomy-fans like me.

regards, alex

Offline

#4772 2013-02-19 16:10:23

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,087
Website

Re: The New Monster Conky Thread

timius1 wrote:

And how to do work?
That it does not work.
Or that there is not enough in the kit?
Help, please.

Hi timius ...

It works fine, I call it: AoN_Clock.lua - set your path|name accordingly and call it up.
You will need "minimum_size 210 210" if using the clock alone.

### AoN Clock ################################################################
lua_load /media/5/Conky/LUA/AoN_Clock.lua
lua_draw_hook_pre clock
#lua_draw_hook_post clock
################################################################## End LUA ###
minimum_size 210 210     ## width, height
maximum_width 210       ## width
update_interval 1

### A minimum of one blank line after TEXT is required
TEXT
1
2
3
4
5
6
7
8
9
0
1
2 more code here line 12

For the clock alone, one blank line after TEXT is required
The default text size you use regulates the number of lines down to start the rest of your conky if you wish, mine is 12

abix5cqD.jpg

Last edited by Sector11 (2013-02-19 16:11:28)


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Offline

#4773 2013-02-19 19:45:03

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: The New Monster Conky Thread

@Sector11 Thank you for taking care of that question


You can find my work here

Make everything ok button

Offline

#4774 2013-02-19 21:08:54

ragamatrix
#! CrunchBanger
From: Horgen Switzerland
Registered: 2012-12-05
Posts: 232

Re: The New Monster Conky Thread

Hi all;
I'd like to display theses clock hands and manage the size and color:
hands
on this clock:
earthclock
There are both lua script but I'm not good enaugh to do that.
Help apreciate thanx

Last edited by ragamatrix (2013-02-19 21:21:05)

Offline

Help fund CrunchBang, donate to the project!

#4775 2013-02-19 23:00:51

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: The New Monster Conky Thread

ragamatrix wrote:

Hi all;
I'd like to display theses clock hands and manage the size and color:
hands
on this clock:
earthclock
There are both lua script but I'm not good enaugh to do that.
Help apreciate thanx

They look like my multi-face clock hands in a different color. If they are then just cut and paste the hands code and change second, minute, and hour to the correct string that has those values.

The original strings are

second=tonumber(conky_parse("${time %S}"))
minute=tonumber(conky_parse("${time %M}"))
hour=tonumber(conky_parse("${time %H}"))


You can find my work here

Make everything ok button

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.

Debian Logo