You are not logged in.

#61 2015-11-25 11:22:55

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Conky - Calendars / Clocks / Time

Sector11 wrote:

This is the Clock conky with the LED lights right?

Strange, it works perfect here...

Are you using Bunsen?

yes

on both
with battery

$ inxi -S
System:    Host: x40RD Kernel: 3.15.2-antix.1-486 i686 (32 bit) Desktop: Fluxbox 1.3.5
           Distro: antiX-14-a3-RD_386-full Killah P 11 October 2014

$ conky -v
Conky 1.9.0 compiled Sat Jan 17 21:15:51 UTC 2015 for Linux 3.2.0-4-amd64 (i686)

Compiled in features:

System config file: /etc/conky/conky.conf
Package library path: /usr/lib/conky

 X11:
  * Xdamage extension
  * XDBE (double buffer extension)
  * Xft
  * ARGB visual

 Music detection:
  * Audacious
  * MPD
  * MOC
  * XMMS2

 General:
  * math
  * hddtemp
  * portmon
  * Curl
  * RSS
  * Weather (METAR)
  * Weather (XOAP)
  * wireless
  * config-output
  * Imlib2
  * apcupsd
  * iostats
  * ncurses
  * Lua

  Lua bindings:
   * Cairo
   * Imlib2

without battery

$ inxi -S
System:    Host: localhost Kernel: 4.1.13-desktop-2.mga5 x86_64 (64 bit) Desktop: KDE 4.14.5 
           Distro: Mageia 5 thornicroft 

$ conky -v
Conky 1.9.0 compiled Sat Oct 18 10:40:56 UTC 2014 for Linux 3.14.18-server-3.mga4 (x86_64)

Compiled in features:

System config file: /etc/conky/conky.conf
Package library path: /usr/lib64/conky

 X11:
  * Xdamage extension
  * XDBE (double buffer extension)
  * Xft
  * ARGB visual

 Music detection:
  * MPD
  * MOC

 General:
  * math
  * hddtemp
  * portmon
  * Curl
  * RSS
  * Weather (METAR)
  * Weather (XOAP)
  * wireless
  * support for IBM/Lenovo notebooks
  * eve-online
  * config-output
  * Imlib2
  * apcupsd
  * iostats
  * ncurses
  * Lua

  Lua bindings:
   * Cairo
   * Imlib2
 

Offline

#62 2015-11-25 13:56:35

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

@ unklar

I just spent some time on the net looking for "no templates to replace" - don't worry about that at all, just a debug report.

The blinking (LED) line in your conky is not LUA.  Just conky parsing a text file.

RE:

Conky: unknown variable 
Conky: unknown variable 

By commenting out:

#lua_load $HOME/.Conky/cronograph/scripts/clock_rings.lua
#lua_draw_hook_pre clock_rings

I stopped the errors.  So now we know what LUA script is spitting out the errors.

In the clock_rings.lua script you have 11 of these:

	{
		name=' ',
		arg=' ',
		max=100,
		bg_colour=0x000000,
		bg_alpha=0.3,
		fg_colour=0xFFFFFF,
		fg_alpha=0.0,
		x=150, y=75,
		radius=13,
		thickness=22,
		start_angle=0,
		end_angle=360
	},

causing the unknown variable because they are not defining a variable in arg=' ',

I eliminated them, and the errors, with this clock_rings.lua:

--[[
Clock Rings by londonali1010 (2009)

This script draws percentage meters as rings, and also draws clock hands if you want! It is fully customisable; all options are described in the script. This script is based off a combination of my clock.lua script and my rings.lua script.

IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement near the end of the script uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num > 5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num > 3; conversely if you update Conky every 0.5s, you should use update_num > 10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.

To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
	lua_load ~/scripts/clock_rings-v1.1.1.lua
	lua_draw_hook_pre clock_rings

Changelog:
+ v1.1.1 -- Fixed minor bug that caused the script to crash if conky_parse() returns a nil value (20.10.2009)
+ v1.1 -- Added colour option for clock hands (07.10.2009)
+ v1.0 -- Original release (30.09.2009)
]]

settings_table = {
	{
		-- Edit this table to customise your rings.
		-- You can create more rings simply by adding more elements to settings_table.
		-- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
		name='time',
		-- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
		arg='%I.%M',
		-- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
		max=12,
		-- "bg_colour" is the colour of the base ring.
		bg_colour=0xFFFFFF,
		-- "bg_alpha" is the alpha value of the base ring.
		bg_alpha=0.1,
		-- "fg_colour" is the colour of the indicator part of the ring.
		fg_colour=0xFFFFFF,
		-- "fg_alpha" is the alpha value of the indicator part of the ring.
		fg_alpha=0.5,
		-- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
		x=150, y=150,
		-- "radius" is the radius of the ring.
		radius=135,
		-- "thickness" is the thickness of the ring, centred around the radius.
		thickness=4,
		-- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
		start_angle=0,
		-- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
		end_angle=360
	},
	{
		name='time',
		arg='%M.%S',
		max=60,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.5,
		x=150, y=150,
		radius=140,
		thickness=4,
		start_angle=0,
		end_angle=360
	},
	{
		name='time',
		arg='%S',
		max=60,
		bg_colour=0xFFFFFF,
		bg_alpha=0.1,
		fg_colour=0xFFFFFF,
		fg_alpha=0.5,
		x=150, y=150,
		radius=145,
		thickness=4,
		start_angle=0,
		end_angle=360
	},
	}

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

clock_r=127

-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.

clock_x=150
clock_y=150

-- Colour & alpha of the clock hands

clock_colour=0xFFFFFF
clock_alpha=1

-- Do you want to show the seconds hand?

show_seconds=true

require 'cairo'

function rgb_to_r_g_b(colour,alpha)
	return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function draw_ring(cr,t,pt)
	local w,h=conky_window.width,conky_window.height

	local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
	local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']

	local angle_0=sa*(2*math.pi/360)-math.pi/2
	local angle_f=ea*(2*math.pi/360)-math.pi/2
	local t_arc=t*(angle_f-angle_0)

	-- Draw background ring

	cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
	cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
	cairo_set_line_width(cr,ring_w)
	cairo_stroke(cr)

	-- Draw indicator ring

	cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
	cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
	cairo_stroke(cr)
