using Conky to display an image without a window [SOLVED]

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

using Conky to display an image without a window [SOLVED]

Post by Logansfury »

Hello everyone,

I would like to run a script to have conky display a .png on the center of my monitor. The .png is a triangular graphic against a transparent background square. I would like conky to display it with no windows visible as if it were opened by an image app.

How would I go about this please?

Thanks for reading,

Logan
Last edited by Logansfury on Fri Jan 26, 2024 9:22 pm, edited 1 time in total.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

I tried to get chatgpt3.5 to assist and it gave the following code:

Code: Select all

conky.config = {
    -- Other conky configurations go here
    
    own_window = true,
    own_window_type = 'override',
    own_window_transparent = true,
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
    double_buffer = true,
}


conky.text = [[
${image /home/logansfury/Pictures/biohazzard.png -p 256,256 -s 500x500}
]]
This was recognized by conky manager 2 as a valid script, and displays the .conf in the widgets selection window, but running it does not display the image on either monitor. I have minimized everything to be sure the image wasnt hiding under a window, it's definitely not being displayed.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: using Conky to display an image without a window

Post by Bleys »

Logansfury wrote: Fri Jan 26, 2024 5:20 am

Code: Select all

conky.config = {
    -- Other conky configurations go here
    
	own_window = true,
	own_window_type = desktop,
    	own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',
	own_window_argb_visual = true,
	own_window_argb_value = 0,
	own_window_colour = '000000', 
    double_buffer = true,
    minimum_width = 500, minimum_height = 500,
    alignment = 'middle_middle',
}


conky.text = [[
${image /home/logansfury/Pictures/biohazzard.png -p 256,256 -s 500x500}
]]
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

Hello Bleys,

Thank you for the reply!

I edited the code slightly to conform to the picture dimensions but got a bad display:

https://imgur.com/a/w20xPw3

Here is the code:

Code: Select all

conky.config = {

    -- Other conky configurations go here
    
	own_window = true,
	own_window_type = desktop,
    	own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',
	own_window_argb_visual = true,
	own_window_argb_value = 0,
	own_window_colour = '000000', 
    double_buffer = true,
    minimum_width = 600, minimum_height = 525,
    alignment = 'middle_middle',
}


conky.text = [[
${image /home/logansfury/Pictures/biohazzard.png -p 256,256 -s 600x525}
]]
any ideas why I have only a partial display and my blacks are transparent?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: using Conky to display an image without a window

Post by AndyMH »

Logansfury wrote: Fri Jan 26, 2024 5:04 am I would like conky to display it with no windows visible as if it were opened by an image app.
You will be stuck with a border around the image or a washed out image, good luck!
viewtopic.php?p=2216420&hilit=conky#p2216420
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

AndyMH wrote: Fri Jan 26, 2024 10:30 am You will be stuck with a border around the image or a washed out image, good luck!
viewtopic.php?p=2216420&hilit=conky#p2216420
Well that's a bummer. I am having issues with a calendar that uses an .lua that is causing a background I dont want. I see your conky is using a beautiful calendar with no boarders or background. May I have the code please?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

AndyMH wrote: Fri Jan 26, 2024 10:30 am You will be stuck with a border around the image or a washed out image, good luck!
viewtopic.php?p=2216420&hilit=conky#p2216420
My result was a partial display of the image, completely washed out.

Would you know how to edit the code I have to display the image properly with a boarder?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: using Conky to display an image without a window

Post by Koentje »

Logansfury wrote: Fri Jan 26, 2024 10:57 am Well that's a bummer. I am having issues with a calendar that uses an .lua that is causing a background I dont want. I see your conky is using a beautiful calendar with no boarders or background. May I have the code please?
The problem seems that the same calendar that looks great without border on Mint 20 produces a border on Mint 21. Since your on 21.3 that border is there...
Image
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: using Conky to display an image without a window

Post by Koentje »

Logansfury wrote: Fri Jan 26, 2024 11:00 am My result was a partial display of the image, completely washed out.
Would you know how to edit the code I have to display the image properly with a boarder?
What i do when i'm working with transparent windows, set the own_window_colour = '000000', temporary to 200000. This way you get a redish window and now you see the borders of the window you are working with.

I see you set your window dimension minimum_width = 600, minimum_height = 525, but you place you picture halve way the window ${image /home/logansfury/Pictures/biohazzard.png -p 256,256 -s 600x525} with 256,256. No wonder you get half the picture! Change these values to 1,1. If it still does not fit, increase the window dimension, or decrease the picture size.

Problem with black is that it is transparent if arg value is 0. Why do you think your window is transparent on 000000 but completely white on FFFFFF. Conky and transparency is a b.i.t.c.h.! ;)
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

Hey hey!

That got me somewhere!

The whole image is now displayed but the yellow is washed out and the black areas are showing transparent
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

Has anyone got time to provide an example of code to display this image in a window? I would like to see what that looks like and if it does prevent the washout and black color-transparency issue.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: using Conky to display an image without a window

Post by Bleys »

Logansfury wrote: Fri Jan 26, 2024 2:05 pm The whole image is now displayed but the yellow is washed out and the black areas are showing transparent
If the image is to be displayed without transparency, LUA must be used:
save as pic.lua

Code: Select all

--[[
2024 Bleys


]]

require 'cairo'
require "imlib2"
home_path = os.getenv ('HOME')


function fDrawImage(cr,path,xx,yy,ww,hh,arc)
    cairo_save (cr)
    local img =  cairo_image_surface_create_from_png(path)
    local w_img, h_img = cairo_image_surface_get_width(img), cairo_image_surface_get_height(img)
    cairo_translate (cr, xx, yy)
    if arc then
        cairo_rotate (cr, arc)
    end
    cairo_scale (cr, ww/w_img, hh/h_img)
    cairo_set_source_surface (cr, img, -w_img/2, -h_img/2)
    cairo_paint (cr)
    cairo_surface_destroy (img)
    collectgarbage ()
    cairo_restore (cr)
