SEARCH

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

You are not logged in.

#3576 2012-11-04 04:03:17

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

Re: Conky v1.9 Thread

McLovin wrote:
Sector11 wrote:

A Knight Rider Conky?

That is 100% correct, I'm working on the wallpaper for it now, I'm making a complete custom wallpaper to work with it, this is gonna be a long time in progress set-up, but once it's done, it's gonna be one killer conky/desktop, all inclusive, and stupidly silly.

You gotta hook "aoogha chukka" in there someplace!

NICE call mrpeachy, have not heard that in years and totally forgot about it.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

Help fund CrunchBang, donate to the project!

#3577 2012-11-04 04:06:26

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

Re: Conky v1.9 Thread

techboywii wrote:

I am kinda new to this forum and #! in general, but here is my Conky config. Hope you like it tongue

http://i.imgur.com/8M925.png

Welcome to #!.  Enjoy your stay - stick around here and you'll be addicted.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#3578 2012-11-04 04:09:56

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

Re: Conky v1.9 Thread

Ohhhhhhh Night Rider conky............

Now that caught my attention!  big_smile

Offline

#3579 2012-11-04 04:30:10

GotSupreme
Banned
Registered: 2012-09-12
Posts: 114

Re: Conky v1.9 Thread

VastOne wrote:

^ On how to copy and paste? 

Once you find the conky code you want to use, just create a new file in your editor and copy the content of the conky into it

Save it as  /home/your user name/.conkyrcnew

Then run it like this

conky -c .conkyrcnew

Edit - You may need to kill all conky files before running the above

killall conky

tyler@crunchbang:~$ conky -c .conkyrc
Conky: .conkyrc: 3: no such configuration: 'border_margin'
Conky: desktop window (af) is root window
Conky: window type - normal
Conky: drawing to created window (0x3000001)
Conky: drawing to double buffer
Conky: obj->data.i 2 info.cpu_count 1
Conky: attempting to use more CPUs than you have!
tyler@crunchbang:~$

?

Offline

#3580 2012-11-04 04:43:58

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

Re: Conky v1.9 Thread

alrigth I have begun my first lua project and yeah...