end

function draw_clock_hands(cr,xc,yc)
	local secs,mins,hours,secs_arc,mins_arc,hours_arc
	local xh,yh,xm,ym,xs,ys

	secs=os.date("%S")
	mins=os.date("%M")
	hours=os.date("%I")

	secs_arc=(2*math.pi/60)*secs
	mins_arc=(2*math.pi/60)*mins+secs_arc/60
	hours_arc=(2*math.pi/12)*hours+mins_arc/12

	-- Draw hour hand

	xh=xc+0.7*clock_r*math.sin(hours_arc)
	yh=yc-0.7*clock_r*math.cos(hours_arc)
	cairo_move_to(cr,xc,yc)
	cairo_line_to(cr,xh,yh)

	cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
	cairo_set_line_width(cr,5)
	cairo_set_source_rgba(cr,rgb_to_r_g_b(clock_colour,clock_alpha))
	cairo_stroke(cr)

	-- Draw minute hand

	xm=xc+clock_r*math.sin(mins_arc)
	ym=yc-clock_r*math.cos(mins_arc)
	cairo_move_to(cr,xc,yc)
	cairo_line_to(cr,xm,ym)

	cairo_set_line_width(cr,3)
	cairo_stroke(cr)

	-- Draw seconds hand

	if show_seconds then
		xs=xc+clock_r*math.sin(secs_arc)
		ys=yc-clock_r*math.cos(secs_arc)
		cairo_move_to(cr,xc,yc)
		cairo_line_to(cr,xs,ys)

		cairo_set_line_width(cr,1)
		cairo_stroke(cr)
	end
end

function conky_clock_rings()
	local function setup_rings(cr,pt)
		local str=''
		local value=0

		str=string.format('${%s %s}',pt['name'],pt['arg'])
		str=conky_parse(str)

		value=tonumber(str)
		if value == nil then value = 0 end
		pct=value/pt['max']

		draw_ring(cr,pct,pt)
	end

	-- Check that Conky has been running for at least 5s

	if conky_window==nil then return end
	local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)

	local cr=cairo_create(cs)

	local updates=conky_parse('${updates}')
	update_num=tonumber(updates)

	if update_num>5 then
		for i in pairs(settings_table) do
			setup_rings(cr,settings_table[i])
		end
	end

	draw_clock_hands(cr,clock_x,clock_y)
end

Terminal output:

 25 Nov 15 | 10:55:11 ~
    $ kfc
 
 25 Nov 15 | 10:55:16 ~
    $ conky -c ~/.Conky/cronograph/conkyrc_2 &
[1] 2172
 
 25 Nov 15 | 10:55:39 ~
    $ Conky: forked to background, pid is 2177

Conky: desktop window (265) is root window
Conky: window type - normal
Conky: drawing to created window (0xa00001)
Conky: drawing to double buffer

[1]+  Done                    conky -c ~/.Conky/cronograph/conkyrc_2
 
 25 Nov 15 | 10:55:54 ~
    $ 

Good luck.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#63 2015-11-25 14:51:40

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Conky - Calendars / Clocks / Time

BINGO!!!! big_smile big_smile
That works perfectly.

Eternal thanks to the large @El Conkystasor!  {)

Offline

#64 2015-11-25 15:58:22

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

Always always glad to see a happy ConkyRat

I consider myself a Bunsen LabRat and therefore by extension: a ConkyRat!   ]:D


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#65 2015-12-06 20:20:52

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

Ever want to test an app with a different time and or date?

Enter 'faketime' shown here with some conky calendars:

Today ... Past ... and Future
2015_12_06_17_10_27_Scrot11.png 2015_12_06_17_11_32_Scrot11.png 2015_12_06_17_12_00_Scrot11.png

It would work just as well with conky clocks.  smile


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#66 2015-12-14 02:45:13

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

== Conky v1.9 ==

Hello "python" gurus.
Can anyone tell me why today, 13 Dec 2015, isn't highlighted in this python calendar?
2015_12_13_23_41_50_Scrot11.jpg

${execpi 3600 faketime '2025-07-14' /media/5/Conky/scripts/cal.py}

${execpi 3600 /media/5/Conky/scripts/cal.py}

${execpi 3600 faketime '1947-04-15' /media/5/Conky/scripts/cal.py}

cal.py

#!/usr/bin/env python
# by Crinos512
import time, calendar, re

localtime = time.localtime(time.time())
calendar.setfirstweekday(calendar.SUNDAY)
#calendar.setfirstweekday(calendar.MONDAY)
cal = calendar.month(localtime[0], localtime[1])

parts = cal.split('\n')
cal = '${color7}${goto 51}' + '\n${goto 51}'.join(parts)
regex = '(?<= )%s(?= )|(?<=\n)%s(?= )|(?<= )%s(?=\n)' % (localtime[2], localtime[2], localtime[2])
replace = '${color8}%s${color7}' % localtime[2]
newCal = re.sub(regex, replace, cal)
print newCal

Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#67 2015-12-14 11:30:34

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Conky - Calendars / Clocks / Time

color8  there is in the conkyrc?

Offline

#68 2015-12-14 12:27:28

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

color8 FFD700 ## Gold

It's what is colouring the dates in the other two conkys.

Interesting ... today it works. 2015_12_14_08_38_53_Scrot11.jpg

Maybe the number 13?  No not that ...

 14 Dec 15 | 09:22:10 ~
    $ faketime '2025-07-07' /media/5/Conky/scripts/cal.py
${color7}${goto 51}     July 2025
${goto 51}Mo Tu We Th Fr Sa Su
${goto 51}    1  2  3  4  5  6
${goto 51} ${color8}7${color7}  8  9 10 11 12 13
${goto 51}14 15 16 17 18 19 20
${goto 51}21 22 23 24 25 26 27
${goto 51}28 29 30 31
${goto 51}
 
 14 Dec 15 | 09:23:37 ~
    $ faketime '2025-07-14' /media/5/Conky/scripts/cal.py
