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
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:54 pm How would I edit to get complete display? Is working with a smaller picture necessary?
You can make the Conky area as large as you like. But keep in mind that you have no access to any icons and folders underneath in the entire Conky area.

necessary changes:
conkyrc Line 24:
minimum_width = 500, minimum_height = 500, --Theoretically, this can be the entire screen

pic.lua Line 36:
fDrawImage(cr,'/path/to/picture.png',0,0,500,500) --the same values as in the conkyrc
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
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 »

Bleys wrote: Fri Jan 26, 2024 8:14 pm ...But keep in mind that you have no access to any icons and folders underneath in the entire Conky area.
Even when in the conky script own_window_type is set to dock or desktop?

(if i'm correct, desktop is the lowest layer)
Image
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 »

Koentje wrote: Fri Jan 26, 2024 8:29 pm
Even when in the conky script own_window_type is set to dock or desktop?
(if i'm correct, desktop is the lowest layer)
no matter wart type...

And a correction. The values for the image in pic.lua must be double the values in the conkyrc!

pic.lua Line 36:
fDrawImage(cr,'/path/to/picture.png',0,0,1000,1000) -double values as in the 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 »

Bleys wrote: Fri Jan 26, 2024 8:55 pm
Koentje wrote: Fri Jan 26, 2024 8:29 pm
Even when in the conky script own_window_type is set to dock or desktop?
(if i'm correct, desktop is the lowest layer)
no matter wart type...

And a correction. The values for the image in pic.lua must be double the values in the conkyrc!

pic.lua Line 36:
fDrawImage(cr,'/path/to/picture.png',0,0,1000,1000) -double values as in the conkyrc
I just made the edits. In conkyrc I have set the values to match the image size, 600,525. In the pic.lua I have edited line 36 to 1200,1050

I got a larger display of the bottom right 1/4 of my image.
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 »

Yep... I shouldn't be coding this late...

I place in the center of the picture area. The values for x,y must therefore be the center of the image. For 500x500, this means 250,250. And the size as written first: the same values as in the conkyrc
Ok, now the correct values for a 500x500 PNG:

pic.lua Line 36:
fDrawImage(cr,'/path/to/picture.png',250,250,500,500) --same values as in the 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 »

Bleys wrote: Fri Jan 26, 2024 9:06 pm Yep... I shouldn't be coding this late...

I place in the center of the picture area. The values for x,y must therefore be the center of the image. For 500x500, this means 250,250. And the size as written first: the same values as in the conkyrc
Ok, now the correct values for a 500x500 PNG:

pic.lua Line 36:
fDrawImage(cr,'/path/to/picture.png',250,250,500,500) --same values as in the conkyrc
YES!!! COMPLETE SUCCESS!!! PERFECT DISPLAY, FULL COLOR, FULL TRANSPARENCY!!

My deepest gratitude, you are brilliant Bleys :D
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 [SOLVED]

Post by Logansfury »

Here are the working scripts:

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 = 600, minimum_height = 525,
	alignment = 'middle_middle',
	
	gap_x = 20,
	gap_y = 20,


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

]];
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',300,263,600,525)
	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
Last edited by Logansfury on Sat Jan 27, 2024 2:41 pm, edited 1 time in total.
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 [SOLVED]

Post by AndyMH »

Bookmarked for future reference. I gave up on my weather conky:
  • dependent on python2 (using a package metoffer to download and parse the data), was able to install in LM20, gave up in LM21
  • the UK met office have changed their API so even if I got python2 installed it would need a rewrite
in addition to the washed out images, which this thread might fix.

I may try again another day.
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 [SOLVED]

Post by Logansfury »

Hello all,

I have a quick question regarding using conky for image display and didn't want to start a whole new thread:

In cases of dual or triple monitor setup (I have one of each for my 2 Linux Boxes) is there a way in the conky.conf used here to specify specific monitor to display the image upon?

Thanks for reading!

Logan
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 [SOLVED]

Post by Koentje »

No, but you can use negative numbers... if the second monitor is above your primary, then the gap_y value (vertical) should be negative.
The same with horizontal movement. If the second monitor is on the right, you need a gap_x that exceeds the horizontal resolution of your primary. If the monitor is on the left you need a negative number.
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 [SOLVED]

Post by Logansfury »

Koentje wrote: Sun Jan 28, 2024 8:41 pm No, but you can use negative numbers... if the second monitor is above your primary, then the gap_y value (vertical) should be negative.
The same with horizontal movement. If the second monitor is on the right, you need a gap_x that exceeds the horizontal resolution of your primary. If the monitor is on the left you need a negative number.
Thank you, I'll start experimenting with these values!
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 [SOLVED]

Post by Logansfury »

Logansfury wrote: Sun Jan 28, 2024 9:03 pm
Koentje wrote: Sun Jan 28, 2024 8:41 pm No, but you can use negative numbers... if the second monitor is above your primary, then the gap_y value (vertical) should be negative.
The same with horizontal movement. If the second monitor is on the right, you need a gap_x that exceeds the horizontal resolution of your primary. If the monitor is on the left you need a negative number.
Thank you, I'll start experimenting with these values!
Success. I edited the gap_x from 20 to 2020 and the image shuffled to the left. I then edited 2020 to -2020 and the image appeared on my right 2nd monitor!

I will know later tonight if my routine with the conky displayed biohazzard image appears to alert me of trash night. I have my crontab firing off an xdotool .sh file at 6:30pm that turns the conky display on. Fingers crossed.
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 [SOLVED]

Post by Koentje »

Why xdotool?? You can start a conky window on the terminal with conky -c </path/to/conkyscript>.

And if you add parameter -i <nr> then it shows only <nr> of update times. So if you have the conky set to an update interval of 10 seconds and -i 2 then it shows 2x 10 seconds and then terminates.

What is in your xdotool script?
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 [SOLVED]

Post by Logansfury »

Koentje wrote: Mon Jan 29, 2024 5:33 pm Why xdotool?? You can start a conky window on the terminal with conky -c </path/to/conkyscript>.

And if you add parameter -i <nr> then it shows only <nr> of update times. So if you have the conky set to an update interval of 10 seconds and -i 2 then it shows 2x 10 seconds and then terminates.

What is in your xdotool script?
I use xdotool for several applications of running graphic and sound scripts either daily or on a specific day/time of the week. Here is my garbage night reminder routine:

crontab:

Code: Select all

00 18 * * 1 /home/logansfury/xdotool/activate.sh
activate.sh:

Code: Select all

#!/bin/bash

export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
export XDG_CURRENT_DESKTOP=Cinnamon
export XDG_RUNTIME_DIR=/run/user/$(id -u)

# Launch Conky in the background
 conky -c /home/logansfury/.conky/Biohazzard_sm/conkyrc &

# Play the audio file
mpg123 /home/logansfury/Documents/garbage_night.mp3
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 = 300, minimum_height = 263,
	alignment = 'middle_middle',
	
	gap_x = 20,
	gap_y = 20,


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

]];
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/bio_sm.png',150,132,300,263)
	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