end

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 cr=cairo_create(cs)		
	local updates=conky_parse('${updates}')
	update_num=tonumber(updates)
  
	if update_num>4 then
        fDrawImage(cr,'/home/logansfury/Pictures/biohazzard.png',0,0,500,500)
	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
conkyrc

Code: Select all

--[[
Bleys 2024 

]]
conky.config = {
-- — Conky settings

	background = false,
	update_interval = 1,
	total_run_times = 0,
	no_buffers = true,	

-- — Window specifications with Background

	own_window = true,
	own_window_type = desktop,
    own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',
	own_window_argb_visual = true,
	own_window_argb_value = 0,
	own_window_colour = '000000', 
	
	double_buffer = true,
	minimum_width = 500, minimum_height = 500,
	alignment = 'middle_middle',
	
	gap_x = 20,
	gap_y = 20,


-- Lua Load
	lua_load = './pic.lua',
	lua_draw_hook_post = 'main',		
};
conky.text = [[

]];
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

Bleys wrote: Fri Jan 26, 2024 6:07 pm
Logansfury wrote: Fri Jan 26, 2024 2:05 pm The whole image is now displayed but the yellow is washed out and the black areas are showing transparent
If the image is to be displayed without transparency, LUA must be used:
save as pic.lua

Code: Select all

--[[
2024 Bleys


]]

require 'cairo'
require "imlib2"
home_path = os.getenv ('HOME')


function fDrawImage(cr,path,xx,yy,ww,hh,arc)
    cairo_save (cr)
    local img =  cairo_image_surface_create_from_png(path)
    local w_img, h_img = cairo_image_surface_get_width(img), cairo_image_surface_get_height(img)
    cairo_translate (cr, xx, yy)
    if arc then
        cairo_rotate (cr, arc)
    end
    cairo_scale (cr, ww/w_img, hh/h_img)
    cairo_set_source_surface (cr, img, -w_img/2, -h_img/2)
    cairo_paint (cr)
    cairo_surface_destroy (img)
    collectgarbage ()
    cairo_restore (cr)
end

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 cr=cairo_create(cs)		
	local updates=conky_parse('${updates}')
	update_num=tonumber(updates)
  
	if update_num>4 then
        fDrawImage(cr,'/home/logansfury/Pictures/biohazzard.png',0,0,500,500)
	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
conkyrc

Code: Select all

--[[
Bleys 2024 

]]
conky.config = {
-- — Conky settings

	background = false,
	update_interval = 1,
	total_run_times = 0,
	no_buffers = true,	

-- — Window specifications with Background

	own_window = true,
	own_window_type = desktop,
    own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',
	own_window_argb_visual = true,
	own_window_argb_value = 0,
	own_window_colour = '000000', 
	
	double_buffer = true,
	minimum_width = 500, minimum_height = 500,
	alignment = 'middle_middle',
	
	gap_x = 20,
	gap_y = 20,


-- Lua Load
	lua_load = './pic.lua',
	lua_draw_hook_post = 'main',		
};
conky.text = [[

]];
I have copied these scripts into the proper files, only editing the 500x500 dimensions to the 600x525 that is the actual image size. I am getting no display when running the conkyrc from CM2 window :(
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: using Conky to display an image without a window

Post by Bleys »

Logansfury wrote: Fri Jan 26, 2024 6:20 pm
I have copied these scripts into the proper files, only editing the 500x500 dimensions to the 600x525 that is the actual image size. I am getting no display when running the conkyrc from CM2 window :(
If you do not start conky in the directory that contains the conkyrc and pic.lua you have to enter the complete path to pic.lua in the conkyrc line 32
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

I edited the lua file path and tried launching, but got no display. I then used Start in Terminal and got this output:

Code: Select all

conky: desktop window (600010) is subwindow of root window (6cb)
conky: window type - normal
conky: drawing to created window (0x6a00002)
conky: drawing to double buffer
conky: llua_load: /home/logansfury/.conky/Biohazzard/pic.lua:34: attempt to index a nil value (global 'conky')
conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: using Conky to display an image without a window

Post by Bleys »

pic.lua Line 34 is empty. Post your pic.lua
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

current pic.lua

Code: Select all

--[[
Bleys 2024 

]]
conky.config = {
-- — Conky settings

	background = false,
	update_interval = 1,
	total_run_times = 0,
	no_buffers = true,	

-- — Window specifications with Background

	own_window = true,
	own_window_type = desktop,
    own_window_transparent = false,
	own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',
	own_window_argb_visual = true,
	own_window_argb_value = 0,
	own_window_colour = '000000', 
	
	double_buffer = true,
	minimum_width = 600, minimum_height = 525,
	alignment = 'middle_middle',
	
	gap_x = 20,
	gap_y = 20,


-- Lua Load
	lua_load = './pic.lua',
	lua_draw_hook_post = 'main',		
};
conky.text = [[

]];
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: using Conky to display an image without a window

Post by Bleys »

Logansfury wrote: Fri Jan 26, 2024 7:35 pm current pic.lua
o_O
This is conkyrc....
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

holy crap.

OK I obviously had some mispastes. Lemme go back and correct that >.<
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: using Conky to display an image without a window

Post by Logansfury »

OOOOOOOOOO!!!

Were on our way! I just got brilliant full color, transparent background display of a portion of the .png!!!

Please see here: https://imgur.com/a/CcuNSzW

How would I edit to get complete display? Is working with a smaller picture necessary?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
Post Reply

Return to “Compiz, Conky, Docks & Widgets”