${color7}${goto 51}     July 2025
${goto 51}Mo Tu We Th Fr Sa Su
${goto 51}    1  2  3  4  5  6
${goto 51} 7  8  9 10 11 12 13
${goto 51}14 15 16 17 18 19 20
${goto 51}21 22 23 24 25 26 27
${goto 51}28 29 30 31
${goto 51}
 
 14 Dec 15 | 09:23:51 ~
    $ faketime '2025-07-21' /media/5/Conky/scripts/cal.py
${color7}${goto 51}     July 2025
${goto 51}Mo Tu We Th Fr Sa Su
${goto 51}    1  2  3  4  5  6
${goto 51} 7  8  9 10 11 12 13
${goto 51}14 15 16 17 18 19 20
${goto 51}21 22 23 24 25 26 27
${goto 51}28 29 30 31
${goto 51}
 
 14 Dec 15 | 09:23:58 ~
    $ 

It is the first column of numbers, with July 2025, 7 works, 14, 21 and 28 do not.  The other "dates" seem to work
I must contact Crinos512 if he is still around if no one else can figure this out


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#69 2015-12-14 14:46:48

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Conky - Calendars / Clocks / Time

in cal.py, replace the line starting with
regex =
by

regex = '(?<=\})%s(?= )|(?<= )%s(?= )|(?<=\n)%s(?= )|(?<= )%s(?=\n)' % (localtime[2], localtime[2], localtime[2], localtime[2])

The original regex did not work when current day contains 2 significant digits and starts in first column.
hth

Offline

#70 2015-12-14 15:43:39

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

${execpi 3600 faketime '2016-01-31' /media/5/Conky/scripts/cal.py}
${execpi 3600 faketime '2016-07-03' /media/5/Conky/scripts/cal.py}
${execpi 3600 faketime '2016-07-10' /media/5/Conky/scripts/cal.py}
${execpi 3600 faketime '2016-07-17' /media/5/Conky/scripts/cal.py}
${execpi 3600 faketime '2016-07-24' /media/5/Conky/scripts/cal.py}
${execpi 3600 faketime '2016-07-31' /media/5/Conky/scripts/cal.py}

OK, awesome xaos52 that cleared up those lines  - but there is a new one ... OOPS! that is.  Jan 2016 and July 2016 (and others I'm sure have 6 rows for weeks and the first date on the 6th line doesn't work.  And looking at what you gave me for that regex line I would be better off reading Martian.  smile
2015_12_14_12_38_39_Scrot11.jpg

 14 Dec 15 | 12:42:43 ~
    $ faketime '2016-07-24' /media/5/Conky/scripts/cal.py
${color7}${goto 51}     July 2016
${goto 51}Su Mo Tu We Th Fr Sa
${goto 51}                1  2
${goto 51} 3  4  5  6  7  8  9
${goto 51}10 11 12 13 14 15 16
${goto 51}17 18 19 20 21 22 23
${goto 51}${color8}24${color7} 25 26 27 28 29 30
${goto 51}31
${goto 51}
 
 14 Dec 15 | 12:42:58 ~
    $ faketime '2016-07-31' /media/5/Conky/scripts/cal.py
${color7}${goto 51}     July 2016
${goto 51}Su Mo Tu We Th Fr Sa
${goto 51}                1  2
${goto 51} 3  4  5  6  7  8  9
${goto 51}10 11 12 13 14 15 16
${goto 51}17 18 19 20 21 22 23
${goto 51}24 25 26 27 28 29 30
${goto 51}31
${goto 51}
 
 14 Dec 15 | 12:43:06 ~
    $ 

Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#71 2015-12-14 16:14:46

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Conky - Calendars / Clocks / Time

I think this covers all bases:

regex = '(?<=\})%s(?= )|(?<= )%s(?= )|(?<=\n)%s(?= )|(?<= )%s(?=\n)|(?<=\})%s(?=\n)' % (localtime[2], localtime[2], localtime[2], localtime[2], localtime[2])

we had not covered the case where current date is 2 digits, preceeded by '}' and followed by a new line.

Not martian, but can become very complicated: python regular expressions.

Offline

#72 2015-12-14 17:01:00

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

xaos52 wrote:

we had not covered the case where current date is 2 digits, preceeded by '}' and followed by a new line.

...aaaaand a parrrrtriiiiidge in a pear treeeeeee! O:)

xaos52 wrote:

Not martian, but can become very complicated: python regular expressions.

wanna bet, that's Martian if I ever saw a "?<=\"  lol  lol

AND THAT'S A WRAP!

@ unklar - make sure you get this version.

cal.py

#!/usr/bin/env python
# by Crinos512
#regex tweaked by xaos52
#https://forums.bunsenlabs.org/viewtopic.php?pid=11683#p11683
import time, calendar, re

localtime = time.localtime(time.time())
calendar.setfirstweekday(calendar.SUNDAY)
#calendar.setfirstweekday(calendar.MONDAY)
cal = calendar.month(localtime[0], localtime[1])

parts = cal.split('\n')
cal = '${color7}${goto 51}' + '\n${goto 51}'.join(parts)
regex = '(?<=\})%s(?= )|(?<= )%s(?= )|(?<=\n)%s(?= )|(?<= )%s(?=\n)|(?<=\})%s(?=\n)' % (localtime[2], localtime[2], localtime[2], localtime[2], localtime[2])
replace = '${color8}%s${color7}' % localtime[2]
newCal = re.sub(regex, replace, cal)
print newCal

I don't think I'll ever understand regular expressions as much as I try.  The only thing I see there that I recognize " | " because I use it,
${ .... | cut -c-18} or ${ .... | fold -sw18}
and =< is equal to or less than  but fail to see how " ? is equal to or less than \ "
Oh well, it works, I'm happy.
2015_12_14_14_02_20_Scrot11.jpg

Thank you xaos52

Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#73 2015-12-14 17:09:44

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Conky - Calendars / Clocks / Time

In this case... it is a positive lookbehind assertion

(?<=...)

    Matches if the current position in the string is preceded by a match for ... that ends at the current position. This is called a positive lookbehind assertion. (?<=abc)def will find a match in abcdef, since the lookbehind will back up 3 characters and check if the contained pattern matches. The contained pattern must only match strings of some fixed length, meaning that abc or a|b are allowed, but a* and a{3,4} are not. Group references are not supported even if they match strings of some fixed length. Note that patterns which start with positive lookbehind assertions will not match at the beginning of the string being searched; you will most likely want to use the search() function rather than the match() function:

