is there a way to focus an image displayed by conky so it appears on top of all other windows? [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.
Post Reply
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

is there a way to focus an image displayed by conky so it appears on top of all other windows? [SOLVED]

Post by Logansfury »

Hello,

The title says it all.
Last edited by Logansfury on Tue Jan 30, 2024 8:44 am, edited 1 time in total.
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Koentje »

Yes there is! ;)

Needs to be dock
own_window_type = 'dock',

and

needs above
own_window_hints = 'skip_taskbar,skip_pager,undecorated,above',

And now your conky windows sticks out on top of all..
Schermafdruk van 2024-01-30 03-27-53.jpg
Schermafdruk van 2024-01-30 03-27-53.jpg (8.43 KiB) Viewed 685 times


And you can still click on things below 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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

Koentje wrote: Mon Jan 29, 2024 10:27 pm Yes there is! ;)

Needs to be dock
own_window_type = 'dock',

and

needs above
own_window_hints = 'skip_taskbar,skip_pager,undecorated,above',

And now your conky windows sticks out on top of all..
Schermafdruk van 2024-01-30 03-27-53.jpg

And you can still click on thing below it!
Far out! do I put that code into the conkyrc or the pic.lua?
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

found the own_window = desktop and changed that to dock and added the second line underneath but when I closed and relaunched the picture it wasnt top focus it was buried behind a webbrowser window
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Koentje »

Paste your current conky script.. there must be something wrong, because that calendar i screenshotted, was above all my open windows!
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

Koentje wrote: Mon Jan 29, 2024 10:42 pm Paste your current conky script..
Here ya go!

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 = dock,
    own_window_hints = 'skip_taskbar,skip_pager,undecorated,above',
    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
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

AHA!!

Its this isnt it?

own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',

deleting that line now, stand by...
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

Logansfury wrote: Mon Jan 29, 2024 10:46 pm AHA!!

Its this isnt it?

own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',

deleting that line now, stand by...
WOOOHOO that did it!

my image is now top focus :D

Thank you so much!
Last edited by Logansfury on Mon Jan 29, 2024 11:23 pm, edited 1 time in total.
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Koentje »

Another satisfied customer! (well.. i got only one customer :mrgreen: )
Last edited by Koentje on Mon Jan 29, 2024 10:58 pm, edited 1 time in total.
Image
User avatar
zcot
Level 9
Level 9
Posts: 2838
Joined: Wed Oct 19, 2016 6:08 pm

Re: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by zcot »

Logansfury wrote: Mon Jan 29, 2024 10:46 pm own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',
It says the thing..

You're gonna want this stuff, obviously you haven't seen it. :D

and right on the same wiki page, you need those:
https://github.com/brndnmtthws/conky/wi ... s#settings
https://github.com/brndnmtthws/conky/wi ... #variables

you do man conky > conky-manual and you have it as a text file into the current directory, open right up with text editor, also searchable easily, open that and ctrl+f and type own_window.
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

zcot wrote: Mon Jan 29, 2024 10:58 pm You're gonna want this stuff, obviously you haven't seen it. :D
Guilty as charged. I haven't cracked open any manuals yet, I figured it would be over my head.
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

I got my routine to kill the image after I take the garbage out.

5 mins after the biohazzard pic and the mp3 announcing garbage time launch, a second .sh script launches:

clickbox.sh

Code: Select all

#!/bin/bash

# Define the coordinates of the clickable box
box_x=780
box_y=385
box_width=300
box_height=260

# Function to check if the mouse is inside the box
mouse_inside_box() {
    mouse_x=$(xdotool getmouselocation --shell | grep 'X' | awk -F'=' '{print $2}')
    mouse_y=$(xdotool getmouselocation --shell | grep 'Y' | awk -F'=' '{print $2}')

    if [ "$mouse_x" -ge "$box_x" ] && [ "$mouse_x" -le "$((box_x + box_width))" ] && \
       [ "$mouse_y" -ge "$box_y" ] && [ "$mouse_y" -le "$((box_y + box_height))" ]; then
        return 0  # Mouse is inside the box
    else
        return 1  # Mouse is outside the box
    fi
}

# Wait for a mouse click event within the specified box
while true; do
    if mouse_inside_box && xdotool click 1; then
        # Run your script after a mouse click
    /home/logansfury/xdotool/stop_bio.sh
        break  # Exit the loop after the script is executed
    fi
    sleep 0.1  # Adjust the sleep duration as needed
done
this creates a box around the biohazzard image, and waits for the mouse to enter the box. Once mouse enters the box another script is activated:

close_bio.sh

Code: Select all

pkill -f "conky -c /home/logansfury/.conky/Biohazzard/conkyrc"
I have tried to get a script out of chatgpt3.5 that waits for a mouse click instead of a mouse-over but it's not capable of scripting it.
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Koentje »

Why the second script?? That one line could also be done in the first script..
I see in your first script stop_bio.sh and your second scriptname is close_bio.sh... is that a typo or are those 2 different scripts?
If it's a typo and they are the same, then replace that line with the line of your second 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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 12:15 am Why the second script?? That one line could also be done in the first script..
I see in your first script stop_bio.sh and your second scriptname is close_bio.sh... is that a typo or are those 2 different scripts?
If it's a typo and they are the same, then replace that line with the line of your second script!
Good catch, yes I did make a typo and the script is actually named stop_bio.sh

I had an existing .sh named beep.sh that does what you would expect. I started on chatgpt with the clickbox activating the beep.sh for quick confirmation that mouseovers were being registered. I then edited the script called by the mouseover from beep.sh to stop_bio.sh.