so here is my error out of terminal:
Conky: llua_do_call: function conky_main execution failed: /home/justin/projects/Conky/Lua/debiancpugauge.lua:22: attempt to call global 'cairo_source_rgba' (a nil value)
here is the lua that I am testing:  (i have been following Mr peachy's guide and messed up)

--this lua script for use in conky
require 'cairo'

function conky_main()
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
--################################
--text settings
font="Mono"
font_size=12
text="hello world"
xpos,ypos=100,100
red,green,blue,alpha=1,1,1,1
font_slant=CAIRO_FONT_SLANT_NORMAL
font_face=CAIRO_FONT_WEIGHT_NORMAL
----------------------------------
cairo_select_font_face (cr, font, font_slant, font_face);
cairo_set_font_size (cr, font_size)
cairo_source_rgba (cr,red,green,blue,alpha)
cairo_move_to (cr,xpos,ypos)
cairo_show_text (cr,text)
cairo_stroke (cr)

--################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function

and here is that conky, just in case you need it.

##############################################
# Settings
##############################################
background yes
use_xft yes
xftfont Liberation Sans:size=9
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent no
own_window_colour 000000
##############################################
# Compositing tips:
# Conky can play strangely when used with
# different compositors. I have found the
# following to work well, but your mileage
# may vary. Comment/uncomment to suit.
##############################################
## no compositor
#own_window_type override
#own_window_argb_visual yes

## xcompmgr
#own_window_type override
#own_window_argb_visual yes

## cairo-compmgr
own_window_type desktop
own_window_argb_visual yes
##############################################
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 200
maximum_width 500
draw_shades no
draw_outline no
draw_borders yes
draw_graph_borders yes
default_color 656667
default_shade_color 000000
default_outline_color 828282
alignment bottom_right
gap_x 6
gap_y 6
no_buffers yes
uppercase no
cpu_avg_samples 1
override_utf8_locale no
##############################################
#  Lua
##############################################
lua_load /home/justin/projects/Conky/Lua/debiancpugauge.lua
lua_draw_hook_post conky_main
##############################################
#  Output
##############################################
TEXT
${cpu}

Last edited by ansem_of_nexus (2012-11-04 04:47:09)


You can find my work here

Make everything ok button

Offline

#3581 2012-11-04 05:22:34

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

Re: Conky v1.9 Thread

^just a typo

cairo_source_rgba (cr,red,green,blue,alpha)

should be

cairo_set_source_rgba (cr,red,green,blue,alpha)

which i assume is line 22 of your script smile

Last edited by mrpeachy (2012-11-04 05:23:20)

Offline

#3582 2012-11-04 05:24:44

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

Re: Conky v1.9 Thread

Sector11 wrote:
McLovin wrote:
Sector11 wrote:

A Knight Rider Conky?

That is 100% correct, I'm working on the wallpaper for it now, I'm making a complete custom wallpaper to work with it, this is gonna be a long time in progress set-up, but once it's done, it's gonna be one killer conky/desktop, all inclusive, and stupidly silly.

You gotta hook "aoogha chukka" in there someplace!

NICE call mrpeachy, have not heard that in years and totally forgot about it.

its not often that i get the chance to promote Mr Hasselhoff's masterpiece  big_smile

Offline

#3583 2012-11-04 05:46:49

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

Re: Conky v1.9 Thread

mrpeachy wrote:

^just a typo

cairo_source_rgba (cr,red,green,blue,alpha)

should be

cairo_set_source_rgba (cr,red,green,blue,alpha)

which i assume is line 22 of your script smile

You sir are scary, in a good way. Thank you, all fixed and yes it is line 22. Now I can go back to my work.


You can find my work here

Make everything ok button

Offline

#3584 2012-11-04 06:23:53

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

Re: Conky v1.9 Thread

hey question, what is the easiest way to draw a spiral in lua, I did some arcs... It looks terrible, is there a better way?


You can find my work here

Make everything ok button

Offline

#3585 2012-11-04 06:41:19

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

Re: Conky v1.9 Thread

here is some a spiral drawing code

--local function calculates points
local 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
--center point
cx,cy=200,200
--radius and degree increments
rad_i=1
deg_i=10
max_i=100
--set line attributes
cairo_set_source_rgba(cr,1,1,1,1)
cairo_set_line_width(cr,1)
--draw points 
for i=1,max_i do
rad1=i*rad_i
deg1=i*deg_i
x1,y1=pt(cx,cy,rad1,deg1)
rad2=rad_i*((i+1) or i)
deg2=deg_i*((i+1) or i)
x2,y2=pt(cx,cy,rad2,deg2)
cairo_move_to(cr,x1,y1)
cairo_line_to(cr,x2,y2)
cairo_stroke(cr)
end

edit - changed code a little

and the resulting spiral:
Screenshot_at_2012_11_04_01_37_27.jpg

the mathematics may be more complicated depending on what type of spiral you are after
change:
rad_i
deg_i
max_i

to get different spirals

Last edited by mrpeachy (2012-11-04 06:57:23)

Offline

#3586 2012-11-04 07:24:28

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

Re: Conky v1.9 Thread

thanks, that will make my life so much easier. One last question on the spiral... Till I screw it up. Is it possible to make it go backwards so I can try and make the debian symbol?


You can find my work here

Make everything ok button

Offline

#3587 2012-11-04 07:28:46

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

Re: Conky v1.9 Thread

you can set deg_i to a negative number to get an anticlockwise spiral... you may need some additional math to get an exact debian spiral however... ill see what i can do

Offline

#3588 2012-11-04 07:35:13

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

Re: Conky v1.9 Thread

mrpeachy wrote:

you can set deg_i to a negative number to get an anticlockwise spiral... you may need some additional math to get an exact debian spiral however... ill see what i can do

Thank you, I am trying to make the debian symbol to later turn into a bar that can be use for file system, ram or cpu usage. My other thought was the crunchBang symbol of #! Which is probably easier.


You can find my work here

Make everything ok button

Offline

#3589 2012-11-04 07:42:01

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

Re: Conky v1.9 Thread

the problem is that the debian "swirl" doesn't look like a mathematical spiral.. you may be able to get close however

also in the section where i set line attributes
if you want to use thicker lines add this

cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)

Offline

#3590 2012-11-04 07:48:14

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

Re: Conky v1.9 Thread

here is an approximation of the debian swirl
Screenshot_at_2012_11_04_01_47_28.jpg

local 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
--center point
cx,cy=200,200
--radius and degree increments
start_deg=-250
rad_i=1
deg_i=-8
min_i=12
max_i=80
--set line attributes
col("red")
cairo_set_line_width(cr,5)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
--draw points 
for i=min_i,max_i do
rad1=(i*1)*rad_i
deg1=start_deg+((i*1)*deg_i)
x1,y1=pt(cx,cy,rad1,deg1)
rad2=rad_i*(((i+1) or i)*1)
deg2=start_deg+(deg_i*(((i+1) or i)*1))
x2,y2=pt(cx,cy,rad2,deg2)
cairo_move_to(cr,x1,y1)
cairo_line_to(cr,x2,y2)
cairo_stroke(cr)
end

Offline

#3591 2012-11-04 08:40:25

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

Re: Conky v1.9 Thread

thanks to sector11 and his color list which i found here
http://ubuntuforums.org/showpost.php?p= … ount=20616

