You are not logged in.

#221 2022-05-30 21:55:27

jeffreyC
Member
Registered: 2019-09-07
Posts: 192

Re: The great yad hacking thread

Bearded_Blunder wrote:

As could quite a few here, I don't think Bunsen has the amount of free Dev time it'd take for the approach MX took though.. you start with one package, then another feels justified & pretty soon you're maintaining a huge repo & spending all your time tracking & updating packages the main Debian repos are behind with.

Sort of thing you'd only take on if you need some feature the Debian version lacks to make the distro work properly.

With MX it is most often in response to a user request on the forum or reddit.

But with yad the reason newer versions are not in the main MX repo is past 0.40.xx it is GTK3 instead of GTK2 and they had reports of problems with it.

Last edited by jeffreyC (2022-05-30 21:59:29)

Offline

#222 2022-05-31 11:24:14

rbh
Moderator
From: South of Lapplands inland
Registered: 2016-08-11
Posts: 1,921

Re: The great yad hacking thread

Bearded_Blunder wrote:

Well there is an open bug  Maybe it'll get addressed one day.

Hopefully sooner. I have mailed  Debian package responsible Gustavo, reminded him that source should bee fetched from GitHub and  mailed Victor; program author, begged hom to make a note on SF, that current source is on GitHub.


// Regards rbh

Please read before requesting help: "Guide to getting help", "Introduction to the Bunsenlabs Lithium Desktop" and other help topics under "Help & Resources" on the BunsenLabs menu

Offline

#223 2022-06-19 02:28:21

achim
Member
Registered: 2019-08-23
Posts: 40

Re: The great yad hacking thread

Sorry, I miss misko_2083 with his excellent posts. Why can't I find his postings anymore? Anyone know where he is?

Offline

#224 2025-07-24 07:37:02

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: The great yad hacking thread

Heavy necroposting here, but it seems a shame to let a monster thread like this die, and I have a question that didn't seem to justify its own thread:

The "--selectable-labels" option

It always comes up with all the text selected, which looks horrible.
Is there no other way to make it possible to copy text out of a yad window?
Or a way to make that above option not select all by default?


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#225 2025-07-25 00:10:19

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 830

Re: The great yad hacking thread

^ I'm not too familiar with YAD, but maybe this can help?
https://stackoverflow.com/questions/641 … n-function

I tested script (Answer 1) in the terminal, but I'm not sure if it's what you need.
Is it usable?

EDIT

Another idea

If you have xclip  installed, you can copy the output to the clipboard:

$ echo test | xclip -selection clipboard

Open text editor and paste.
Or use the keyboard shortcut Ctrl + Shift + V in the terminal (Right-click > Paste).

Inside the script you can use:

echo $something | xclip -selection clipboard

Last edited by marens (2025-07-25 02:12:20)


If people would know how little brain is ruling the world, they would die of fear.

Offline

#226 2025-07-25 02:58:45

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: The great yad hacking thread

^Thanks for replying here.
OK let me spell out in a bit more detail what I'm trying to do.

I've got a script which outputs some information as text, containing a few ID numbers which it would be useful for the user (me) to be able to copy - if they want to - and paste somewhere else, eg into a terminal.
I want to display the info, but make it possible to select and copy parts of it.

Of course, that's usually quite possible, whether in a text editor, terminal emulator or even a web browser.

I could just pop up a terminal to display the info, but thought a yad window was more elegant. The problem with yad, though is that the text displayed is not usually selectable. Yad has an option '--selectable-labels' which makes the text selectable, but it then comes up with all the text selected right away. User can use the mouse to select the bit they want, but the first appearance is quite ugly.

Here's what I get (I don't think those key ID numbers would be any use to a hacker, but deleted them anyway):
UIKFiLqm.png

After clicking in the window with the mouse, the text is unselected, which is what I want:
8mhwSpIm.png

It's a cosmetic issue really.

Maybe there's something that could be done in the script with xdotool to simulate a mouse click and unselect the text...

Last edited by johnraff (2025-07-25 04:17:56)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#227 2025-07-25 13:24:21

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 830

Re: The great yad hacking thread

^ Ok.
Now it's clearer to me what you want.

johnraff wrote:

Maybe there's something that could be done in the script with xdotool to simulate a mouse click and unselect the text...

I think it's possible.

1) First I ran yad --color  from the terminal
2) Then I used xwininfo  to get information about the window:

xwininfo: Window id: 0x3c00007 "YAD"

This is a test  script:

#!/bin/bash

## Current mouse position
prev_pos=$(xdotool getmouselocation | awk -F "[: ]" '{print $2 " " $4}')

## Go to the YAD window
xdotool mousemove $(xdotool getwindowgeometry $(xdotool search --name --onlyvisible YAD | tail -1) | awk -F "[, ]" 'NR==2{print $4 " " $5}')

## Click
xdotool click 1

## Go back to previous mouse position
xdotool mousemove $(echo $prev_pos)

When I run the script from the terminal, the YAD window becomes focused and the mouse returns to its previous position (terminal).

Add the code to the end of your script and test it.

Note *
If necessary, use the sleep  command at the beginning of the code (for delay) to make sure the YAD window is already on the desktop.

Last edited by marens (2025-07-25 15:18:40)


If people would know how little brain is ruling the world, they would die of fear.

Offline

#228 2025-07-26 08:10:15

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: The great yad hacking thread

^thanks, i'm playing with this now but it seems to be working OK.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#229 2025-07-27 00:04:20

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 830

Re: The great yad hacking thread

^ Yes.
I expected that it would be necessary to set the right timing.

In the test  script, of course, the left click ($ xdotool click 1)  was used.