Offline

#74 2015-12-14 20:10:19

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Conky - Calendars / Clocks / Time

Sector11 wrote:

@ unklar - make sure you get this version.

done   big_smile

@xaos52
equally thank you. You are great!

Offline

#75 2016-03-28 16:36:30

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

I like clocks ... so another clock.  mrpeachy's yearclock.lua is an interesting script to say the least ... circles and dots!  I added the text to just to test while working on it.

I also changed all instances of the 'circles' to a thickness of 1 and all instances of the dots to size 6. (old sizes are commented)  Then I did some colour changes so the different elements would stand out (old black-grey colours preserved in comments).

Lastly I used 'faketime' to test various times displayed; IE:

 28 Mar 16 @ 10:46:15 ~
  $ faketime '2016-03-08 15:15:00' conky -q -c /media/5/Conky/S11_YearClock.conky
[2]+  Done                    pkill -xf "conky -q -c /media/5/Conky/S11_YearClock.conky"
 
 28 Mar 16 @ 10:49:26 ~
  $ pkill -xf "conky -q -c /media/5/Conky/S11_YearClock.conky" &
[1] 1647
[1]+  Done                    pkill -xf "conky -q -c /media/5/Conky/S11_YearClock.conky"
 
 28 Mar 16 @ 10:49:53 ~
  $ faketime '2000-12-01 00:00:00' conky -q -c /media/5/Conky/S11_YearClock.conky
 
 28 Mar 16 @ 10:50:24 ~
  $ pkill -xf "conky -q -c /media/5/Conky/S11_YearClock.conky" &
[1] 1900
[1]+  Done                    pkill -xf "conky -q -c /media/5/Conky/S11_YearClock.conky"
 
 28 Mar 16 @ 10:51:28 ~
  $

At first I thought the "month" dot position was not working right, but with different "times" it became apparent that the month dot flowed smoothly around the ring as the days advanced from 01 to 28, 29, 30, 31, 01, 02 ... DUH!  talk about feel silly!

Anyway ... images or did not happen (set to: alignment mm)
2016_03_28_12_13_59_Scrot11.jpg  2016_03_28_12_19_38_Scrot11.jpg
2016_03_28_12_20_40_Scrot11.jpg  2016_03_28_12_22_24_Scrot11.jpg
2016_03_28_12_22_45_Scrot11.jpg  2016_03_28_12_23_20_Scrot11.jpg
2016_03_28_12_24_03_Scrot11.jpg  2016_03_28_12_24_50_Scrot11.jpg

2016_03_28_12_26_47_Scrot11.jpg<<-- a few minutes ago with no faketime.

The conky:

# pkill -xf "conky -q -c /media/5/Conky/S11_YearClock.conky" &
###  Begin Window Settings  ##################################################
own_window yes
own_window_type normal
own_window_transparent yes
own_window_colour yellow
own_window_hints undecorated,below,skip_taskbar,skip_pager ##,sticky
own_window_class Conky
own_window_title YearClock.lua

# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
double_buffer yes

### ARGB can be used for real transparency
# own_window_argb_visual yes # Options: yes or no
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
# own_window_argb_value 255

minimum_size 600 600 	## w|h
maximum_width 600

gap_x 0	## l|r
gap_y 0	## u|d

alignment mm
####################################################  End Window Settings  ###
###  Font Settings  ##########################################################
use_xft yes
xftfont Monofur:size=14
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1.0
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
######################################################  End Font Settings  ###
## --------- Color Settings
draw_shades yes
default_shade_color 000000
draw_outline no
default_outline_color 000000

default_color DCDCDC #Gainsboro
color0 98FB98 #PaleGreen
color1 778899 #LightSlateGray
color2 FFD700 #Gold
color3 B0E0E6 #PowderBlue
color4 F4A460 #SandyBrown
color5 DEB887 #BurlyWood
color6 00BFFF #DeepSkyBlue
color7 5F9EA0 #CadetBlue
color8 FFA500 #Orange
color9 FF4500 #OrangeRed
## ---------- End Color Settings
###  Borders Section  ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders yes #no
#default_graph_size 15 40
#####################################################  End Borders Secton  ###
###  Miscellaneous Section  ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background yes

# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none

# Subtract (file system) buffers from used memory?
no_buffers yes

##############################################  End Miscellaneous Section  ###
###  LUA Settings  ###########################################################
###  yearclock.lua  ###########################################################
lua_load /media/5/Conky/LUA/yearclock.lua
lua_draw_hook_pre draw_clock
#lua_draw_hook_post draw_clock

#######################################################  End LUA Settings  ###

###  Removed from the final  ###
#${goto 180}${color 000000}Month ${color 778899}Day ${color DCDCDC}Hour ${color 00BFFF}Minute ${color FF4500}Second${color}
#${goto 180}${color 000000}${time %m}    ${color 778899}${time %d}  ${color DCDCDC}${time %H}   ${color 00BFFF}${time %M}     ${color FF4500}${time %S}${color}

update_interval 1
TEXT

yearclock.lua -- well commented for the different settings.

--yearclock by mrpeachy
require 'cairo'

function conky_draw_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)
-- not using CPU do not need the following two lines nor the second last 'end'
-- local updates=tonumber(conky_parse('${updates}'))
-- if updates > 5 then

--year clock
year=os.date("%G")
t1 = os.time( {    year=year,month=03,day=01,hour=00,min=0,sec=0} );
t2 = os.time( {    year=year,month=02,day=01,hour=00,min=0,sec=0} );
feb=(os.difftime(t1,t2))/(24*60*60)
yeardays=31+feb+31+30+31+30+31+31+30+31+30+31
monthdays = { 31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
yearsec=yeardays*24*60*60

rad=60
across=300
down=300
yrlw=1	-- yr (months) circle - lw = line width

circrad=rad
circx=across
circy=down
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.00,0.00,0.00,1) -- circle colour: Black
cairo_set_line_width(cr, yrlw)
cairo_stroke (cr)