i thought i would try and implement the list in lua, usable by typing the names
and it worked big_smile
Screenshot_at_2012_11_04_02_35_20.jpg

here is the colorname function

function colorname(col)
local cnametab={
indianred={205,92,92},
lightcoral={240,128,128},
salmon={250,128,114},
darksalmon={233,150,122},
lightsalmon={255,160,122},
crimson={220,20,60},
red={255,0,0},
firebrick={178,34,34},
darkred={139,0,0},
pink={255,192,203},
lightpink={255,182,193},
hotpink={255,105,180},
deeppink={255,20,147},
mediumvioletred={199,21,133},
palevioletred={219,112,147},
lightsalmon={255,160,122},
coral={255,127,80},
tomato={255,99,71},
orangered={255,69,0},
darkorange={255,140,0},
orange={255,165,0},
gold={255,215,0},
yellow={255,255,0},
lightyellow={255,255,224},
lemonchiffon={255,250,205},
lightgoldenrodyellow={250,250,210},
papayawhip={255,239,213},
moccasin={255,228,181},
peachpuff={255,218,185},
palegoldenrod={238,232,170},
khaki={240,230,140},
darkkhaki={189,183,107},
lavender={230,230,250},
thistle={216,191,216},
plum={221,160,221},
violet={238,130,238},
orchid={218,112,214},
fuchsia={255,0,255},
magenta={255,0,255},
mediumorchid={186,85,211},
mediumpurple={147,112,219},
blueviolet={138,43,226},
darkviolet={148,0,211},
darkorchid={153,50,204},
darkmagenta={139,0,139},
purple={128,0,128},
indigo={75,0,130},
slateblue={106,90,205},
darkslateblue={72,61,139},
mediumslateblue={123,104,238},
greenyellow={173,255,47},
chartreuse={127,255,0},
lawngreen={124,252,0},
lime={0,255,0},
limegreen={50,205,50},
palegreen={152,251,152},
lightgreen={144,238,144},
mediumspringgreen={0,250,154},
springgreen={0,255,127},
mediumseagreen={60,179,113},
seagreen={46,139,87},
forestgreen={34,139,34},
green={0,128,0},
darkgreen={0,100,0},
yellowgreen={154,205,50},
olivedrab={107,142,35},
olive={128,128,0},
darkolivegreen={85,107,47},
mediumaquamarine={102,205,170},
darkseagreen={143,188,143},
lightseagreen={32,178,170},
darkcyan={0,139,139},
teal={0,128,128},
aqua={0,255,255},
cyan={0,255,255},
lightcyan={224,255,255},
paleturquoise={175,238,238},
aquamarine={127,255,212},
turquoise={64,224,208},
mediumturquoise={72,209,204},
darkturquoise={0,206,209},
cadetblue={95,158,160},
steelblue={70,130,180},
lightsteelblue={176,196,222},
powderblue={176,224,230},
lightblue={173,216,230},
skyblue={135,206,235},
lightskyblue={135,206,250},
deepskyblue={0,191,255},
dodgerblue={30,144,255},
cornflowerblue={100,149,237},
mediumslateblue={123,104,238},
royalblue={65,105,225},
blue={0,0,255},
mediumblue={0,0,205},
darkblue={0,0,139},
navy={0,0,128},
midnightblue={25,25,112},
cornsilk={255,248,220},
blanchedalmond={255,235,205},
bisque={255,228,196},
navajowhite={255,222,173},
wheat={245,222,179},
burlywood={222,184,135},
tan={210,180,140},
rosybrown={188,143,143},
sandybrown={244,164,96},
goldenrod={218,165,32},
darkgoldenrod={184,134,11},
peru={205,133,63},
chocolate={210,105,30},
saddlebrown={139,69,19},
sienna={160,82,45},
brown={165,42,42},
maroon={128,0,0},
white={255,255,255},
snow={255,250,250},
honeydew={240,255,240},
mintcream={245,255,250},
azure={240,255,255},
aliceblue={240,248,255},
ghostwhite={248,248,255},
whitesmoke={245,245,245},
seashell={255,245,238},
beige={245,245,220},
oldlace={253,245,230},
floralwhite={255,250,240},
ivory={255,255,240},
antiquewhite={250,235,215},
linen={250,240,230},
lavenderblush={255,240,245},
mistyrose={255,228,225},
gainsboro={220,220,220},
lightgrey={211,211,211},
silver={192,192,192},
darkgray={169,169,169},
gray={128,128,128},
dimgray={105,105,105},
lightslategray={119,136,153},
slategray={112,128,144},
darkslategray={47,79,79},
black={0,0,0},
}
local ctab=cnametab[string.lower(col)]
cairo_set_source_rgba(cr,ctab[1]/255,ctab[2]/255,ctab[3]/255,1)
end