it's still primed to fire tonight for the first time, but it has worked perfectly in testing by setting a crontab event for 1 minute into the future.
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 [SOLVED]

Post by Koentje »

...will know later tonight if my routine with the conky displayed biohazzard image appears to alert me of trash night. I have my crontab firing off an xdotool.sh....
Why did you call this script xdotool ?? There is nothing of xdotool in it...
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 [SOLVED]

Post by Logansfury »

Koentje wrote: Mon Jan 29, 2024 6:06 pm
...will know later tonight if my routine with the conky displayed biohazzard image appears to alert me of trash night. I have my crontab firing off an xdotool.sh....
Why did you call this script xdotool ?? There is nothing of xdotool in it...
It was built by chatgpt3.5. I requested an "xdotool bash .sh script for linux mint to launch a conky display and play an mp3 with mpg123"

This is what it output for me. I assumed the bot had honored the details of my request. As this is a script launched via automation and I come from windows as an EventGhost automation user, I had queried the net on the linux version of EventGhost and it led me to xdotool and Repeat.
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 [SOLVED]

Post by Logansfury »

Isn't it the installation of the xdotool on my Linux box that allows this .sh script to run at all?

My inexperience has entered the room >.<
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 [SOLVED]

Post by Koentje »

Nope.. that's the task of BASH!
xdotool emulates a key press and such..
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 [SOLVED]

Post by Logansfury »

Koentje wrote: Mon Jan 29, 2024 7:53 pm Nope.. that's the task of BASH!
xdotool emulates a key press and such..
Holy crap. Well I do have some xdotool routines that I know are calling upon xdotool as it's in the script text. Mostly automatons on reboot to auto-mount my windows shared drives and the Public directories on my two linux boxes:

network.sh:

Code: Select all

#!/bin/bash

# Wait for a moment to ensure the script works reliably
sleep 1

# Use xdg-open to open the "network:///" location
xdg-open "network:///"

# Wait for the network window to open (you can adjust the sleep time as needed)
sleep 1

# Use wmctrl to move the window to a specific location (e.g., 100,100)
wmctrl -r "Network" -e 0,150,100,-1,-1

# Wait
sleep 1

# Move the mouse to coordinates (290, 245) and pause for half a second
xdotool mousemove 395 255
sleep 0.5

# Perform a double-click (two left-click events in rapid succession)
xdotool click --repeat 2 --delay 100 1


# Wait for a moment after the last double-click
sleep 1

# Move the mouse to coordinates (290, 245) and pause for half a second
xdotool mousemove 545 255
sleep 0.5

# Perform a double-click (two left-click events in rapid succession)
xdotool click --repeat 2 --delay 100 1


# Wait for a moment after the last double-click
sleep 1

# Close the folder named "public on optiplex-5040"
xdotool key Alt+F4
network2.sh:

Code: Select all

#!/bin/bash

# Wait for a moment to ensure the script works reliably
sleep 1

# Use xdg-open to open the "network:///" location
xdg-open "network:///"

# Wait for the network window to open (you can adjust the sleep time as needed)
sleep 1

# Use wmctrl to move the window to a specific location (e.g., 100,100)
wmctrl -r "Network" -e 0,150,100,-1,-1

# Wait
sleep 1

# Move the mouse to coordinates (290, 245) and pause for half a second
xdotool mousemove 540 255
sleep 0.5

# Perform a double-click (two left-click events in rapid succession)
xdotool click --repeat 2 --delay 100 1


# Wait for a moment after the last double-click
sleep 2


# Perform a double-click (two left-click events in rapid succession)
xdotool click --repeat 2 --delay 100 1

# Wait for a moment after the last double-click
sleep 1

# Close the folder named "public on hp-z220-sff-workstation"
xdotool key Alt+F4
it's fun on reboot to watch xdotool go to work for me :)
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 [SOLVED]

Post by Koentje »

I have a rooted samsung S5 that i use as IP camera and to control the thing i login with adb and use similar commands to swipe, move finger around, tap, double tap, etc.. i have all sorts of scripts to focus camera, enable/disable flashlight, brightness control, network control, reboot/shutdown, etc. Without ever touching the screen i control all camera aspects and more.

Love it! :mrgreen:
Image
Post Reply

Return to “Compiz, Conky, Docks & Widgets”