<div dir="ltr">2013/9/12 Nils Kassube <span dir="ltr"><<a href="mailto:kassube@gmx.net" target="_blank">kassube@gmx.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">Johnny Rosenberg wrote:<br>
> I can't make exit work as I thought it would work…<br>
><br>
> #!/bin/bash<br>
><br>
> Title="Error"<br>
> ERROR="Something bad happened."<br>
><br>
> while [ something ]; do<br>
>     if [[ something_bad ]]; then<br>
>         yad --title "${Title}" \<br>
>             --image=error \<br>
>             --text "${ERROR}" \<br>
>             --no-buttons \<br>
>             --timeout 5 &<br>
>         exit 1<br>
>     fi<br>
> done<br>
> more_statements<br>
><br>
> # End of code<br>
><br>
> The problem is that even if something_bad happens, more_statements are<br>
> executed. The yad error messages is displayed as expected, though.<br>
<br>
</div>Why do you put the yad command in the background? Maybe that's the<br>
reason why it doesn't work. Would it be a problem if the script stops<br>
after the yad job exits? After all it seems like it should display the<br>
error message for only 5 seconds.<br></blockquote><div><br></div><div>I tried without putting it to the background too before I posted this, but there was no difference, so I kept the & character in this example.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> (yad is a dialogue, similar to zenity, or even a zenity fork, I think<br>
> – yad=Yet Another Dialogue)<br>
<br>
</div>Why do you use yad and not zenity? A short test with zenity worked here.<br></blockquote><div><br></div><div>Zenity had a nasty bug when used in a special way, and since I don't like mixing things that basically do the same thing, I just decided to go with yad instead. This example works with both, but I have a few more scripts which didn't work with Zenity, and the developers didn't seem too keen on correcting the bug. Right now I don't even remember what the bug was about, though…</div>
<div><br></div><div>Anyway, here's a ”working” example to show you what I mean. Just type it in and run it… (replace yad with zenity if you don't have yad installed, or install yad).</div><div><br></div><div>#!/bin/bash<br>
<br>WaitTime=10<br>TargetPath="This/path/does/not/exist"<br><br>if [ ! -e "${TargetPath}" ]; then<br>     Time=0<br>      StartTime=$(date +%s%N)<br><br>          while [ ! -e "${TargetPath}" ]; do<br>
                          sleep .1<br>                        Time=$(($(date +%s%N)-StartTime))<br>                       if [[ Time -ge WaitTime*10**9 ]]; then<br>                                       yad --title "Folder missing"                                                                  \<br>                                                 --image=error                                                                                           \<br>
                                                    --text "Your device is not connected."                                                \<br>                                                 --no-buttons                                                                                            \<br>                                                 --timeout 5<br>                                  exit 1<br>                          fi<br>
                          echo "$((Time/10**7/WaitTime))"<br>                       Seconds=$((WaitTime-Time/10**9))<br>                        MM=$((Seconds/60))<br>                      SS=$((Seconds-MM*60))<br>                   echo \#$(printf "%s %d:%02d." "Time to connect your device:" "$MM" "$SS")<br>
             done |                                                                                                                                  \<br>     yad --progress                                                                                                                       \<br>                       --title="Folder missing"                                                                                      \<br>                       --image=time                                                                                                            \<br>                       --percentage=0                                                                                                          \<br>
                          --auto-close<br>fi<br><br>yad --image="info"        \<br>          --title="Another dialogue"    \<br>          --text="You shouldn't see this dialogue"</div><div><br></div><div># End of code</div>
<div><br></div><div>Since the path given doesn't exist, the progress dialogue will count down time for ${WaitTime} seconds. After that the Folder missing dialogue will appear and disappear after 5 seconds. The script should then exit, but it doesn't, because the last dialogue comes up, and it shouldn't, should it? If it should, what die I do wrong?</div>
<div><br></div><div><br></div><div></div><div><br></div><div>Johnny Rosenberg</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<span class=""><font color="#888888"><br>
<br>
Nils<br>
<br>
<br>
--<br>
ubuntu-users mailing list<br>
<a href="mailto:ubuntu-users@lists.ubuntu.com">ubuntu-users@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br>
</font></span></blockquote><br></div>