use it like this in the main lua function

colorname("ghostwhite")

case doesnt matter when you type the name in as the function converts everything to lowercase anyway
so this also works

colorname("GhostWhite")

need to tweak a tiny bit to allow adjustment of alpha

it would also be easy to add your own custom colors to the list as long as the name was unique

Last edited by mrpeachy (2012-11-04 08:57:07)

Offline

#3592 2012-11-04 09:06:51

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

Re: Conky v1.9 Thread

^ here is one fix for your name possible needs.. and more colors than you need, I bet
500+ colors


You can find my work here

Make everything ok button

Offline

#3593 2012-11-04 09:11:16

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

Re: Conky v1.9 Thread

^nice list, should be easy enough to convert to a lua table smile
but would have to get rid of the spaces in the names

Offline

#3594 2012-11-04 09:14:40

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

Re: Conky v1.9 Thread

mrpeachy wrote:

^nice list, should be easy enough to convert to a lua table smile
but would have to get rid of the spaces in the names

Could replace all the spaces with _, then it should be fine, a simple "find and replace" move I would think


You can find my work here

Make everything ok button

Offline

#3595 2012-11-04 09:23:37

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 13,970

Re: Conky v1.9 Thread

mrpeachy wrote:

the problem is that the debian "swirl" doesn't look like a mathematical spiral.. you may be able to get close however

I'm not a regular participant in this thread, but I had to jump in here - the Debian swirl looks very close to a logarithmic spiral to me. wink  Surely Lua can handle logs?

Offline

#3596 2012-11-04 15:53:09

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

Re: Conky v1.9 Thread

mrpeachy wrote:

thanks to sector11 and his color list which i found here
http://ubuntuforums.org/showpost.php?p= … ount=20616

OH that neat mrpeachy.  Can that be added to any LUA? stroke that out I see it can  :D

Can't remember where I got it but the interesting thing with that list is it said you could use the "names directly in conky"
Obviously I haven't tried them all and as most people know I prefer this format:

###  Color Settings  #########################################################
draw_shades no
default_shade_color black

draw_outline no # amplifies text if yes
default_outline_color black
default_color DCDCDC #220 220 220	Gainsboro

color0 8FBC8F #143 188 143	DarkSeaGreen
color1 778899 #119 136 153	LightSlateGray
color2 FF8C00 #255 140   0	DarkOrange
color3 7FFF00 #127 255   0	Chartreuse
color4 FFA07A #255 160 122	LightSalmon
color5 FFDEAD #255 222 173	NavajoWhite
color6 00BFFF #  0 191 255	DeepSkyBlue
color7 00FFFF #  0 255 255	Cyan
color8 FFFF00 #255 255   0	Yellow
color9 B22222 #178  34  34	FireBrick
#####################################################  End Color Settings  ###

I like it because it has the hex code and the decimal code.  It's helped me with LUA color.

I have a little archive: Conky_Tips_N_Tricks.tar.gz that creates a folder and has these in it if anyone is interested:

  • Conky_Tips_N_Tricks/ASCII_2.txt - some cut/paste ASCII characters

  • Conky_Tips_N_Tricks/colours_code.txt - older version of above

  • Conky_Tips_N_Tricks/colours_web_safe_2.txt - see above

  • Conky_Tips_N_Tricks/Time_2.txt - all the ${time optiona}

  • Conky_Tips_N_Tricks/tztime.txt - timezones for conky

  • Conky_Tips_N_Tricks/weather.command.txt - that elusive ${weather options} command

  • Conky_Tips_N_Tricks/World_Time_Zones.txt - more time zones.

Last edited by Sector11 (2012-11-04 15:57:59)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#3597 2012-11-04 16:44:47

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

Re: Conky v1.9 Thread

do u have an idea why the value for incoming connections does not work?

screenshot

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbanglinux.org/forums/topic/16100/weather-in-conky/

 the file:
 http://dl.dropbox.com/u/19008369/weatheragain9000.lua.tar.gz

 mrppeachys LUA Tutorial
 http://crunchbanglinux.org/forums/topic/17246/how-to-using-lua-scripts-in-conky/
]]

_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="PF Tempesta Seven" --font must be in quotes
default_font_size=8
default_color=0xffffff --white
default_alpha=1 --fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE

local posx=0
local posy=170
local hell=dnc(0xd1cf3d,0x988a8a)
local dunkel=dnc(0xa3a23f,0x988a8a)
local farbe_head=dnc(0xaa6028,0xb3a7a7)