--hours
hrs=os.date("%H")
--minutes
min=os.date("%M")
--seconds
sec=os.date("%S")
--day of month
day=os.date("%e")
--month-1
month=os.date("%m")
--position in the year indicator
mdays=0
for i=1,(month-1) do
mdays=mdays+monthdays[i]
end
yrsecs=(mdays*24*60*60)+(day*24*60*60)+(hrs*60*60)+(min*60)+(sec)
cairo_translate (cr, across, down)
outer1=rad
text_arc=((2*math.pi/(yearsec))*yrsecs)
yrx=0+outer1*(math.sin(text_arc))
yry=0-outer1*(math.cos(text_arc))
circrad=6 --6
circx=yrx
circy=yry
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.00,0.00,0.00,1)  -- dot color Black
cairo_fill (cr)
cairo_translate (cr, -across, -down)

--day of the month indicator
rad=50
across=yrx+across
down=yry+down
mnlw=1

circrad=rad
circx=across
circy=down
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.47,0.53,0.60,1) -- circle colour: LightSlateGray
cairo_set_line_width(cr, mnlw)
cairo_stroke (cr)

mndays=(monthdays[tonumber(month)])*24*60*60
mnday=(day*24*60*60)+(hrs*60*60)+(min*60)+(sec)
cairo_translate (cr, across, down)
outer1=rad
text_arc=((2*math.pi/(mndays))*mnday)
mnx=0+outer1*(math.sin(text_arc))
mny=0-outer1*(math.cos(text_arc))
circrad=6 --5
circx=mnx
circy=mny
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.47,0.53,0.60,1) -- dot colour: LightSlateGray
cairo_fill (cr)
cairo_translate (cr, -across, -down)

--hours of the day
rad=40
across=mnx+across
down=mny+down
dylw=1

circrad=rad
circx=across
circy=down
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.86,0.86,0.86,1) -- circle colour: Gainsboro
cairo_set_line_width(cr, dylw)
cairo_stroke (cr)

hours=24*60*60
hour=(hrs*60*60)+(min*60)+(sec)
cairo_translate (cr, across, down)
outer1=rad
text_arc=((2*math.pi/(hours))*hour)
dyx=0+outer1*(math.sin(text_arc))
dyy=0-outer1*(math.cos(text_arc))
circrad=6 --4
circx=dyx
circy=dyy
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.86,0.86,0.86,1) -- dot colour: Gainsboro
cairo_fill (cr)
cairo_translate (cr, -across, -down)

--minutes of hour indicator
rad=30
across=dyx+across
down=dyy+down
hrlw=1

circrad=rad
circx=across
circy=down
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.00,0.75,1.00,1) -- circle colour: DeepSkyBlue
cairo_set_line_width(cr, hrlw)
cairo_stroke (cr)

minutes=60*60
minute=(min*60)+(sec)
cairo_translate (cr, across, down)
outer1=rad
text_arc=((2*math.pi/(minutes))*minute)
hrx=0+outer1*(math.sin(text_arc))
hry=0-outer1*(math.cos(text_arc))
circrad=6 --3
circx=hrx
circy=hry
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0.00,0.75,1.00,1) -- circle colour: DeepSkyBlue
cairo_fill (cr)
cairo_translate (cr, -across, -down)

--seconds of minute indicator
rad=20
across=hrx+across
down=hry+down
seclw=1

circrad=rad
circx=across
circy=down
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,1.00,0.27,0.00,1) -- circle colour: OrangeRed
cairo_set_line_width(cr, seclw)
cairo_stroke (cr)
seconds=60
second=(sec)
cairo_translate (cr, across, down)
outer1=rad
text_arc=((2*math.pi/(seconds))*second)
scx=0+outer1*(math.sin(text_arc))
scy=0-outer1*(math.cos(text_arc))
circrad=6 --2
circx=scx
circy=scy
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba(cr,1.00,0.27,0.00,1) -- circle colour: OrangeRed
cairo_fill (cr)
cairo_translate (cr, -across, -down)
-- end
end

Colour coding LUA scripts the easy way.  nobody's map.py script.

Thank you mrpeachy and nobody.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#76 2016-03-28 17:15:24

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

So what happens when we run mrpeachy's yearclock.lua and easysid's clock_easysid.lua in the same conky?

###  yearclock.lua  ##########################################################
lua_load /media/5/Conky/LUA/yearclock.lua
lua_draw_hook_pre draw_clock
#lua_draw_hook_post draw_clock
#
###  clock_easysid_conkyrc.lua  ##############################################
lua_load /media/5/Conky/LUA/clock_easysid.lua
lua_draw_hook_post es_clock

2016_03_28_14_01_45_Scrot11.jpg 2016_03_28_14_04_57_Scrot11.jpg

2016_03_28_14_05_50_Scrot11.jpg 2016_03_28_14_06_24_Scrot11.jpg
NICE!!!!!

--[[ Clock for conky
written by easysid
Thu 09 May 2013 19:20:16 IST
--]]

require 'cairo'

function conky_es_clock()

clock_table ={
    {
        -- Draw the seconds
	    -- x = l|r y = u|d
        arg = "time %S",
        xc = 295,		--200,
        yc = 307,		--150,
        r  = 290,		--radius
        font_face = "Monofur",
        top_font_size = 20, -- font size for display
        min_font_size = 6,  -- min font for trail
        max_font_size = 14, -- max font fot trail
        max_alpha = .6,     -- max alpha for trail
        trail = 40,         -- size of trail
        main_color = {0xFFDEAD,1}, --color of numbers
        trail_color = {0xC1C1C1,1} --color of trail.
    },

    {
        -- Draw the Minutes
        arg = "time %M",
        xc = 295,		--200,
        yc = 307,		--150,
        r  = 250,		--radius
        font_face = "Monofur",
        top_font_size = 25, -- font size for display
        min_font_size = 4,  -- min font for trail
        max_font_size = 14, -- max font fot trail
        max_alpha = .6,     -- max alpha for trail
        trail = 40,         -- size of trail
        main_color = {0xFFDEAD,1}, --color of numbers
        trail_color = {0xC1C1C1,1} --color of trail
    },

    {
        -- Draw the Hours
        arg = "time %H",
        xc = 295,		--200,
        yc = 307,		--150,
        r  = 210,		--radius
        font_face = "Monofur",
        top_font_size = 30, -- font size for display
        min_font_size = 4,  -- min font for trail
        max_font_size = 14, -- max font fot trail
        max_alpha = .6,     -- max alpha for trail
        trail = 40,         -- size of trail
        main_color = {0xFFDEAD,1}, --color of numbers
        trail_color = {0xC1C1C1,1} --color of trail
    },
}
    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>3 then
        for i in ipairs(clock_table) do
            draw_clock(cr, clock_table[i])
        end
    end
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
end -- end main function


