Yad -- Update textinfo from file stdin-input

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
arivas_2005
Posts: 37
Joined: Mon Oct 05, 2020 3:48 am

Yad -- Update textinfo from file stdin-input

Post by arivas_2005 »

Greetings

will it be possible to update the text-info with yad?
sample

Code: Select all

yad --geometry=20x40+500+400 --fontname="Arial Bold 15" --wrap --justify="center" --margins=1 --tail --editable --fore=green --back=yellow --listen --auto-close --auto-kill --monitor --text-info </tmp/tempo.txt &
##  based on-->: https://www.mankier.com/1/yad#Options-Text_info_options

for i in {1..5};do
		echo $i >/tmp/tempo.txt
		sleep 3
done

in this script the text-info is not updated.
will it be possible to make it update?

too, (geometry options not works!)
thanks for your support

arivas_2005
Posts: 37
Joined: Mon Oct 05, 2020 3:48 am

Re: Yad -- Update textinfo from file stdin-input

Post by arivas_2005 »

After searching .. searching and searching
I found a little script suggested by MochiMoppel
is at http://murga-linux.com/puppy/viewtopic. ... &start=285
and is the following:

Code: Select all

#!/bin/bash
export PIPE_03=/tmp/yadpipe03
mkfifo $PIPE_03
exec 3<> $PIPE_03

yad --icons --single-click --height=300 --width=500 --listen < $PIPE_03 &
echo -e "Name\nTooltip\ngtk-ok\nbeep\nFALSE" > $PIPE_03
sleep 1
echo -e "Yes\nTooltip\ngtk-yes\nbeep\nFALSE" > $PIPE_03
sleep 1
echo -e "No\nTooltip\ngtk-no\nbeep\nFALSE"   > $PIPE_03

------------------------
I must explain that there are several elements of the script that I do not know and do not understand how they are used and what they are used for in each case
But...
------------------------
After experimenting again and again, I was able to rebuild and thus I found the answer to what I was looking for.
"how to insert data in yad after the window is opened." I had something like that.

Code: Select all

#!/bin/bash
export PIPE_03=/tmp/yadpipe03
mkfifo $PIPE_03
exec 3<> $PIPE_03

#yad --icons --single-click --height=300 --width=500 --listen < $PIPE_03 &
yad --title "unodostrescuatro" --text-info < $PIPE_03 > /tmp/yadpipe04 --editable --listen --monitor --height=220 --width=70 & 
for i in {1..2}
do
		echo -e "PASS  ""$i" > $PIPE_03
		sleep 2
done
sleep 2
echo -e "FIN  " > $PIPE_03
###--------------
#Now my problem is how to retrieve the content. 
#I have experimented with these lines and cannot capture the content of the yad
echo "----------------------1"
tail -f $PIPE_03 
echo "----------------------2"
cat >$PIPE_03 &
cat $PIPE_03
echo "----------------------3"
tail -F  /tmp/yadpipe04 
echo "----------------------4"
# I need to retrieve that content from the PIPE or /tmp/yadpipe04 

.
Now my problem is how to retrieve the content.
I need to retrieve that content from the PIPE or /tmp/yadpipe04
I'm sure this little script can be done better or corrected unnecessarily
--------------------
Thanks

User avatar
fredx181
Posts: 2626
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 291 times
Been thanked: 1028 times
Contact:

Re: Yad -- Update textinfo from file stdin-input

Post by fredx181 »

Not sure what exactly you want to accomplish, but to update text-info, I would just pipe it to yad like this:

Code: Select all

(
for i in {1..5};do
echo $i 
sleep 3
done
) | yad --geometry=20x40+500+400 --fontname="Arial Bold 15" --wrap --justify="center" --margins=1 --tail --editable --fore=green --back=yellow --listen --auto-close --auto-kill --monitor --text-info &

Fred

arivas_2005
Posts: 37
Joined: Mon Oct 05, 2020 3:48 am

Re: Yad -- Update textinfo from file stdin-input

Post by arivas_2005 »

thanks for the reply, Fred
my dilemma is that the yad must receive different inputs, (because the script is lengthened and the yad receives the inputs)
that is why I have placed the yad first and the script after.
was what attracted me to the MochiMoppel version

So that's my dilemma.
If the script goes later and will fill up with several entries, in the end, how do I collect everything at once
that's what i tried to do with him $PIPE_03 > /tmp/yadpipe04
but when running a 'cat /tmp/yadpipe04'
it doesn't work for me (as if the file /tmp/yadpipe04 is trapped).

The file /tmp/yadpipe04 does battle everything that is entered and edited, but I cannot access it ! ..
with cat nothing comes out (/tmp/yadpipe04) but when I see the file with leafpad it is filled with everything I enter the yad box
So ... how do I read (/tmp/yadpipe04) it during the process?
(or it is not possible what I am trying to do?)
Thanks!

User avatar
MochiMoppel
Posts: 1128
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 18 times
Been thanked: 366 times

Re: Yad -- Update textinfo from file stdin-input

Post by MochiMoppel »

arivas_2005 wrote: Mon Nov 30, 2020 9:06 pm

that's what i tried to do with him $PIPE_03 > /tmp/yadpipe04

This should work, however you probably attempt to read the file when it still has no data.

When you start the yad command is creates an empty /tmp/yadpipe04
The yad command ends with a trailing '&', which means that the dialog window pops up and the script continues
When the script reaches a tail or cat comand while the dialog is still open, your tail or cat command will fail because there are still no data to read.
After you close the yad dialog with the "OK" button all data will be written to /tmp/yadpipe04 and you should be able to read the file.

arivas_2005
Posts: 37
Joined: Mon Oct 05, 2020 3:48 am

Re: Yad -- Update textinfo from file stdin-input

Post by arivas_2005 »

Thanks!

Post Reply

Return to “Programming”