brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.27k stars 620 forks source link

Lua obscures conf images #1167

Closed quiltedstars closed 1 year ago

quiltedstars commented 2 years ago

Issue

Scripting lua with rounded corners requires adding a background colour for it to appear in Conky (and therefore requires the background in conkyrc to be transparent). However, when I add images into the conkyrc file, Lua draws the background overtop of the images, even though text and bars appear correctly. Changing the alpha in lua to 0 shows that the images are rendered in conkyrc, and removing the background colour in lua and adding it in conky eliminates the rounded corners.

Information

I believe this issue should be OS/version agnostic.

To replicate, append these to their respective spots:

background.lua

require 'cairo'

corner_r=45

bg_colour=0x121212
bg_alpha=1 (change to 0 to see that the image does in fact render)

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

own_window_transparent = true [but it also worked with false],
own_window_argb_value = [any],
lua_load = '~/background.lua'
lua_draw_hook_pre = '(whatever is the main function)'
};

conky.text = [[
${color7}${font :size=14:bold}${alignr}SYSTEM${image ~/void.png -p 150,0 -s 25x25}${font}
...
]]

Is there a way to change this, either within lua or within the conf file? I can only barely make my way around lua, so I don't know how to add an image into lua, and I've tried to search, but haven't found anything. I apologize if it's obvious to most!

rdschmidt commented 2 years ago
require "imlib2"
function image (im)
    local x = (im.x or 0)
    local y = (im.y or 0)
    local w = (im.w or 0)
    local h = (im.h or 0)
    local file = tostring (im.file)
    if file == nil then print ("set image file") end
    local show = imlib_load_image (file)
    if show == nil then return end
    imlib_context_set_image (show)
    if tonumber (w) == 0 then
        width = imlib_image_get_width ()
    else
        width = tonumber (w)
    end

    if tonumber (h) == 0 then
        height = imlib_image_get_height ()
    else
        height = tonumber (h)
    end

    imlib_context_set_image (show) 
    local scaled = imlib_create_cropped_scaled_image (0, 0,
            imlib_image_get_width (), imlib_image_get_height (), width, height) 
    imlib_free_image ()
    imlib_context_set_image (scaled)
    imlib_render_image_on_drawable (x, y)
    imlib_free_image ()
    show = nil
end

--Call: image ({x = 100, y = 100, h = 50, w = 50, file = "/path/to/image"})

source: brndnmtthws WIKI

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment, or this issue will be closed in 30 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 30 days with no activity.