I just left it in the state of one script calling another when I was done with beep.sh
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Koentje »

And what if you move the conky window? Then your box doesn't fit the conky window anymore...
Why not use the conky gap_x, gap_y, minimum_width, minimum_height of your conky config?

So instead of

Code: Select all

box_x=780
box_y=385
box_width=300
box_height=260
Use this

Code: Select all

conkyconf="/home/logansfury/.conky/Biohazzard/conkyrc"
 box_x=$(cat "$conkyconf" | grep gap_x | awk -F'=' '{print $2}'); box_x=${box_x:1:-1}
 box_y=$(cat "$conkyconf" | grep gap_y | awk -F'=' '{print $2}'); box_y=${box_y:1:-1}
 box_width=$(cat "$conkyconf" | grep minimum_width | awk -F'=' '{print $2}'); box_width=${box_width:1:-1}
 box_height=$(cat "$conkyconf" | grep minimum_height | awk -F'=' '{print $2}'); box_height=${box_height:1:-1}
Image
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Koentje »

Logansfury wrote: Tue Jan 30, 2024 12:23 am I just left it in the state of one script calling another when I was done with beep.sh
If it is just one line, then it's better to put it in the first script, or else you loose track of scripts!
When the second script is a whole other story, then maybe keep it seperate. But i kind of keep the same topic in one script, unless it can't be this way. Like the server script in my inxi-report. It has a loop after starting the server that i can't build in the inxi-report script, that's why it is seperated...
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 12:30 am
Logansfury wrote: Tue Jan 30, 2024 12:23 am I just left it in the state of one script calling another when I was done with beep.sh
If it is just one line, then it's better to put it in the first script, or else you loose track of scripts!
When the second script is a whole other story, then maybe keep it seperate. But i kind of keep the same topic in one script, unless it can't be this way. Like the server script in my inxi-report. It has a loop after starting the server that i can't build in the inxi-report script, that's why it is seperated...
I see your logic. I can most likely do a combining of the scipts, I just have to edit part of my crontab if I do to keep things operating.
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 12:26 am And what if you move the conky window? Then your box doesn't fit the conky window anymore...
Why not use the conky gap_x, gap_y, minimum_width, minimum_height of your conky config?

So instead of

Code: Select all

box_x=780
box_y=385
box_width=300
box_height=260
Use this

Code: Select all

conkyconf="/home/logansfury/.conky/Biohazzard/conkyrc"
 box_x=$(cat "$conkyconf" | grep gap_x | awk -F'=' '{print $2}'); box_x=${box_x:1:-1}
 box_y=$(cat "$conkyconf" | grep gap_y | awk -F'=' '{print $2}'); box_y=${box_y:1:-1}
 box_width=$(cat "$conkyconf" | grep minimum_width | awk -F'=' '{print $2}'); box_width=${box_width:1:-1}
 box_height=$(cat "$conkyconf" | grep minimum_height | awk -F'=' '{print $2}'); box_height=${box_height:1:-1}
This looks very cool! The bot spat out the existing code for I dont know what reason but the box it defines surrounds the bio image on screen perfectly and there is nothing that should make the image change position. The script isn't dependent on the conky manager 2 gui window being open.
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: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Koentje »

Why? Just copy the line from stop_bio.sh and place it in the first script where you call stop_bio.sh
This looks very cool! The bot spat out the existing code for I dont know what reason but the box it defines surrounds the bio image on screen perfectly and there is nothing that should make the image change position. The script isn't dependent on the conky manager 2 gui window being open.
Keep conky manager 2 and conky windows/scripts/configs seperate! The manager only starts and stops scripts, nothing more. For that matter, you don't even need conky manager to start a conky script, it is just very handy!
What i'm trying to say is when you've long forgotten the scripts and after a year or so you move your bio hazzard window to the other screen or make it smaller or you move it around (as i have done multipledozents of times over the years) you begin to wonder why all of a sudden your perfectly working setup doesn't work anymore... and totally forgotten how, what and where you did who! ;)
You have only a few configs running, so maybe you can remember it all.. i have 57 conky's running and another 50 bash scripts, and 12 lua scripts! Every time i move my scripts around to fit new ones i have to do some serious changes in the scripts to keep it running as is.. and everytime i upgrade them so i have to do less each time i want to move them!
Just my 2 cents... ;)
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: is there a way to focus an image displayed by conky so it appears on top of all other windows?

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 12:51 am Why? Just copy the line from stop_bio.sh and place it in the first script where you call stop_bio.sh
This looks very cool! The bot spat out the existing code for I dont know what reason but the box it defines surrounds the bio image on screen perfectly and there is nothing that should make the image change position. The script isn't dependent on the conky manager 2 gui window being open.
Keep conky manager 2 and conky windows/scripts/configs seperate! The manager only starts and stops scripts, nothing more. For that matter, you don't even need conky manager to start a conky script, it is just very handy!
What i'm trying to say is when you've long forgotten the scripts and after a year or so you move your bio hazzard window to the other screen or make it smaller or you move it around (as i have done multipledozents of times over the years) you begin to wonder why all of a sudden your perfectly working setup doesn't work anymore... and totally forgotten how, what and where you did who! ;)
You have only a few configs running, so maybe you can remember it all.. i have 57 conky's running and another 50 bash scripts, and 12 lua scripts! Every time i move my scripts around to fit new ones i have to do some serious changes in the scripts to keep it running as is.. and everytime i upgrade them so i have to do less each time i want to move them!
Just my 2 cents... ;)
Sounds like an easy edit.

This seems very sound advice, thank you!
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
Post Reply

Return to “Compiz, Conky, Docks & Widgets”