--[[
-- actual date
local datum=now["day_lc"]..", "..dropZero(now["date"])..". "..now["month_lc"].." "..now["year"]
xout({x=posx,y=220,c=dunkel,txt=datum})

-- aktuelle Temperatur
xout({x=240,y=240,c=hell,txt='h:'})
xout({x=260,y=240,c=hell,txt=high_temp[1]})

-- gefühlte Temperatur
xout({x=240,y=255,c=hell,txt='t:'})
xout({x=260,y=255,c=hell,txt=low_temp[1]})

-- Niederschlagswahrscheinlichkeit
xout({x=295,y=240,c=hell,txt='n:'})
xout({x=330,y=240,c=hell,txt=precipitation[1]..'%',j='r'})

-- Bewölkungswahrscheinlichkeit
xout({x=295,y=255,c=hell,txt='b:'})
xout({x=330,y=255,c=hell,txt=cloud_cover[1]..'%',j='r'})

xout({x=0,y=240,c=dunkel,txt=now["conditions_short_lc"]})

-- Windgeschwindigkeit
local windgeschw=wind_speed_text(now['wind_km'])
xout({x=0,y=255,c=dunkel,txt=string.lower(windgeschw)})



--moon phase
local laenge_mond=moon_phase_lc[1]
xout({x=330,y=275,c=hell,txt=laenge_mond,j='r'})


-- #################################################################
-- ### Trennlinien zeichnen ########################################
-- #################################################################

local abstandhalter=10
local position_1=laenge(datum)+abstandhalter
local position_2=320-(laenge(laenge_mond)+abstandhalter)
local position_3=laenge(ueberschrift)+abstandhalter

--linie(1,position_3,320,28,28) -- linie news
-- linie(breite,posx_1,posx_2,posy_1,posy_2)

linie(1,position_1,330,215,215) -- linie wetter datum
-- linie(breite,posx_1,posx_2,posy_1,posy_2)

linie(1,0,position_2,270,270) -- linie mondphase
-- linie(breite,posx_1,posx_2,posy_1,posy_2)
]]--

-- Sonne
xout({x=190,y=10,c=dunkel,txt='sonne:'})
xout({x=260,y=10,c=hell,txt=dropZero(sun_rise_24[1]),j='r'})
xout({x=330,y=10,c=hell,txt=dropZero(sun_set_24[1])..' uhr',j='r'})

xout({x=270,y=10,c=dunkel,txt='<'})
xout({x=275,y=10,c=hell,txt='>'})

-- Mond
xout({x=190,y=25,c=dunkel,txt='mond:'})
xout({x=260,y=25,c=hell,txt=dropZero(moon_rise_24[1]),j='r'})
xout({x=330,y=25,c=hell,txt=dropZero(moon_set_24[1])..' uhr',j='r'})

xout({x=270,y=25,c=dunkel,txt='<'})
xout({x=275,y=25,c=hell,txt='>'})

xout({x=190,y=40,c=dunkel,txt='aktuelle temp.:'})
xout({x=300,y=40,c=hell,txt=now["temp"]..'°',j='r'})
xout({x=330,y=40,c=hell,txt=' /  '..now["feels_like"]..'°',j='r'})

-- #################################################################
-- ## Conky-Befehle ################################################
-- #################################################################

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

--xout({x=190,y=50,c=dunkel,txt='systemmonitor:'})



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

local zeit=conky_parse('${time %T}')

xout({x=190,y=85,c=dunkel,txt='uhrzeit:'})
xout({x=330,y=85,c=hell,txt=dropZero(zeit)..' uhr',j='r'})

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

local ram=conky_parse('${uptime}')

xout({x=190,y=100,c=dunkel,txt='uptime:'})
xout({x=330,y=100,c=hell,txt=ram,j='r'})

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

local ram=conky_parse('${memmax}')

xout({x=190,y=115,c=dunkel,txt='ram:'})
xout({x=330,y=115,c=hell,txt=aendern(ram,'mb').." total",j='r'})

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

local cpu_core_1=conky_parse('${freq_g 1}')
local cpu_core_2=conky_parse('${freq_g 2}')

xout({x=190,y=130,c=dunkel,txt='cpu #1:'})
xout({x=330,y=130,c=hell,txt=string.gsub(tostring(cpu_core_1),"%.",",").." ghz",j='r'})

xout({x=190,y=145,c=dunkel,txt='cpu #2:'})
xout({x=330,y=145,c=hell,txt=string.gsub(tostring(cpu_core_2),"%.",",").." ghz",j='r'})

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

local fs_folder=conky_parse('${fs_free /home/alexander/Downloads}')
local typ_hdd_home=conky_parse("${fs_type /home/alexander/Downloads}")

xout({x=190,y=160,c=dunkel,txt='downloads:'})
xout({x=330,y=160,c=hell,txt=aendern(fs_folder,'gb')..' ('..typ_hdd_home..')',j='r'})

