Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 16 Oct 2019, 14:15
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
YAD - Tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 48 of 50 [742 Posts]   Goto page: Previous 1, 2, 3, ..., 46, 47, 48, 49, 50 Next
Author Message
Wognath

Joined: 19 Apr 2009
Posts: 421

PostPosted: Sat 07 Sep 2019, 13:40    Post subject: timeout=zero  

In a script, I call a function
Code:
yad --timeout=$x --button=cancel && cancel action || timeout action
Usually, $x is 10 or 60, but in one case I want to go immediately to the timeout action. x=0 disables timeout, but any non-integer string results in yad error, exit code 255, and gives the desired result.
A trivial tip, but mine own Confused
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1921
Location: Japan

PostPosted: Sun 08 Sep 2019, 00:00    Post subject:  

Laughing
I wouldn't count on it.
Exploiting an error is one thing and works here since you don't test for a real timeout (exit code 70), but relying on a possible bug is another thing. Other dialogs like Xdialog or gxmessage treat a timeout text string (or empty string) as "0", the same as bash. IMO this is the way yad should behave.

Instead of letting yad crash you could achieve what you want by testing $x. If it is empty or contains any non-numeric character then go straight to your timeout action:
Code:
[[ $x =~ [0-9]+ ]] && yad --timeout=$x --button=cancel && echo cancel action || echo timeout action
Back to top
View user's profile Send private message 
Wognath

Joined: 19 Apr 2009
Posts: 421

PostPosted: Mon 09 Sep 2019, 17:19    Post subject:  

MM, thanks for your insight, as always. If the author fixes this "possible bug", then I'll certainly have to change my script!
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Thu 12 Sep 2019, 06:57    Post subject: convert flexibly  

Hello everybody,

I have created a YAD code to convert images. Now I want to make the fixed 50% but flexible. For this I need one, however, an additional input field. Can someone tell me if another query is needed or can I do everything with the following
Code:


]#!/bin/bash

# Bilder konvertieren (Einzeln)

cd $HOME/Bilder/

TITLE="Bild konvertieren"
TEXT="<span foreground='red'><b><big><big>
      Bitte das gewünschte Bildformat wählen, eine beliebige Datei selektieren und mit 'OK' fortfahren!
</big></big></b></span>"

filename=$(yad --width=1600 --height=600 --window-icon="$HOME/.icons/Movies-icon24.png" --title="$TITLE" --file-selection \
            --text="$TEXT" --button=" Abbrechen!$HOME/.icons/Button-stop-icon24.png":1 --button=" OK!$HOME/.icons/Accept-icon24.png":0 \
            --file-filter='*.png' --file-filter='*.jpg' --file-filter='*.tif')

pfadname=${filename}
verz=${filename%/*}
datm=${pfadname##*/}
dato=${datm%.*}
   
cd  "$verz"

[[ -z "$filename" ]] && exit 0

case $filename in
     *.png)

echo "Konvertierung des Bildes "$datm" läuft...";
    convert "$datm" -resize 50% "$datm"-neu.png
yad --text="<span color='red'>Die Konvertierung des Bildes

$datm

wird erzeugt...</span>" --width=550 --window-icon="$HOME/.icons/Movies-icon24.png" \
--title="Verlaufskontrolle" --text-align=center --no-buttons --timeout=3;   
    ;;

     *.jpg)

echo "Konvertierung des Bildes "$datm" läuft...";
    convert "$datm" -resize 50% "$datm"-neu.jpg
yad --text="<span color='red'>Die Konvertierung des Bildes

$datm

wird erzeugt...</span>" --width=550 --window-icon="$HOME/.icons/Movies-icon24.png" \
--title="Verlaufskontrolle" --text-align=center --no-buttons --timeout=3;   
    ;;

     *.tif)

echo "Konvertierung des Bildes "$datm" läuft...";
    convert "$datm" -resize 50% "$datm"-neu.tif
yad --text="<span color='red'>Die Konvertierung des Bildes

$datm

wird erzeugt...</span>" --width=550 --window-icon="$HOME/.icons/Movies-icon24.png" \
--title="Verlaufskontrolle" --text-align=center --no-buttons --timeout=3;   
    ;;

esac
exit 0

Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 87

PostPosted: Thu 12 Sep 2019, 08:28    Post subject: Re: convert flexibly  

achim wrote:
Hello everybody,

