You are not logged in.
Nili wrote:An unforgettable time for sure. #!, respected teamwise members, interesting topics, old conky versions, systemd free, club-100, And endlessly waiting for Janice 12 to come out.
.conkyrc before lua was the best, so kudos to 1.9 legacy.
When i saw those clocks, they reminded me of many good things from 2008-2015. So, I'm glad you guys did some revisits of those conky.Me too had a good ride.
I preferred the old syntax as well...so much easier and cleaner. Made it easy to debug.
Would be cool if there's a 1.9 version that still compiles on Buster.
Yupper ... and I'm still a conky v1.9er.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Nice clock widget @loutch..reminds me of the old clock widget in Win Vista.
Real Men Use Linux
Offline
RE
Sence clocks for Rainmeter by Marc22
@+
Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX
Offline
hello
Modificated chronograph from hfcf
https://i.postimg.cc/Kjh6n5Wq/Capture-d-cran-2023-04-14-10-36-54.png
https://i.postimg.cc/F7K5Ys6h/Capture-d-cran-2023-04-14-10-29-44.png
@+
absolutely awesome!
Configuration files please.
Offline
Re
conkyrc
conky.config = {
background = true,
use_xft = true,
font = 'gerinald:size=7',
xftalpha = 1,
update_interval = 1.0,
total_run_times = 0,
net_avg_samples = 2,
own_window = true,
own_window_transparent = true,
--own_window_color 000000
own_window_argb_visual = true,
--own_window_argb_value = 250,
own_window_type = 'normal',
own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',
double_buffer = true,
minimum_width = 320, minimum_height = 320,
maximum_width = 320,
text_buffer_size = 2048,
draw_shades = false,
draw_outline = false,
draw_borders = false,
draw_graph_borders = false,
default_color = 'white',
default_outline_color = 'white',
alignment = 'top_right',
gap_x = 120,
gap_y = 70,
no_buffers = true,
uppercase = false,
cpu_avg_samples = 2,
override_utf8_locale = true,
imlib_cache_flush_interval = 60,
imlib_cache_size = 10000,
stippled_borders = 5,
-- Couleurs
default_color = '#ffffff', --ffd579
default_shade_color = '#333333',
default_outline_color = 'black',
lua_load = '~/.conky/cronograph/scripts/loader.lua',
lua_draw_hook_pre = 'loader_lua',
};
conky.text = [[
${voffset 66}${alignc 14}${time %d}
${voffset 01}${alignc 20}${time %a} ${offset 8}${time %b}
${voffset 50}${goto 96}${cpu cpu0} % ${goto 188}${cpu cpu1} %
${voffset 50}${alignc 6}${uptime}
${execpi 1 cat ~/.conky/cronograph/scripts/blinkingLED}
${lua fDrawImage $HOME/.conky/cronograph/images/c2.png 0 0 300 300}
]];
loader.lua
require 'cairo'
function conky_loader_lua()
usrhome = os.getenv("HOME")
dofile (usrhome .."/.conky/cronograph/scripts/clock_rings.lua")
dofile (usrhome .."/.conky/cronograph/scripts/multi_rings.lua")
dofile (usrhome .."/.conky/lua/image.lua")
conky_main()
conky_clock_rings()
end
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.2,
-- "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.8,
-- "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=124,
-- "thickness" is the thickness of the ring, centred around the radius.
thickness=3,
-- "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.2,
fg_colour=0xFFFFFF,
fg_alpha=0.8,
x=150, y=150,
radius=120,
thickness=2,
start_angle=0,
end_angle=360
},
{
name='time',
arg='%S',
max=60,
bg_colour=0xFFFFFF,
bg_alpha=0.2,
fg_colour=0xFFFFFF,
fg_alpha=0.8,
x=150, y=150,
radius=116,
thickness=2,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0x000000,
bg_alpha=0.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=150,
radius=66,
thickness=130,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0xFFFFFF,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=150,
radius=1,
thickness=10,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0xFFFFFF,
bg_alpha=0.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=85, y=150,
radius=30,
thickness=1,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0x000000,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=85, y=150,
radius=15,
thickness=27,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0xFFFFFF,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=85, y=150,
radius=1,
thickness=2,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0xFFFFFF,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=215, y=150,
radius=30,
thickness=1,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0x000000,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=215, y=150,
radius=15,
thickness=27,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0xFFFFFF,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=215, y=150,
radius=1,
thickness=2,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0xFFFFFF,
bg_alpha=0.0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=75,
radius=25,
thickness=1,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0x000000,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=75,
radius=13,
thickness=22,
start_angle=0,
end_angle=360
},
{
name='',
arg='',
max=100,
bg_colour=0xFFFFFF,
bg_alpha=0,
fg_colour=0xFFFFFF,
fg_alpha=0.0,
x=150, y=75,
radius=1,
thickness=2,
start_angle=0,
end_angle=360
},
}
-- Use these settings to define the origin and extent of your clock.
clock_r=100
-- "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
multi_rings.lua
--==============================================================================
-- multi_rings.lua
--
-- author : SLK
-- version : v2011011601
-- license : Distributed under the terms of GNU GPL version 2 or later
--
--==============================================================================
require 'cairo'
--------------------------------------------------------------------------------
-- clock DATA
-- HOURS
clock_h = {
{
name='time', arg='%H', max_value=12,
x=150, y=150,
graph_radius=140,
graph_thickness=0,
graph_unit_angle=30, graph_unit_thickness=5,
graph_bg_colour=0xffffff, graph_bg_alpha=0.,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
txt_radius=100,
txt_weight=1, txt_size=10.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=125,
graduation_thickness=10, graduation_mark_thickness=2,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
},
}
-- MINUTES
clock_m = {
{
name='time', arg='%M', max_value=60,
x=150, y=150,
graph_radius=100,
graph_thickness=3,
graph_unit_angle=6, graph_unit_thickness=3,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
txt_radius=100,
txt_weight=0, txt_size=9.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=57,
graduation_thickness=0, graduation_mark_thickness=2,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
},
}
-- SECONDS
clock_s = {
{
name='time', arg='%S', max_value=60,
x=150, y=150,
graph_radius=50,
graph_thickness=32,
graph_unit_angle=6, graph_unit_thickness=3,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
txt_radius=100,
txt_weight=0, txt_size=12.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=0,
graduation_thickness=0, graduation_mark_thickness=0,
graduation_unit_angle=0,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
},
}
--------------------------------------------------------------------------------
-- gauge DATA
gauge = {
{
name='cpu', arg='cpu0', max_value=100,
x=105, y=150,
graph_radius=10,
graph_thickness=15,
graph_start_angle=0,
graph_unit_angle=3.5, graph_unit_thickness=3.0,
graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0,
txt_radius=1,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=27,
graduation_thickness=4, graduation_mark_thickness=4,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
},
{
name='cpu', arg='cpu1', max_value=100,
x=195, y=150,
graph_radius=10,
graph_thickness=15,
graph_start_angle=0,
graph_unit_angle=3.5, graph_unit_thickness=3.0,
graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0,
txt_radius=1,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=27,
graduation_thickness=4, graduation_mark_thickness=4,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
},
{
name='fs_used_perc', arg='/', max_value=100,
x=150, y=75,
graph_radius=10,
graph_thickness=23,
graph_start_angle=0,
graph_unit_angle=3.5, graph_unit_thickness=3.0,
graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
hand_fg_colour=0xFFFFFF, hand_fg_alpha=0,
txt_radius=1,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=22,
graduation_thickness=4, graduation_mark_thickness=4,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
},
}
-------------------------------------------------------------------------------
-- rgb_to_r_g_b
-- converts color in hexa to decimal
--
function rgb_to_r_g_b(colour, alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
-------------------------------------------------------------------------------
-- angle_to_position
-- convert degree to rad and rotate (0 degree is top/north)
--
function angle_to_position(start_angle, current_angle)
local pos = current_angle + start_angle
return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end
-------------------------------------------------------------------------------
-- draw_clock_ring
-- displays clock
--
function draw_clock_ring(display, data, value)
local max_value = data['max_value']
local x, y = data['x'], data['y']
local graph_radius = data['graph_radius']
local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
local graph_unit_angle = data['graph_unit_angle']
local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
-- background ring
cairo_arc(display, x, y, graph_radius, 0, 2 * math.pi)
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
cairo_set_line_width(display, graph_thickness)
cairo_stroke(display)
-- arc of value
local val = (value % max_value)
local i = 1
while i <= val do
cairo_arc(display, x, y, graph_radius,( ((graph_unit_angle * i) - graph_unit_thickness)*(2*math.pi/360) )-(math.pi/2),((graph_unit_angle * i) * (2*math.pi/360))-(math.pi/2))
cairo_set_source_rgba(display,rgb_to_r_g_b(graph_fg_colour,graph_fg_alpha))
cairo_stroke(display)
i = i + 1
end
local angle = (graph_unit_angle * i) - graph_unit_thickness
-- graduations marks
local graduation_radius = data['graduation_radius']
local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
local graduation_unit_angle = data['graduation_unit_angle']
local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
local nb_graduation = 360 / graduation_unit_angle
local i = 1
while i <= nb_graduation do
cairo_set_line_width(display, graduation_thickness)
cairo_arc(display, x, y, graduation_radius, (((graduation_unit_angle * i)-(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2),(((graduation_unit_angle * i)+(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2))
cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
cairo_stroke(display)
cairo_set_line_width(display, graph_thickness)
i = i + 1
end
end
-- text
local txt_radius = data['txt_radius']
local txt_weight, txt_size = data['txt_weight'], data['txt_size']
local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
local movex = txt_radius * (math.cos((angle * 2 * math.pi / 360)-(math.pi/2)))
local movey = txt_radius * (math.sin((angle * 2 * math.pi / 360)-(math.pi/2)))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight);
cairo_set_font_size (display, txt_size);
cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha));
cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3);
cairo_show_text (display, value);
cairo_stroke (display);
end
-------------------------------------------------------------------------------
-- draw_gauge_ring
-- displays gauges
--
function draw_gauge_ring(display, data, value)
local max_value = data['max_value']
local x, y = data['x'], data['y']
local graph_radius = data['graph_radius']
local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
local graph_start_angle = data['graph_start_angle']
local graph_unit_angle = data['graph_unit_angle']
local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
local graph_end_angle = (max_value * graph_unit_angle) % 360
-- background ring
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
cairo_set_line_width(display, graph_thickness)
cairo_stroke(display)
-- arc of value
local val = value % (max_value + 1)
local start_arc = 0
local stop_arc = 0
local i = 1
while i <= val do
start_arc = (graph_unit_angle * i) - graph_unit_thickness
stop_arc = (graph_unit_angle * i)
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
cairo_stroke(display)
i = i + 1
end
local angle = start_arc
-- hand
start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2)
stop_arc = (graph_unit_angle * val)
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
cairo_stroke(display)
-- graduations marks
local graduation_radius = data['graduation_radius']
local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
local graduation_unit_angle = data['graduation_unit_angle']
local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
local nb_graduation = graph_end_angle / graduation_unit_angle
local i = 0
while i < nb_graduation do
cairo_set_line_width(display, graduation_thickness)
start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
cairo_stroke(display)
cairo_set_line_width(display, graph_thickness)
i = i + 1
end
end
-- text
local txt_radius = data['txt_radius']
local txt_weight, txt_size = data['txt_weight'], data['txt_size']
local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight)
cairo_set_font_size (display, txt_size)
cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
cairo_show_text (display, value)
cairo_stroke (display)
-- caption
local caption = data['caption']
local caption_weight, caption_size = data['caption_weight'], data['caption_size']
local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight);
cairo_set_font_size (display, caption_size)
cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
cairo_move_to (display, x + tox + 5, y + toy + 1)
-- bad hack but not enough time !
if graph_start_angle < 105 then
cairo_move_to (display, x + tox - 30, y + toy + 1)
end
cairo_show_text (display, caption)
cairo_stroke (display)
end
-------------------------------------------------------------------------------
-- go_clock_rings
-- loads data and displays clock
--
function go_clock_rings(display)
local function load_clock_rings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
value = tonumber(str)
draw_clock_ring(display, data, value)
end
for i in pairs(clock_h) do
load_clock_rings(display, clock_h[i])
end
for i in pairs(clock_m) do
load_clock_rings(display, clock_m[i])
end
for i in pairs(clock_s) do
load_clock_rings(display, clock_s[i])
end
end
-------------------------------------------------------------------------------
-- go_gauge_rings
-- loads data and displays gauges
--
function go_gauge_rings(display)
local function load_gauge_rings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
value = tonumber(str)
draw_gauge_ring(display, data, value)
end
for i in pairs(gauge) do
load_gauge_rings(display, gauge[i])
end
end
-------------------------------------------------------------------------------
-- MAIN
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)
local display = cairo_create(cs)
local updates = conky_parse('${updates}')
update_num = tonumber(updates)
if update_num > 5 then
go_clock_rings(display)
go_gauge_rings(display)
end
end
images here ( must modify it with gimp to have transparency) (color to alpha)
https://www.automotivpress.fr/wp-conten … 4x1024.jpg
@+
Last edited by loutch (2023-04-25 14:25:41)
Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX
Offline
Ach ja, eine ganz schöne Sammlung
ah yeah quite a collection .
@+
Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX
Offline
You both are awesome.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
You both are awesome.
Thanks a lot my friend
I finally once converted your configuration of this @easysid clock to lua. Always wanted to do but, as you know, we never have time.
For hours now I've been trying to put a matching rgb color on the 'month's circle', because black doesn't do well on a black desktop background.
Would you maybe have an idea for a color?
It's about this section and all light colors look crappy in the display:
cairo_set_source_rgba(cr,0.00,0.00,0.00,1) -- circle colour: Black
linie 31 + 61 in yearclock.lua
e.g.
0.244,0.164,0.96,1
etc. for
color4 = 'F4A460', --SandyBrown
Last edited by unklar (2023-04-17 09:29:33)
Offline
That
0.244,0.164,0.96,1
is exactly what yad colour tells me is the RGB equivalent for "SandyBrow" as well as:
https://convertingcolors.com/hex-color-F4A460.html
But it ends up more a purple colour, so I'm confused here.
But then I have always been bad when it comes to LUA
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
BINGO! I have something. Look at this text file:
colour-grey-33-shades.txt
Web Safe
Shade Name Hex val R G B
Black #000000 0 0 0 rgb(0.00,0.00,0.00)
#1a1a1a 26 26 26 rgb(0.10,0.10,0.10)
#222222 34 34 34 rgb(0.13,0.13,0.13)
Darkslategray #2F4F4F 47 79 79 rgb(0.18,0.31,0.31)
#333333 51 51 51 rgb(0.18,0.31,0.31)
#444444 68 68 68 rgb(0.27,0.27,0.27)
#4d4d4d 77 77 77 rgb(0.30,0.30,0.30)
#666666 102 102 102 rgb(0.40,0.40,0.40)
Dimgray #696969 105 105 105 rgb(0.41,0.41,0.41)
Slategray #708090 112 128 144 rgb(0.44,0.50,0.56)
Lightslategray #778899 119 136 153 rgb(0.47,0.53,0.60)
Gray #808080 128 128 128 rgb(0.50,0.50,0.50)
#8a8a8a 137 137 137 rgb(0.54,0.54,0.54)
#999999 152 152 152 rgb(0.60,0.60,0.60)
#a0a0a0 160 160 160 rgb(0.63,0.63,0.63)
Darkgray #a9a9a9 169 169 169 rgb(0.66,0.66,0.66)
ab-grey #ababab 171 171 171 rgb(0.67,0.67,0.67)
b3-grey #b3b3b3 178 178 178 rgb(0.70,0.70,0.70)
#bababa 187 187 187 rgb(0.73,0.73,0.73)
Silver #c0c0c0 192 192 192 rgb(0.75,0.75,0.75)
#cccccc 204 204 204 rgb(0.80,0.80,0.80)
Lightgray #d3d3d3 211 211 211 rgb(0.83,0.83,0.83)
Gainsboro #dcdcdc 220 220 220 rgb(0.86,0.86,0.86)
#dddddd 221 221 221 rgb(0.87,0.87,0.87)
#dedede 222 222 222 rgb(0.87,0.87,0.87)
#dfdfdf 223 223 223 rgb(0.87,0.87,0.87)
#e0e0e0 224 224 224 rgb(0.88,0.88,0.88)
#e6e6e6 229 229 229 rgb(0.90,0.90,0.90)
#ededed 238 238 238 rgb(0.93,0.93,0.93)
Whitesmoke #F5F5F5 245 245 245 rgb(0.96,0.96,0.96)
#FAFAFA 250 250 250 rgb(0.98,0.98,0.98)
#FBFBFB 251 251 251 rgb(0.98,0.98,0.98)
White #FFFFFF 255 255 255 rgb(1.00,1.00,1.00)
EDIT:
30 shades of grey:
${color 000000}101 ${color 1a1a1a}201 ${color 222222}301
${color 2F4F4F}102 ${color 333333}202 ${color 444444}302
${color 4d4d4d}103 ${color 666666}203 ${color 696969}303
${color 708090}104 ${color 778899}204 ${color 808080}304
${color 8a8a8a}105 ${color 999999}205 ${color a0a0a0}305
${color a9a9a9}106 ${color ababab}206 ${color b3b3b3}306
${color bababa}107 ${color c0c0c0}207 ${color cccccc}307
${color d3d3d3}108 ${color dcdcdc}208 ${color dddddd}308
${color dedede}109 ${color dfdfdf}209 ${color e0e0e0}309
${color e6e6e6}110 ${color ededed}210 ${color F5F5F5}310
${color FAFAFA}111 ${color FBFBFB}211 ${color FFFFFF}311
image seen here
Take a close look at "LightSlateGrey"
cairo_set_source_rgba(cr,0.47,0.53,0.60,1) -- circle colour: LightSlateGray
Somewhere here I have a bash script, that @nobody gave me, that does that conversion.
Let me find it and I'll post it.
Last edited by Sector11 (2023-04-17 15:24:43)
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
@unklar and everyone else that wants to do colours in LUA scripts.
Check it out:
Index» Basic Help & Support» [SOLVED] Cairo colour codes (used in LUA)
Check out the bash script: rgb in the 3rd post. KUDOS @nobody!
SandyBrown = F4A460 - or:
17 Apr 23 @ 11:36:45 ~
$ rgb f4a460
f4a460 rgb(0.96,0.64,0.38)
17 Apr 23 @ 11:37:08 ~
$
So the lines would be:
cairo_set_source_rgba(cr,0.96,0.64,0.38,1) -- circle color SandyBrown
cairo_set_source_rgba(cr,0.96,0.64,0.38,1) -- dot color SandyBrown
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
KUDOS, my friend! I didn't have to do anything again, you did all the work and searching for me with this awesome script from @nobody. Brilliant!
At that time (2016), I had not understood the whole thing, which is why I had never saved this script.
Thank you, El Conkystatdor!
Last edited by unklar (2023-04-17 15:59:50)
Offline
So it's actually two watches that @S11 has compinated here in 2016.
I do not want such gems because of the syntax1.10 in Conky, disappear into oblivion, such as mrpeachy's chronograph.
Therefore here the 'new' configuration. Have fun! S11_YearClock.conky
conkyrc
-- Concept-Idea 04-2016 @Sector11
-- rgb-color-script @nobody https://forums.bunsenlabs.org/viewtopic.php?pid=22917#p22917
-- Lua-Syntax 1.10, 04-2023 @unklar
conky.config = {
background = true,
use_xft = true,
font = 'monofur:size=14',
xftalpha = 1,
update_interval = 1.0,
total_run_times = 0,
cpu_avg_samples = 2,
net_avg_samples = 2,
own_window = true,
own_window_transparent = true,
--own_window_color 000000
--own_window_argb_visual = true,
--own_window_argb_value = 250,
own_window_type = 'normal',
own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',
double_buffer = true,
no_buffers = true,
minimum_width = 600, minimum_height = 600,
--maximum_width = 320,
text_buffer_size = 2048,
draw_shades = true,
draw_outline = false,
draw_borders = false,
draw_graph_borders = true,
stippled_borders = 0,
border_width = 0,
border_inner_margin = 5,
border_outer_margin = 0,
alignment = 'middle_middle',
gap_x = 0,
gap_y = 0,
uppercase = false,
use_spacer = 'none',
override_utf8_locale = true,
--imlib_cache_flush_interval = 60,
--imlib_cache_size = 10000,
draw_shades = true,
default_shade_color = '000000',
draw_outline = false,
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
lua_load = '~/.conky/S11_YearClock/scripts/loader.lua',
lua_draw_hook_pre = 'loader_lua',
};
conky.text = [[
${voffset 140}${goto 180}${color4}Month ${color1}Day ${color}Hour ${color6}Minute ${color9}Second${color}
${goto 180}${color4}${time %m} ${color1}${time %d} ${color}${time %H} ${color6}${time %M} ${color9}${time %S}${color}
]];
loader.lua
require 'cairo'
function conky_loader_lua()
usrhome = os.getenv("HOME")
dofile (usrhome .."/.conky/S11_YearClock/scripts/yearclock.lua")
dofile (usrhome .."/.conky/S11_YearClock/scripts/clock_easysid.lua")
conky_draw_clock()
conky_es_clock()
end
yearclock.lua
--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.96,0.64,0.38,1) -- circle color SandyBrown
--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.96,0.64,0.38,1) -- dot color SandyBrown
--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
clock_easysid.lua
--[[ 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
Offline
mrpeachy's-chronograph
conkyrc
--[[ pkill -xf "conky -c ~/Conky/The_Clock.conky" &
Chronograph LUA - mrpeachy (originally 4 clocks - tweaked by Sector11)
LUA-Syntax 1.10, 04-2023 @unklar
https://thepeachyblog.blogspot.com/p/index-or-home-page.html
]]
conky.config = {
own_window = true,
--own_window_colour ff0000
own_window_class = 'Conky',
own_window_transparent = true,
own_window_argb_visual = true,
own_window_type = 'normal',
own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',--
minimum_width = 320, minimum_height = 320,
maximum_width = 320,
alignment = 'top_right',-- tl, tm, tr, bl, bm, br, ml, mr
gap_x = 40,
gap_y = 0,
background = false,
draw_borders = false,
stippled_borders = 1,
border_width = 1,
draw_graph_borders = false,
draw_shades = false,
draw_outline = false,
use_spacer = 'right',
default_color = 'ffffff',
default_shade_color = '000000',
default_outline_color = 'ffffff',
color0 = 'FFFF00',
color1 = 'white',
color2 = 'yellow',
color3 = 'red',
use_xft = true,
font = 'Ubuntu:size=9',
xftalpha = 1,
uppercase = false,
override_utf8_locale = true,
update_interval = 1,
total_run_times = 0,
double_buffer = true,
no_buffers = true,
cpu_avg_samples = 2,
net_avg_samples = 2,
imlib_cache_size = 0,
short_units = true,
pad_percents = 2,
text_buffer_size = 2048,
imlib_cache_size = 0,
lua_load = '~/.conky/cronograph/crono.lua',
lua_draw_hook_pre = 'main',
};
conky.text = [[
]];
crono.lua
--chronograph mrpeachy 12/13/12 - i blame sector11 for starting the whole chronograph thing!
require 'cairo'
extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
function conky_main()
if conky_window == nil then return end
local updates=tonumber(conky_parse("${updates}"))
if updates<=3 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)
--#########################################################################################################
--defaults
default_font_name="White Rabbit"
default_font_size=22
default_font_face="n"
default_hex_color=0xffffff
default_alpha=1
default_red=1
default_green=1
default_blue=1
default_horizontal_justify="l" --"l"=left, "r"=right, "c"=center
default_vertical_justify="n" --"n"=normal, "nb"=normal-ybearing, "m"=middle, "mb"=middle-ybearing, "t"=top
default_rotation="0"
--font({f="name",fs=size,ff="face"}) face="n" or "b" or "i" or "bi"
--hexcolor({c=hexcolor,a=alpha})
--rgbcolor({r=,g=,b=,a=})
--text({x=x,y=y,t="text",hj=horizontal_justify,vj=vertical_justify,r=rotation})
--set center coordinates
centx,centy=200,200
--########################################################################################
--background circle
hexcolor({c=0x3c3c3c})
cairo_arc(cr,centx,centy,118,0,2*math.pi)
cairo_fill(cr)
--background circle
hexcolor({c=0x212121})
cairo_arc(cr,centx,centy,108,0,2*math.pi)
cairo_fill(cr)
--setup font and color
font({})
hexcolor({c=0xccaa7a})
--draw numbers and dots around main circle
for i=1,12 do
if i==12 or i==4 or i==8 then
x,y=pt(centx,centy,84,((360/12)*i))
text({y=y,x=x,t=i,hj="c",vj="m"})
end
if i==2 or i==6 or i==10 then
hexcolor({c=0xdac09b})
x,y=pt(centx,centy,98,((360/12)*i))
cairo_arc(cr,x,y,6,0,2*math.pi)
cairo_fill(cr)
else
hexcolor({c=0xccaa7a})
x,y=pt(centx,centy,98,((360/12)*i))
cairo_arc(cr,x,y,4,0,2*math.pi)
cairo_fill(cr)
end
end--for
--draw inbetween marks
cairo_set_line_width(cr,1)
for i=1,60 do
if string.find(i/5,"%.")~=nil then
x,y=pt(centx,centy,108,((360/60)*i))
cairo_move_to(cr,x,y)
x,y=pt(centx,centy,98,((360/60)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
end
end--for
--outer circle
cairo_arc(cr,centx,centy,108,0,2*math.pi)
cairo_stroke(cr)
--########################################################################################
--hours of day at 2 position
dcx,dcy=pt(centx,centy,98,60)
font({fs=8})
--numbers
for i=0,24,3 do
x,y=pt(dcx,dcy,68,180+((120/24)*i))
text({y=y,x=x,t=string.format("%02d",i),hj="c",vj="m"})
end--for
--marks
for i=0,24 do
if string.find(i/3,"%.")~=nil and i~=0 then
x,y=pt(dcx,dcy,60,180+((120/24)*i))
cairo_move_to(cr,x,y)
x,y=pt(dcx,dcy,56,180+((120/24)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
else
x,y=pt(dcx,dcy,58,180+((120/24)*i))
cairo_arc(cr,x,y,1.5,0,2*math.pi)
cairo_fill(cr)
end
end
--day name
font({fs=22})
dtx,dty=pt(dcx,dcy,30,180+60)
text({x=dtx,y=dty,t=string.upper(os.date("%a")),hj="c",vj="m"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
hour=tonumber(os.date("%H"))
dpx,dpy=pt(dcx,dcy,54,180+(120*(hour/24)))
cairo_move_to(cr,dcx,dcy)
cairo_line_to(cr,dpx,dpy)
cairo_stroke(cr)
--########################################################################################
--days of month at 6 position
font({fs=8})
hexcolor({c=0xccaa7a})
cairo_set_line_width(cr,1)
mcx,mcy=pt(centx,centy,98,180)
--date calcs
local year=os.date("%G")
local today=tonumber(os.date("%d"))
local t1 = os.time({year=year,month=03,day=01,hour=00,min=0,sec=0});
local t2 = os.time({year=year,month=02,day=01,hour=00,min=0,sec=0});
local feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={31,feb,31,30,31,30,31,31,30,31,30,31}
local month=os.date("%m")
local mdays=monthdays[tonumber(month)]
--marks
for i=1,mdays do
if string.find((i-1)/3,"%.")~=nil then
x,y=pt(mcx,mcy,60,300+((120/mdays)*i))
cairo_move_to(cr,x,y)
x,y=pt(mcx,mcy,56,300+((120/mdays)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
else
x,y=pt(mcx,mcy,60,300+((120/mdays)*i))
cairo_move_to(cr,x,y)
x,y=pt(mcx,mcy,54,300+((120/mdays)*i))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
end
end--for
--numbers
for i=1,mdays,3 do
x,y=pt(mcx,mcy,68,300+((120/mdays)*i))
text({y=y,x=x,t=string.format("%02d",i),hj="c",vj="m"})
end--for
--month name
font({fs=22})
text({x=mcx,y=mcy-30,t=string.upper(os.date("%b")),hj="c",vj="m"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
day=tonumber(os.date("%e"))
mpx,mpy=pt(mcx,mcy,52,300+(120*(day/mdays)))
cairo_move_to(cr,mcx,mcy)
cairo_line_to(cr,mpx,mpy)
cairo_stroke(cr)
--########################################################################################
--months of year at 10 position
font({fs=8})
hexcolor({c=0xccaa7a})
cairo_set_line_width(cr,1)
ycx,ycy=pt(centx,centy,98,5*60)
--date calculations
td=0
for i=1,12 do
td=td+monthdays[i]
end
angle={}
ang=0
for i=1,12 do
ang=((monthdays[i]/td)*120)+ang
angle[i]=ang
end
months={"J","F","M","A","M","J","J","A","S","O","N","D"}
--arc line
cairo_arc(cr,ycx,ycy,60,adeg(60),adeg(60+ang))
cairo_stroke(cr)
--arc marks
for i=0,12 do
x,y=pt(ycx,ycy,60,60+((angle[i] or 0)))
cairo_move_to(cr,x,y)
x,y=pt(ycx,ycy,56,60+((angle[i] or 0)))
cairo_line_to(cr,x,y)
cairo_stroke(cr)
end
--month letters
for i=1,12 do
x,y=pt(ycx,ycy,68,60+((120/12)*i)-(120/24))
text({y=y,x=x,t=months[i],hj="c",vj="m"})
end--for
--year text
font({fs=22})
ytx,yty=pt(ycx,ycy,30,60+60)
text({x=ytx,y=yty,t=string.upper(os.date("%y")),hj="c",vj="m"})
font({fs=12})
text({x=ytx-4,y=yty-10,t="20",hj="c",vj="n"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
today=tonumber(os.date("%j"))-1
ypx,ypy=pt(ycx,ycy,55,60+(120*(today/td)))
cairo_move_to(cr,ycx,ycy)
cairo_line_to(cr,ypx,ypy)
cairo_stroke(cr)
--center circle
hexcolor({c=0xdac09b,a=1})
cairo_arc(cr,centx,centy,5,0,2*math.pi)
cairo_stroke(cr)
--hand calculations #######################################################
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
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*12))
--call hand drawing function
--hexcolor({c=0xccaa7a,a=0.8})
hexcolor({c=0xdac09b,a=0.8})
cairo_set_line_width(cr,2)
hands(
centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y
hsec_degs,--string or value for hand degrees
70,--string or value for hand length (radius)
3,--set hand center width in pixels
10,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.9--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)
--[[hands(
centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y
hsec_degs+180,--string or value for hand degrees
30,--string or value for hand length (radius)
6,--set hand center width in pixels
18,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
.8--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)--]]
--MINUTES HAND
--hexcolor({c=0xdac09b,a=0.8})
hands(
200,--string or coodinate for clock center x
200,--string or coodinate for clock center y
360*((m_to_s+seconds)/(60*60)),--string or value for hand degrees
90,--string or value for hand length (radius)
3,--set hand center width in pixels
8,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.9--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)
--[[hands(
200,--string or coodinate for clock center x
200,--string or coodinate for clock center y
180+(360*((m_to_s+seconds)/(60*60))),--string or value for hand degrees
30,--string or value for hand length (radius)
4,--set hand center width in pixels
18,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.8--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)--]]
--#########################################################################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end--end main function
--this function draws hands
function hands(clock_centerx,clock_centery,degrees,length,hand_center_width,hand_mid_width,hand_end_width,distance_to_mid)
--draw_middle
--calc start point
xs,ys=pt(clock_centerx,clock_centery,hand_center_width,degrees-90)
cairo_move_to(cr,xs,ys)
x1,y1=pt(clock_centerx,clock_centery,length*distance_to_mid,degrees-(hand_mid_width/2))
cairo_line_to (cr,x1,y1)
x2,y2=pt(clock_centerx,clock_centery,length,degrees)
cairo_arc(cr,x2,y2,hand_end_width,(degrees+180)*(math.pi/180),(degrees)*(math.pi/180))
--cairo_line_to (cr,x2,y2)
x3,y3=pt(clock_centerx,clock_centery,length*distance_to_mid,degrees+(hand_mid_width/2))
cairo_line_to (cr,x3,y3)
--calc end point
xe,ye=pt(clock_centerx,clock_centery,hand_center_width,degrees+90)
cairo_line_to (cr,xe,ye)
cairo_arc(cr,clock_centerx,clock_centery,hand_center_width,(degrees)*(math.pi/180),(degrees+180)*(math.pi/180))
cairo_fill(cr)
end
function adeg(deg)
return(math.pi/180)*(deg-90)
end
function pt(px,py,prad,pdeg)
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1
end
function font(fontt)
local name=fontt.f or default_font_name or "mono"
local size=fontt.fs or default_font_size or 12
local face=fontt.ff or default_font_face or "n"
if face=="n" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="b" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
elseif face=="i" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="bi" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD)
end
cairo_set_font_size(cr,size)
end
function hexcolor(hexcolort)
local col=hexcolort.c or default_hex_color or 0xffffff
local a=hexcolort.a or default_alpha or 1
local r,g,b=((col/0x10000) % 0x100)/255,((col/0x100) % 0x100)/255,(col % 0x100)/255
cairo_set_source_rgba(cr,r,g,b,a)
end
function rgbcolor(rgbcolort)
local r=rgbcolort.r or default_red or 1
local g=rgbcolort.g or default_green or 1
local b=rgbcolort.b or default_blue or 1
local a=rgbcolort.a or default_alpha or 1
cairo_set_source_rgba(cr,r,g,b,a)
end
function text(textt)
local x=textt.x or 100
local y=textt.y or 100
local t=textt.t or "set txt"
local hj=textt.hj or default_horizontal_justify or "l"
local vj=textt.vj or default_vertical_justify or "n"
local r=textt.r or default_rotation or 0
cairo_text_extents(cr,t,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
--hl-- l=left, c=center, r=right
if hj=="l" then
xa=x-bx
rad=0
elseif hj=="c" then
xa=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
xa=x-wx
rad=wx-bx
else
print ('hj not set correctly for text: '..t..' - "l", "c" or "r"')
xa=0
rad=0
end
--vj-- n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
ya=y
rad2=0
ry=by
elseif vj=="nb" then
ya=y-by
rad2=-by
ry=by
elseif vj=="m" then
ya=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
ya=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
ya=y+hy-by
rad2=hy-by
ry=0+by
else
print ('vj not set correctly for text: '..t..' - "n", "nb", "m", "mb" or "t"')
ya=0
rad2=0
ry=0
end
--rotation
if r~=0 then
local x2,y2=pt(x,y,rad2,r-180)
local x1,y1=pt(x2,y2,rad,r-90)
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*r)
cairo_show_text (cr,t)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,xa,ya)
cairo_show_text (cr,t)
cairo_stroke (cr)
end--if ro
--set non local variables to nil
xa=nil;ya=nil;rad=nil;rad2=nil;ry=nil
end--function text ###################################################################
- i blame sector11 for starting the whole chronograph thing!
Last edited by unklar (2023-04-18 08:05:32)
Offline
KUDOS, my friend! I didn't have to do anything again, you did all the work and searching for me with this awesome script from @nobody. Brilliant!
KUDOS really go to @nobody. I just asked the question. I went looking in my ~/bin folder saw "rgb" since I commented in the BL thread it was a given to post that link for you.
I cannot take credit for either of those clocks, purely mrpeachy and easysid who get the KUDOS
All I did was put them together in one conky so this:
-- Concept-Idea 04-2016 @Sector11
I can accept. Thank you for that.
- i blame sector11 for starting the whole chronograph thing!
Oh how I remember that remark.
mrpeachy, wherever you are, thank you for being.
And as I use to say back then, "When it comes to LUA I can't create a thing. All I can do is bend, fold and mutilate them.
SandyBrown looks awesome unklar!
This post, and the conky above, are proof that conky isn't always a one man show, but the combined efforts of many.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
This post, and the conky above, are proof that conky isn't always a one man show, but the combined efforts of many.
Noted.
Wise words of a Conky fan young at heart. CHIMO!
Offline
Sector11 wrote:This post, and the conky above, are proof that conky isn't always a one man show, but the combined efforts of many.
Noted.
Wise words of a Conky fan young at heart. CHIMO!
We are a legion of Conkystadors united by a single cause to help conky go where no conky has gone before!
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline