1

here is an example of my code:

#!/bin/bash

while true; do

wget www.website.com/picture.jpg

qiv picture.jpg --command -blah -blah -blah

sleep 600

done

My question is how can I kill qiv? For those unfamiliar, qiv shows an image in fullscreen mode. Therefore, this script doesn't move on until qiv is exited (manually), but I want this automatic! For those wondering, it's for a digital picture frame that pulls pictures from a network. My full script works, but I have to manually press [ESC] to let the script progress. I'm sure there's a simple command to do this, and if not, could you please explain any arguments/ commands as I'm unfortunately not very experienced with bash script.

Thank you for taking the time to read this, and thanks for any help!

7
  • 1
    qiv has a --delay option, which you can give a number of seconds. This sets the "slideshow delay". Maybe you could use this instead of sleep? linux.die.net/man/1/qiv Commented Nov 17, 2013 at 2:02
  • Hi c.anna, thanks for taking the time to respond. I apologize for not mentioning necessary information in the first post and I have edited appropriately. I use wget to download a picture and I display that picture for 10 minutes, then re-download from the same location (but it's a different picture) and then display the new one. So to get to the next picture, I have to hit [ESC], wait the sleep command out, then it works. I'm trying to get rid of pressing [ESC]. Commented Nov 17, 2013 at 2:14
  • It looks like you want the T, --watch Reload the image if it has changed on disk. option. You then run qiv once, and let your sleep loop collect the image. If it changes, qiv will redisplay. Commented Nov 17, 2013 at 2:19
  • Yes! That does sound like a great idea for this. However, how can I run qiv once and then run a constant loop? if I just change my code to move the qiv command above the while loop and add an &, is it that simple? Thank you for the response, I saw that argument but didn't know how to simultaneously run the loop and quiv. Commented Nov 17, 2013 at 2:21
  • The chances are high that it is as simple as qic -T ... & and then loop. You probably want to keep a track of the PID of your qiv process so that you can kill it when your script exits (eg someone interrupts it). That's $! immediately after the qiv command: qiv -T ... & QIV_PID=$!. Commented Nov 17, 2013 at 2:25

1 Answer 1

1

If all else fails:

while true; do

wget www.website.com/picture.jpg

killall -9 qiv                                  #<- kill backgrounded qiv

qiv picture.jpg --command -blah -blah -blah &   #<- backgrounding new qiv

sleep 600

done
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer! Could you answer this question for me though: when qiv and sleep get executed together (as per the &), does it move on AFTER either one ends, or when 'both' end. I was under the impression it continues when both end so I didn't consider taking this route.
Dont confuse & and &&: qiv will be started in the background so the script will immediately continue. Sleep is then executed, after 600 seconds wget is executed and when wget is finished, qiv will be killed and started in the background again. All this time qiv was running in parallel with the script because it was backgrounded. Consider qiv as "launched" because the script will not wait for qiv to end, the script just moves on after qiv's "launch".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.