local updates_verf=conky_parse("${execi 1800 aptitude search '~U' | wc -l}")
xout({x=190,y=175,c=dunkel,txt='updates:'})
xout({x=330,y=175,c=hell,txt=updates_verf..' updates',j='r'})

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

local speed_1=conky_parse('${downspeedf wlan0}')
local speed_2=conky_parse('${upspeedf wlan0}')
local geschw_1=string.gsub(tostring(speed_1),"%.",",")
local geschw_2=string.gsub(tostring(speed_2),"%.",",")

local total_1=conky_parse('${totaldown wlan0}')
local total_2=conky_parse('${totalup wlan0}')

xout({x=190,y=210,c=dunkel,txt='downspeed:'})
xout({x=330,y=210,c=hell,txt=geschw_1..' kb/s',j='r'})

xout({x=190,y=225,c=dunkel,txt='upspeed:'})
xout({x=330,y=225,c=hell,txt=geschw_2..' kb/s',j='r'})

xout({x=0,y=210,c=dunkel,txt='total down:'})
xout({x=140,y=210,c=hell,txt=aendern(total_1,'mb'),j='r'})

xout({x=0,y=225,c=dunkel,txt='total up:'})
xout({x=140,y=225,c=hell,txt=aendern(total_2,'mb'),j='r'})

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

local anzahl_1=conky_parse('${tcp_portmon 1 32767 count}')
local anzahl_2=conky_parse('${tcp_portmon 32768 61000 count}')

xout({x=330,y=250,c=dunkel,txt=lw(anzahl_1,'ein'),j='r'})
xout({x=330,y=265,c=dunkel,txt=lw(anzahl_2,'aus'),j='r'})


-- #################################################################
-- ## Aufruf isometric bars ########################################
-- #################################################################

conky_draw_shape()

-- #################################################################




--start or weather forecast table section
--set start forecast day
start_day=2
--set total forecast days you want to display
number_of_days=5
topy=100
gapy=65 -- topy+(gapy*1)

--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=10,topy
   top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,topy+(gapy*1)
   top_left_x_coordinate[4],top_left_y_coordinate[4]=120,topy+(gapy*1)
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,topy+(gapy*2)
   top_left_x_coordinate[6],top_left_y_coordinate[6]=120,topy+(gapy*2)
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,topy+(gapy*3)
   top_left_x_coordinate[8],top_left_y_coordinate[8]=120,topy+(gapy*3)
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,topy+(gapy*4)
   top_left_x_coordinate[10],top_left_y_coordinate[10]=120,topy+(gapy*4)
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do --start of day repeat, do not edit #######
tlx=top_left_x_coordinate[i]+10 --sets top left x position for each repeat ##################
tly=top_left_y_coordinate[i] --sets top left y position for each repeat ##################
--########################################################################################


--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################


function number_to_words(number)
n_sub=string.gsub(tostring(number), ".", "%1|")
n_split=string.split(n_sub, "|")
n_len=string.len(tostring(number))
if tonumber(number)>0 then n0="" else n0="zero" end
n1_tab={n0='keine',n1="eine",n2="zwei",n3="drei",n4="vier",n5="fünf",n6="sechs",n7="sieben",n8="acht",n9="neun",n10="zehn",n11="elf",n12="zwölf",n13="dreizehn",n14="vierzehn",n15="fünfzehn",n16="sechzehn",n17="siebzehn",n18="achtzehn",n19="neunzehn",}
n2_tab={n0="",n1="zehn",n2="zwanzig",n3="dreißig",n4="vierzig",n5="fünfzig",n6="sechzig",n7="siebzig",n8="achzig",n9="neunzig",}
n3_tab={n0="",n1="einhundert",n2="zweihundert",n3="dreihundert",n4="vierhundert",n5="fünfhundert",n6="sixty",n7="seventy",n8="eighty",n9="ninety",}
if tonumber(number)<20 then
return (n1_tab[tostring("n" .. number)])
elseif tonumber(number)>19 and tonumber(number)<100 then
if tonumber(n_split[2])>0 then joinu=" " else joinu="" end
return (n2_tab[tostring("n" .. n_split[1])] .. joinu .. n1_tab[tostring("n" .. n_split[2])])
elseif tonumber(number)>99 and tonumber(number)<1000 then
if tonumber(n_split[2])>0 or tonumber(n_split[3])>0 then join="and " else join="" end
if tonumber(n_split[2])>0 then joinu=" " else joinu="" end
return (n1_tab[tostring("n" .. n_split[1])] .. " hundred " .. join .. n2_tab[tostring("n" .. n_split[2])] .. joinu .. n1_tab[tostring("n" .. n_split[3])])
end
end--function


function lw(wert,text)

local zahl=tonumber(wert)