function draw_clock(cr, t)

        cairo_select_font_face (cr, t.font_face, CAIRO_FONT_SLANT_NORMAL,  CAIRO_FONT_WEIGHT_BOLD)

        local value = tonumber(conky_parse(string.format("${%s}",t.arg)))
        local first = value - t.trail

--[[        if t.arg == 'time %H' then -- special case for the hour digit
             cairo_set_source_rgba (cr, rgba_to_r_g_b_a(t.main_color))
             cairo_set_font_size (cr, t.top_font_size)
             cairo_move_to(cr, t.xc - t.top_font_size/3, t.yc+t.top_font_size/4) -- minor adjustment. Tweak here for your setting
             cairo_show_text(cr, value)
        else --]]
            for i = first, value do

                local theta = i*2*math.pi/60 -math.pi/2 -- calculate the angle
                local alpha = t.max_alpha*(i-first)/(value-first) -- map alpha value to [0, max_alpha]
                local font_size = (t.max_font_size-t.min_font_size)*(i-first)/(value-first) + t.min_font_size -- map font size similar to alpha
                t.trail_color[2] = alpha
                cairo_set_source_rgba (cr, rgba_to_r_g_b_a(t.trail_color))
                cairo_set_font_size (cr, font_size)
                if i == value then -- if we have the main value
                    cairo_set_source_rgba (cr, rgba_to_r_g_b_a(t.main_color)) -- switch color
                    cairo_set_font_size (cr, t.top_font_size) -- switch font
                end -- end if
                local k = i
                if k < 0 then k = 60 + i end  -- adjust seconds
                cairo_move_to(cr, t.xc + t.r*math.cos(theta), t.yc + t.r*math.sin(theta))
                cairo_show_text(cr, k)

            end -- end for
--[[      end --end if ------------- the if for special case for hours --]]
end -- end draw_clock