I have created a YAD code to convert images. Now I want to make the fixed 50% but flexible. For this I need one, however, an additional input field. Can someone tell me if another query is needed or can I do everything with the following

You made one for each forum. (•‿•)
The answer is is in the other one. Laughing
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Thu 12 Sep 2019, 08:50    Post subject: Re: convert flexibly  

You are the best - thank you Smile Smile
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Mon 16 Sep 2019, 14:08    Post subject:  

i cant activate yad notification icon right-click on touchscreen. what would be a workaround?

stemsee
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Tue 17 Sep 2019, 19:04    Post subject:  

To answer my own question! I added "bash -c 'xdotool click 3'" as yad notification --command.
Back to top
View user's profile Send private message MSN Messenger 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Wed 18 Sep 2019, 07:38    Post subject:  

I have a question for the experts,

is it possible to fix a YAD information window so that only the content is changed via a for loop running in the background?

Greetings achim
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Wed 18 Sep 2019, 09:26    Post subject:  

achim

im not an expert but yes,
Code:
mkfifo /tmp/testpipe
exec 8<> /tmp/testpipe

yad --text-info --listen --width=200 --height=200 <&8 &
while sleep 8
do
echo -e '\f' >/tmp/testpipe
yad --entry >/tmp/testpipe
done

comment out the echo line if you want accumulative updates.
Back to top
View user's profile Send private message MSN Messenger 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Wed 18 Sep 2019, 11:02    Post subject:  

Thank you stemseee, you helped me a lot!
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Wed 18 Sep 2019, 14:02    Post subject:  

After I have dealt a little closer with the answer of stemsee I have to say that it is for me at the moment a little more complicated than I thought. Especially since I have not used mkfifo and exec so often. But I want to learn to handle it.
Currently I have a snippet of code with which I want to reach, which can be seen in a YAD window, which image files are being copied. However, this code opens a new window for each file. I have not been able to apply the example of stemsee to my situation.

Code:

....
z=0

for f in *.jpg; do name=`echo "${f%.*}"`; echo "Kopiervorgang des Bildes "$f" läuft...";
   rsync -t $CAMERA/"$f" $ZIEL/$DATE/;
   z=$[$z+1];
TEXT='<span color=\"blue\" font="Monospace italic 12">

Der Kopiervorgang des Bildes

'$f'

wird als laufende Nr. '$z' durchgeführt...

</span>'
   yad --text="$TEXT" --width=600 --fixed --window-icon="$HOME/.icons/Movies-icon24.png" \
--title="Verlaufskontrolle" --text-align=center --no-buttons --timeout=1;   
done

echo $z Bilder kopiert.
....
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4123
Location: holland

PostPosted: Wed 18 Sep 2019, 16:46    Post subject:  

Hi achim, probably there are different ways, but what I would do is pipe to a yad --text-info dialog, like this:
Code:
cd $CAMERA/
(
z=0
for f in *.jpg; do name=`echo "${f%.*}"`; echo "Kopiervorgang des Bildes "$f" läuft..."
   rsync -t $CAMERA/"$f" $ZIEL/$DATE/;
   z=$[$z+1];

echo "Der Kopiervorgang des Bildes"

echo "$f"

echo "wird als laufende Nr. $z durchgeführt..."
echo "$z Bilder kopiert"
done
) | yad --text="Kopiervorgang des Bildes" --width=600 --height 200 --fixed --window-icon="$HOME/.icons/Movies-icon24.png" --text-info --wrap --tail \
--title="Verlaufskontrolle" --text-align=center --no-buttons

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Thu 19 Sep 2019, 07:47    Post subject:  

out of interest

non pipe version. type on commandline and hit enter to send.

How to make it send as it is being typed without newlines until return is hit??

Code:
while true; do read ound; echo "$ound"; done | yad --text-info --listen --width=200 --height=200

Last edited by stemsee on Thu 19 Sep 2019, 07:52; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Thu 19 Sep 2019, 07:51    Post subject:  

Hello Fred,

this is a very good tip, which I also like to take over. However, after terminating the for loop, the variable "z" is no longer available. Do you know how to get around this problem?

PS. would like to give you some coffee for your good tips. Are you possibly in Germany? Smile
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 48 of 50 [742 Posts]   Goto page: Previous 1, 2, 3, ..., 46, 47, 48, 49, 50 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2622s ][ Queries: 12 (0.1248s) ][ GZIP on ]