You are not logged in.

#1 2021-10-11 05:14:42

ohnonot
...again
Registered: 2015-09-29
Posts: 5,568

Conky and Lua

Let this be a collection of tips, scripts and questions about using lua with conky.

For starters, mrpeachy once wrote a lua tutorial that is still featured on conky github wiki.

Bunsenlabs forum is often under the top search results for web searches regarding conky.

PS:
This thread is meant for a constructive discussion of the possibilities of conky & lua. Let's please keep it that way.

Last edited by ohnonot (2021-10-12 05:49:19)


Give to COVAX! Here or here. (explanation)
My Repos: notabug | framagit

Offline

#2 2021-10-11 05:19:48

ohnonot
...again
Registered: 2015-09-29
Posts: 5,568

Re: Conky and Lua

lua & conky can also draw SVG images:

require 'cairo'
require 'rsvg'

function draw_svg_file(path,x,y,w,h)
-- draws on existing (most likely globally defined in conky_main) cairo xlib surface cr
   local rh = rsvg_create_handle_from_file(path)
   local rd = RsvgDimensionData:create()
   rsvg_handle_get_dimensions(rh, rd)
   iw, ih, em, ex = rd:get()
   if w and h then
      do_scale=1
   else
      do_scale=0
      w=iw
      h=ih
   end
   cairo_translate (cr, x, y)
   if do_scale == 1 then
      cairo_scale (cr, w/iw, h/ih)
   end
   rsvg_handle_render_cairo(rh, cr)
   rsvg_destroy_handle(rh)

   -- reset scaling
   if do_scale == 1 then
      cairo_scale (cr,iw/w,ih/h)
   end
   -- move back to origin
   cairo_translate (cr,-x,-y)
end

x and y define the starting position, w and h are the width and height of the image, extending to the right and down from x,y.
In other words, this function also scales the image.
If w,h are omitted, the image is displayed in its original size.


Give to COVAX! Here or here. (explanation)
My Repos: notabug | framagit

Offline

#3 2021-10-11 05:33:43

ohnonot
...again
Registered: 2015-09-29
Posts: 5,568

Re: Conky and Lua

Is it possible to change the way text and images are antialiased?
The manual for cairo-antialias-t suggests these options:

--CAIRO_ANTIALIAS_DEFAULT --- Use the default antialiasing for the subsystem and target device, since 1.0
CAIRO_ANTIALIAS_NONE --- Use a bilevel alpha mask, since 1.0
CAIRO_ANTIALIAS_GRAY --- Perform single-color antialiasing (using shades of gray for black text on a white background, for example), since 1.0
CAIRO_ANTIALIAS_SUBPIXEL --- Perform antialiasing by taking advantage of the order of subpixel elements on devices such as LCD panels, since 1.0
CAIRO_ANTIALIAS_FAST --- Hint that the backend should perform some antialiasing but prefer speed over quality, since 1.12
CAIRO_ANTIALIAS_GOOD --- The backend should balance quality against performance, since 1.12
CAIRO_ANTIALIAS_BEST --- Hint that the backend should render at the highest quality, sacrificing speed if necessary, since 1.12

They can be set with these two functions afaics:

cairo_set_antialias(cr, CAIRO_ANTIALIAS_....)
cairo_font_options_set_antialias(cr, CAIRO_ANTIALIAS_....)

I tried pretty much all combinations, but never saw any effect.
Does anybody have any experience with this?


Give to COVAX! Here or here. (explanation)
My Repos: notabug | framagit

Offline

#4 2021-10-11 13:20:49

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

Re: Conky and Lua

ohnonot wrote:

I tried pretty much all combinations, but never saw any effect.
Does anybody have any experience with this?

Which conky version?
Just a guess, maybe try with version 1.9   smile

Offline

#5 2021-10-11 15:09:40

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,817

Re: Conky and Lua

I felt the pain of mrPeachy's passing.  I am glad his legacy lives on.

I will over time post may of his scripts here.


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.
_______________________________
Debian 10 Buster = SharpBang ♯!

Offline

Board footer

Powered by FluxBB