function rgba_to_r_g_b_a(tcolor)
	local color,alpha=tcolor[1],tcolor[2]
	return ((color / 0x10000) % 0x100) / 255.,
		((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end --end rgba

See the previous post to get the conky and yearclock.lua.

Thank you easysid.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#77 2016-04-04 17:58:04

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Conky - Calendars / Clocks / Time

Hello,

any ideas why the clock does not rotate?
It is Lua.  hmm
2016-04-04-19-26-47_scrot.th.png

conkyrc

# main conkyrc by Boris Krinkel <olgmen>
# krinkel@rambler.ru
# --- параметры окна ---
# эти строки необходимы для нормальной работы лучше не изменять
own_window		yes 
own_window_class	Conky 
own_window_transparent	yes 
own_window_type		normal 
own_window_hints	undecorated,below,skip_taskbar,skip_pager 
own_window_argb_visual  yes
# own_window_argb_value 255
# следующие параметры можно изменять
# минимальный размер
minimum_size 400 0 
# минимальная ширина
#maximum_width 400 
# --- расположение окна
# левый верхний угол экрана 
alignment top_left 
# левый нижний угол экрана
#alignment bottom_left 
# правый верхний угол экрана
#alignment top_right 
# правый нижний угол экрана
#alignment bottom_right 
# расстояние между кромкой экрана и окном
# по горизонтали
gap_x 30 
# по вертикали
gap_y 50 

# --- графика окна --- 
# если желаете выводить conky на другом фоне напишите yes
background no 
# окантовка окна, бордюр
draw_borders no

# если бордюр yes
# длина штрихов бордюра, если 0, то бордюр выводится сплошной линией
stippled_borders 1
# толщина линий бордюра 
border_width 1
# поле бордюра 
border_inner_margin 20 
# бордюр вокруг выводимых графиков
draw_graph_borders no
# включить тень?
draw_shades no
# окантовка вокруг текста и выводимых объектов
draw_outline no 
# Добавить пробел?  Только для встраиваемых объектов 
use_spacer right 

# --- цвет ---
# основной цвет по умолчанию 
default_color DeepSkyBlue
# цвет тени
default_shade_color black 
# цвет окантовки
default_outline_color black
# дополнительные
color1 white
color2 yellow 
color3 red 

# --- шрифты ---
# используемые шрифты X когда Xft не используется, можно выбрать один из следующих 
#font 5x7 
#font 6x10 
#font 7x13 
#font 8x13 
#font 9x15 
#font *mintsmild.se* 
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-* 

# Используется ли Xft? 
use_xft yes 

# Шриф Xft когда Xft доступен, здесь можно ввести название и размер любого шрифта 
xftfont D3 Roadsterism Long Italic:size=9 

# яркость шрифта при испоьзовании шрифтов Xft 
xftalpha 0.5 
# выводить весь текст прописными буквами 
uppercase no 
# использовать кодировку UTF8? ПРИМЕЧАНИЕ: требуется Xft 
override_utf8_locale yes 

# --- следующие данные необходимы для работы
# обновление в секундах не имеет смысла ставить больше 2
# при выводе времени в секундах необходимо значение 1 и менее
update_interval 1.0 
# время работы программы до её выключения
# установите 0 для работы программы без остановки
total_run_times 0
# двойная буфферизация (требуется для flicker, может не работать) 
double_buffer yes 
# вычитать буферизацию файловой системы из используемой памяти? 
no_buffers yes 
# количество cpu
cpu_avg_samples 2
# number of net samples to average 
net_avg_samples 2 
imlib_cache_size 0 
short_units yes 
pad_percents 2 
text_buffer_size 2048 
imlib_cache_size 0 
#--- LUA ---
lua_load /media/DATEN/francescoPC/Conky/Olgmen/Schief/rotate_clock.lua
lua_draw_hook_pre widgets

TEXT
${voffset 450}

rotate_clock.lua

--[[
Conky Widgets by olgmen (2010)

Скрипт позволяет выводить в окно CONKY часы

для запуска необходимо ввести до TEXT сдедующие строки

#--- LUA ---
lua_load ~/scripts/rotate_clock.lua
lua_draw_hook_pre widgets

при условии, что скрипт rotate_clock.lua сохранен в папке ~/scripts
]]

require 'cairo'

--[[ CLOCK WIDGET ]]

function clock(cr, x, y, s, bgc, bga, fgc, fga)

-- функция перекодировки цвета

	function rgb_to_r_g_b(colour,alpha)
		return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
	end
		-- назначаем толщину выводимых линий

		local s_th = 2

		-- перехватываем данные часы, минуты, секунды

		local hours=os.date("%I")
		local mins=os.date("%M")
		local secs=os.date("%S")
	
		-- назначаем максимальные значения

		secs_arc=(2*math.pi/60)*secs
		mins_arc=(2*math.pi/60)*mins
		hours_arc=(2*math.pi/12)*hours+mins_arc/12

		-- рисуем циферблат

		local radius = s/2	
		local m_x,m_y = x + s/2, y + s/2
		cairo_set_line_width(cr,6)

		-- поворот циферблата

		cairo_rotate (cr, 30*math.pi/180)

		-- элипс первая цифра - ширина, вторая - высота

		cairo_scale (cr, 0.6, 1)

		-- рисуем циферблат

		cairo_arc(cr, m_x,m_y, radius, 0, math.rad(360))
		cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
		cairo_fill_preserve(cr)
		cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
		cairo_stroke(cr)

		-- прозрачный "корпус часов"
	
		cairo_arc(cr, m_x, m_y, radius*1.25, 0, 2*math.pi)
		cairo_set_source_rgba(cr, 0.5, 0.5, 0.5, 0.8)
		cairo_set_line_width(cr,1)
		cairo_stroke(cr)
	
		local border_pat=cairo_pattern_create_linear(m_x, m_y - radius*1.25, m_x, m_y + radius*1.25)
	
		cairo_pattern_add_color_stop_rgba(border_pat,0,0,0,0,0.7)
		cairo_pattern_add_color_stop_rgba(border_pat,0.3,1,1,1,0)
		cairo_pattern_add_color_stop_rgba(border_pat,0.5,1,1,1,0)
		cairo_pattern_add_color_stop_rgba(border_pat,0.7,1,1,1,0)
		cairo_pattern_add_color_stop_rgba(border_pat,1,0,0,0,0.7)
		cairo_set_source(cr,border_pat)
		cairo_arc(cr, m_x, m_y, radius*1.125, 0, 2*math.pi)
		cairo_close_path(cr)
		cairo_set_line_width(cr, radius*0.25)
		cairo_stroke(cr)

		-- вывод часовых делений

		local i = 0
		local winkel = math.rad(30)		
		
		for i=0,11,1 do
		cairo_set_line_width(cr,s_th*1.5)
		cairo_move_to(cr, m_x-math.sin(winkel*i)*(radius*1.5), m_y-math.cos(winkel*i)*(radius*1.5))
		cairo_line_to(cr, m_x-math.sin(winkel*i)*(radius*0.9), m_y-math.cos(winkel*i)*(radius*0.9))
		cairo_fill_preserve(cr)
		cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
		cairo_stroke(cr)
		end

		-- вывод минутных делений

		local i = 0
		local winkel = math.rad(6)

		for i=0,59,1 do
		cairo_set_line_width(cr,1)
		cairo_move_to(cr, m_x-math.sin(winkel*i)*radius, m_y-math.cos(winkel*i)*radius)
		cairo_line_to(cr, m_x-math.sin(winkel*i)*(radius*0.9), m_y-math.cos(winkel*i)*(radius*0.9))
		cairo_stroke(cr)
		end

		-- рисуем деления 3, 6, 9 и 12 часовые

		cairo_set_line_width(cr,s_th/2)			-- устанавливаем толщину линий
		cairo_move_to (cr, x + 0.15*s, y + 0.5*s)
		cairo_line_to (cr, x + 0.45*s, y + 0.5*s)
		cairo_move_to (cr, x + 0.55*s, y + 0.5*s)
		cairo_line_to (cr, x + 0.85*s, y + 0.5*s)
		cairo_move_to (cr, x + 0.5*s, y + 0.15*s)
		cairo_line_to (cr, x + 0.5*s, y + 0.45*s)
		cairo_move_to (cr, x + 0.5*s, y + 0.55*s)
		cairo_line_to (cr, x + 0.5*s, y + 0.85*s)
		cairo_stroke(cr)


		-- ОКНО ВЫВОДА ДАТЫ

		-- задаем размер окна

		local wo = s/5
		local ho = s/12
		local ro = (wo+ho)/2*0.04
		local xo = x+0.2*s
		local yo = y+0.45*s
		-- рисуем окно
		cairo_move_to(cr, xo + ro, yo)
		cairo_line_to(cr, xo + wo - ro, yo)
		cairo_arc(cr, xo + wo - ro, yo + ro, ro, -math.pi/2,0)
		cairo_line_to(cr, xo + wo, yo + ho - ro)
		cairo_arc(cr, xo + wo - ro, yo + ho - ro, ro, 0, math.pi/2)
		cairo_line_to(cr, xo + ro, yo + ho)
		cairo_arc(cr, xo + ro, yo + ho - ro, ro, math.pi/2, math.pi)
		cairo_line_to(cr, xo, yo + ro)
		cairo_arc(cr, xo + ro, yo + ro, ro, math.pi, math.pi*1.5)
		-- закрашиваем в черный цвет
		cairo_set_source_rgba(cr, 0,0,0,0.1)
		cairo_fill(cr)
		-- выводим в окно дату
		local value = conky_parse("${time %b}")
		cairo_set_font_size(cr, (ho - 2 * ro)*(15/11))
		cairo_move_to(cr, xo + ro, yo + ho - ro)
		-- задаем белый цвет цифрам даты
		cairo_set_source_rgba(cr, 1, 1, 1, 1)
		cairo_show_text(cr, value)

		-- задаем размер окна

		local wo = s/6
		local ho = s/12
		local ro = (wo+ho)/2*0.04
		local xo = x+0.62*s
		local yo = y+0.45*s
		-- рисуем окно
		cairo_move_to(cr, xo + ro, yo)
		cairo_line_to(cr, xo + wo - ro, yo)
		cairo_arc(cr, xo + wo - ro, yo + ro, ro, -math.pi/2,0)
		cairo_line_to(cr, xo + wo, yo + ho - ro)
		cairo_arc(cr, xo + wo - ro, yo + ho - ro, ro, 0, math.pi/2)
		cairo_line_to(cr, xo + ro, yo + ho)
		cairo_arc(cr, xo + ro, yo + ho - ro, ro, math.pi/2, math.pi)
		cairo_line_to(cr, xo, yo + ro)
		cairo_arc(cr, xo + ro, yo + ro, ro, math.pi, math.pi*1.5)
		-- закрашиваем в черный цвет
		cairo_set_source_rgba(cr, 0,0,0,0)
		cairo_fill(cr)

		-- выводим в окно дату
		local value = conky_parse("${time %d}")
		cairo_set_font_size(cr, (ho - 2 * ro)*(15/11))
		cairo_move_to(cr, xo + ro, yo + ho - ro)
		-- задаем белый цвет цифрам даты
		cairo_set_source_rgba(cr, 1, 1, 1, 1)
		cairo_show_text(cr, value)

		local clock_r = s/2
		local xc = x + s/2
		local yc = y + s/2
	
		-- вывод часовой стрелки

		xh=xc+0.55*clock_r*math.sin(hours_arc)
		yh=yc-0.55*clock_r*math.cos(hours_arc)
		cairo_move_to(cr,xc,yc)
		cairo_line_to(cr,xh,yh)
		cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
		cairo_set_line_width(cr,6)
		cairo_set_source_rgba(cr, 0, 0, 1, 1)
		cairo_stroke(cr)

		-- вывод минутной стрелки
	
		xm=xc+0.7*clock_r*math.sin(mins_arc)
		ym=yc-0.7*clock_r*math.cos(mins_arc)
		cairo_move_to(cr,xc,yc)
		cairo_line_to(cr,xm,ym)
		cairo_set_line_width(cr,4)
		cairo_stroke(cr)

		-- вывод секундной стрелки
	
		xs=xc+0.75*clock_r*math.sin(secs_arc)
		ys=yc-0.75*clock_r*math.cos(secs_arc)
		cairo_move_to(cr,xc,yc)
		cairo_line_to(cr,xs,ys)
		cairo_set_line_width(cr,2)
		cairo_set_source_rgba(cr, 1, 0, 0, 1)
		cairo_stroke(cr)
		-- рисуем ось стрелок
		cairo_arc (cr, xc, yc, s*0.02, 0, 2*math.pi)
		cairo_fill (cr)

		-- глянец

		local h1 = s/2.5
		cairo_move_to(cr, x + radius, y)
		cairo_line_to(cr, x + s - radius, y)
		cairo_arc(cr, x + s - radius, y + radius, radius, -math.pi/2, 0)
		cairo_line_to(cr, x + s, y + h1)
		cairo_curve_to(cr, x + 3 * s/4, y + 1.3 * h1, x + s/4, y + 1.3 * h1, x, y + h1)
		cairo_line_to(cr, x, y + radius)
		cairo_arc(cr, x + radius, y + radius, radius, math.pi, math.pi * 1.5)
		cairo_set_source_rgba(cr, 1, 1, 1, 0.2)
		cairo_fill(cr)

end
--[[ END CLOCK ]]

--------------------------------
function conky_widgets()
	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)

---------------------------------
	
--[[ CLOCK ]]

	cr = cairo_create(cs)
	clock(cr, 500, -50, 200, 0x151515, 0.2, 0x606070, 0.9)
 
--          опции: x,  y,   s, bgc, bga, fgc, fga
--		"x" координаты по горизонтали центра часов
--		"y" координаты по вертикали центра часов
--		"s" диаметр часов
--		"bgc" цвет фона
--		"bga" яркость фона
--		"fgc" цвет графики
--		"fga" яркость графики

	cairo_destroy(cr)

end 

Thanks!

Last edited by unklar (2016-06-13 20:49:14)

Offline

#78 2016-04-04 18:17:41

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Conky - Calendars / Clocks / Time

Do you mean that the whole clock should rotate, or just the hands? The hands go round fine for me.

Have you set the correct lua path for your system? Is the one in the conkyrc yours, or the original?

lua_load /media/DATEN/francescoPC/Conky/Olgmen/Schief/rotate_clock.lua

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#79 2016-04-04 19:14:08

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Conky - Calendars / Clocks / Time

It's working fine here.
FGAnrNit.jpg tIBthHoS.jpg Xe9PBzox.jpg h7CEW8aa.jpg 7Axsx5QO.jpg

First I put a box around, to see the conky window limits, it and made it a bit bigger:

minimum_size 500 0

Then I played with the поворот циферблата (Rotation dial) :

		-- поворот циферблата
		-- Rotation dial

--		cairo_rotate (cr, 15*math.pi/180)
--		cairo_rotate (cr, 20*math.pi/180)
--		cairo_rotate (cr, 25*math.pi/180)
--		cairo_rotate (cr, 30*math.pi/180) -- original
--		cairo_rotate (cr, 35*math.pi/180)
--		cairo_rotate (cr, 40*math.pi/180)
--		cairo_rotate (cr, 45*math.pi/180)
--		cairo_rotate (cr, 50*math.pi/180)
--		cairo_rotate (cr, 55*math.pi/180)
		cairo_rotate (cr, 60*math.pi/180)

The clock does not 'rotate' by itself.  But one can rotate it between ±15° and ±60° on an axis in the conky window and still see it.

Interesting script.  Nice find unklar.

With a bigger window and a full circle one could probably get it going a full 360°, but an upside down clock ????


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#80 2016-04-04 19:50:52

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Conky - Calendars / Clocks / Time

Ok, then I misunderstood the ...

@damo, the original path to the script is:

lua_load ~/scripts/rotate_clock.lua
lua_draw_hook_pre widgets

@S11,
of course is not standing upside down the clock. I assumed it rotates by itself like a top.
http://www.amazon.de/Brummkreisel-Spiel … B0058BDNWI

Offline

Board footer

Powered by FluxBB