if zahl==1 and zahl==0 then
txt=number_to_words(zahl)..' '..text..'gehende verbindung'
elseif zahl~=1 and zahl~=0 then
txt=number_to_words(zahl)..' '..text..'gehende verbindungen'
end

return txt

end

i have problems with the function (number_2_word). if the value is bigger then 20 then this error appears:

adoUMN1K.png?st=Ce7oQiUQDZDzyKyD1YYhQA&e=1352054204

it works for english numbers but not for german numbers sad

20  ->  zwanzig
21  -> einundzwanzig

@mrpeachy

do u know how to solve this problem?

Last edited by lionhead (2012-11-04 18:12:32)

Offline

#3598 2012-11-04 18:51:56

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

Re: Conky v1.9 Thread

lionhead wrote:

do u have an idea why the value for incoming connections does not work?

I don't do code but maybe because you have multiple occurrences of the same: 10 = zehn

n10="zehn" = n1="zehn"

Just a thought, probably wrong, but you reminded me that I can count in German.  big_smile


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#3599 2012-11-04 18:55:28

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

Re: Conky v1.9 Thread

see PM lionhead, ive sent you a fixed version of the numbers to words function

unfortunately i have little/no idea how you construct written numbers in german, therefore the function follows english conventions

Offline

Help fund CrunchBang, donate to the project!

#3600 2012-11-04 19:10:06

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 105
Website

Re: Conky v1.9 Thread

Ok, I altered the clock slightly, added numbers for the minutes to it, and altered the weather slightly as well, moved the wind to inside the clock
acjnm4Y1.png

here is the updated Chronograph.lua

--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
 21 Jun 2012 - Chronograph modifications by Sector11
 22 Jun 2012 - again with mrpeachy's help day names, numbers and month names

use in conkyrc

lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT


-- INDEX (use find with):

-- ###### 12 OR 24 CLOCK FACE
-- SET BORDER OPTIONS ######  ALL CLOCKS

-- ### START CLOCK A ######################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
-- CLOCK A ###### 24 HR TIME

-- ### START DIAL B ### Top - Week Day Names Dial #########
-- ### START DIAL C ### Right - Month Names Dial ##########
-- ### START DIAL D ### Left - Day Numbers Dial ###########

-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
-- CLOCK E HOUR HAND
-- CLOCK E MINUTE HAND SETUP
-- CLOCK E SECOND HAND SETUP
-- CLOCK E ###### 12 HR TIME

NOTE:  Putting ### CLOCK A ### last insures that it's functions are written
       over the other dials.
]]

require 'cairo'

function conky_main()
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)
-- ########################################################
-- SETTINGS AREA
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")

-- ###### 12 OR 24 CLOCK FACE #############################
local clock_type_A=12 -- Large Main 24 HR Clock
local clock_type_E=12 -- Bottom - 12 HR Clock

-- ###### CLOCK SETTINGS ##################################
-- SET BORDER OPTIONS FOR "CLOCKS" ########################
local clock_border_width=0
-- set color and alpha for clock border
local cbr,cbg,cbb,cba=1,1,1,1  -- full opaque white
-- gap from clock border to minute marks
local b_to_m=1

-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- DIAL POSITION FOR TEXT
local center_x=175
local center_y=95
local radius=50
-- FONT
cairo_select_font_face (cr, "Santana", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"SUN","MON","TUE","WED","THR","FRI","SAT",}
-- text_days={"DOM","LUN","MAR","MIE","JUE","VIE","SAB",}
for i=1,7 do
-- work out points
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=35
for i=1,7 do
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current day of week
local hand_length=30
local day_number=tonumber(os.date("%w"))
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
local hand_width=2
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END DIAL B #########################################