Maybe someone needs other options within the topic:

  • Left click 1

  • Middle click 2

  • Right click 3

  • Scroll wheel up 4

  • Scroll wheel down 5

More details:
https://linuxhint.com/xdotool_stimulate … keystrokes


If people would know how little brain is ruling the world, they would die of fear.

Offline

#230 2025-07-27 05:04:47

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: The great yad hacking thread

Played with this some more today - one thing I changed was searching for the yad window by its pid instead of the name. It seemed a bit more precise:

yadwinid=$(xdotool search --pid "$yadpid"  --onlyvisible)

The yad pid was available from the calling script:

yad.... & yadpid=$!

But... then while I was using the window ID from that search, I discovered that just selecting the ID number from the terminal (to paste it into another command) was enough to clear the selection from the yad window! So just touching the primary selection does the job I wanted.

xsel -c

clears the primary selection, and cleans up yad. smile Just add a small sleep to make sure yad is open and here's the test code:

text='first line of text
another line of text 12345
third line....'

yad --selectable-labels --center --borders=20 --window-icon=distributor-logo-bunsenlabs '--title=Secret keys expiry check' --fixed --text="$text" --image=dialog-warning --width=300  --button=OK:0 &
# comment out this next line to see the preselected yad window
sleep 1; xsel -c

Oh yes, yad had to be forked off with a & in order for the xsel command to work. It's obvious when you think about it - otherwise xsel won't be run until after yad has closed. It's a small inconvenience, especially if you want to have more actions triggered by yad buttons, but in my case it's OK.

Thanks for your help @marens - I probably wouldn't have hit on that fix unless I'd been playing with the xdotool search...

Last edited by johnraff (2025-08-01 07:18:17)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#231 2025-07-28 01:04:20

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 830

Re: The great yad hacking thread

johnraff wrote:

...

Just add a small sleep to make sure yad is open and here's the test code:

...   '--title=Secret keys expiry check'   ...

...

Maybe I didn't understand, but this works in my test  script with  '--title=Secret keys expiry check' :

xdotool mousemove $(xdotool getwindowgeometry $(xdotool search --name --onlyvisible "Secret keys expiry check" | tail -1) | awk -F "[, ]" 'NR==2{print $4 " " $5}')

Also:

johnraff wrote:

Played with this some more today - one thing I changed was searching for the yad window by its pid instead of the name. It seemed a bit more precise:
...

Do you think the name of the YAD window "Secret keys expiry check"  is not precise enough?

Anyway, the cosmetic issue is solved.
The solution with YAD pid is very interesting, @johnraff.

And we learned something new.  smile


If people would know how little brain is ruling the world, they would die of fear.

Offline

#232 2025-07-28 01:32:18

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: The great yad hacking thread

marens wrote:
johnraff wrote:

...

Just add a small sleep to make sure yad is open and here's the test code:

...   '--title=Secret keys expiry check'   ...

...

Maybe I didn't understand, but this works in my test  script with  '--title=Secret keys expiry check' :

xdotool mousemove $(xdotool getwindowgeometry $(xdotool search --name --onlyvisible "Secret keys expiry check" | tail -1) | awk -F "[, ]" 'NR==2{print $4 " " $5}')

Maybe indeed you didn't get what I was saying, but ultimately I didn't need to use xdotool at all. Just clearing the primary selection with 'xsel -c' after launching yad was enough. As in that short test script I posted.

johnraff wrote:

Played with this some more today - one thing I changed was searching for the yad window by its pid instead of the name. It seemed a bit more precise:
...

Do you think the name of the YAD window "Secret keys expiry check"  is not precise enough?

Yes, in this particular case that title is probably unique enough. But sometimes the yad title will be a bit more generic, while the PID will always be unique.

And we learned something new.

Yes, thanks for your input!


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#233 2025-08-01 18:49:55

greenjeans
Member
Registered: 2025-01-18
Posts: 227
Website

Re: The great yad hacking thread

Well right now i'm flailing about with yad trying to make --css=[string] work, lol, but I do have a tip some might find useful if you don't already know about it. I didn't come up with it, and after an hour of searching for answers I found an obscure post from many years ago from a user that needed to do a similar thing and was able to apply it to my project.

I needed a yad dialog to instantly close after making a selection in a dialog (ScrotShot app) and was having a hella time trying to make it happen while still getting the output and continuing the script. Here's how it worked finally:

choice=$(yad --title="ScrotShot" --window-icon=camera --width=300 --height=150 --borders=10 \
    --form \
    --field="Desktop (entire):FBTN" "bash -c \"echo 1;kill \$YAD_PID\"" \
    --field="Desktop (5 sec delay):FBTN" "bash -c \"echo 2;kill \$YAD_PID\"" \
    --field="Select area with mouse:FBTN" "bash -c \"echo 3;kill \$YAD_PID\"" \
    --button="Cancel:1" \
    --buttons-layout=spread)

With a case/eval function that followed to exec the choices. This was the only way this worked right after a lot of experimenting.

Offline

#234 2025-08-09 02:00:40

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 830

Re: The great yad hacking thread

johnraff wrote:

Yes, in this particular case that title is probably unique enough. But sometimes the yad title will be a bit more generic, while the PID will always be unique.

Thanks for this.

I used your tips to improve my YAD script  (rt-yad2)  which displays album art  when Radiotray-NG is playing.
At one point, two YAD pids appear with the same window title.
I could have gotten the necessary PIDs differently, but this really helped:
https://forums.bunsenlabs.org/viewtopic … 54#p144954

Of course, the radiotray-ng  script runs in Conky.
That way I get the album-art.png  image and know when it was changed.


If people would know how little brain is ruling the world, they would die of fear.

Offline

Board footer

Powered by FluxBB