-- ########################################################
-- ### START DIAL C ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=260
local center_y=175
local radius=45
-- FONT
cairo_select_font_face (cr, "Santana", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC",}
-- text_days={"ENE","FEB","MAR","ABR","MAY","JUN","JUL","AGO","SEP","OCT","NOV","DIC",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=32
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current month
local this_month=tonumber(os.date("%m"))
local hand_length=28 --radius for this calculation
local point=(math.pi/180)*((360/12)*(this_month-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)

-- ### END CLOCK C ########################################

-- ########################################################
-- ### START DIAL D ### Left - Day Numbers Dial ###########
-- GET NUMBER OF DAYS IN CURRENT MONTH
-- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
-- MONTH TABLE
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]
-- TEXT positioning
local center_x=95
local center_y=175
local radius=50
cairo_select_font_face (cr, "Santana", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 8)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
for i=1,number_days do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=i
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=40
for i=1,number_days do
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current DAY
local this_day=tonumber(os.date("%d"))
local hand_length=35--radius for this calculation
local point=(math.pi/180)*((360/number_days)*(this_day-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END CLOCK D ########################################

-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,0,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=25
-- set hour hand width
hh_width_E=2
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=35
-- set minute hand width
mh_width_E=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,0,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK E SECOND HAND SETUP
-- set length of seconds hand
sh_length_E=32
-- set hour hand width
sh_width_E=1
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
shr,shg,shb,sha=1,0,0,1-- fully opaque red
-- CLOCK E ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=45
clock_centerx=175
clock_centery=260
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_E
-- set line cap type
cairo_set_line_cap  (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end-- of for loop
--[[ TIME CALCULATIONS CLOCK E
if clock_type_E==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_E==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND
-- get hours minutes seconds as just seconds and draw it
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_E))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_E)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_E)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_E
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_E)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr)


-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=260
local radius=45
-- FONT
cairo_select_font_face (cr, "Santana", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
--text_days={"12","01","02","03","04","05","06","07","08","09","10","11",}
-- FOR A 12 HOUR CLOCK WITH THE NUMBERS 13-00
text_days={"00","13","14","15","16","17","18","19","20","21","22","23",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=32
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end ]]

-- ### END CLOCK E ########################################




-- ########################################################
-- ### START CLOCK A ######################################
-- SET MARKS ##############################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=12
-- set mark length
local m_length_A=0
-- set mark width
local m_width_A=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK A HOUR HAND
-- set length of hour hand
hh_length_A=130
-- set hour hand width
hh_width_A=3
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,1,.5-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK A MINUTE HAND SETUP
-- set length of minute hand
mh_length_A=145
-- set minute hand width
mh_width_A=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,1,.5-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
sh_length_A=150
-- set hour hand width
sh_width_A=2
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
shr,shg,shb,sha=1,0,0,1-- fully opaque red
-- CLOCK A ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=200
clock_centerx=175
clock_centery=175
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A
-- set line cap type
cairo_set_line_cap  (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_A)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end-- of for loop
-- HOUR MARKS
-- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds just as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
--[[
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr)
]]
-- ####################################################################
-- part of a second hand

--position
local center_x=175
local center_y=175
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
local arc=(math.pi/180)*((360/60)*seconds)
--calculate point 1
local radius1=100
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=151
local x2=0+radius2*math.sin(arc)
local y2=0-radius2*math.cos(arc)
--draw line connecting points
cairo_move_to (cr, center_x+x1,center_y+y1)
cairo_line_to (cr, center_x+x2, center_y+y2)
cairo_set_source_rgba (cr,255/255,0/255,0/255,1)
cairo_stroke (cr)
-- ####################################################################

-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=175
local radius=165
-- FONT
cairo_select_font_face (cr, "Santana", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 16)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"12","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end

-- POSITION FOR TEXT HOUR NUMBERS
local center_x=175
local center_y=175
local radius=160
-- FONT
cairo_select_font_face (cr, "Santana", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 12)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
text_days={"","1","2","3","4","","6","7","8","9","","11","12","13","14","","16","17","18","19","","21","22","23","24","","26","27","28","29","","31","32","33","34","","36","37","38","39","","41","42","43","44","","46","47","48","49","","51","52","53","54","","56","57","58","59","",}
for i=1,60 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end

-- INNER POINTS POSITION, radius smaller than text circle
local radius=150
for i=1,60 do
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
--[[ HOUR POINTS CIRCLES,  ##########Uncoment section to draw rings around numbers
local radius=162
for i=1,60 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,12,0,2*math.pi)
cairo_stroke (cr)
end]]
-- ### END CLOCK A ########################################



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

and here is the altered weather.template

Sunrise${goto 290}Sunset
 [--datatype=SR]${goto 300}[--datatype=SS]




${goto 75}Visible${goto 240}Rain?
${goto 60}[--datatype=VI]${goto 240}[--datatype=PC]










${goto 40}Wind
${goto 50} [--datatype=WD] @ [--datatype=WS]
${goto 210}${font Santana:style=bold:size=12}[--datatype=CC]${font}
${goto 60}High: [--datatype=HT --startday=0]${goto 215}${font Santana:style=bold:size=10}Temp: [-u]${font}
${goto 80}Low: [--datatype=LT --startday=0]${goto 230}FL: [--datatype=LT --night]
${goto 100}Bar: [--datatype=BR]${goto 220}UV: [--datatype=UI]
${goto 110}Humidity: [--datatype=HM]${image [--datatype=MI] -p 150,73 -s 50x50}
${goto 140}Dew: [--datatype=DP]${image [--datatype=WI] -p 125,170 -s 100x100 -n}
${image [--datatype=BI] -p 59,139 -s 70x70}

8o Got /? | The first GUI, and "on-line" system was created in 1968 by Douglas Engelbart, the system included modern day innovations such as video conferencing, and on-line file sharing.

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: acrobat

Debian Logo