I have a shell script running in crontab to perform certain checks. In case of any problem I want to alert user. For that purpose I am using zenity and play command

zenity --error --text='Something has happened!' --display=:0.0   // for pop up
play /somepath/somefile.wav                                      // for sound

These two are working fine independently. But I want to play the alarm until zenity error is acknowledged. After searching in internet I found zenity does not have audio alarm inbuilt support. I want to know how to achieve my goal. Any other solution is also ok if it is not a third party solution.

zenity --error --text='Something has happened!' --display=:0.0 &
while [ -d /proc/$! ];do play /somepath/somefile.wav;done
  • This could do with some explanation. Also it won't work without &. Finally this is highly dependent on how the shell implements its wait calls. So I'd worry if a minor implementation change of the shell in the future would cause it to stop working. You are not explicitly calling wait you are relying on the shell doing it implicitly. If the shell didn't do that you'd be looping forever waiting for a zombie to go away, meanwhile the zombie will stay around until the parent waits or terminates. – kasperd Jul 23 '18 at 9:35
  • It worked for me. @kasperd can you provide some elegant solution? – Sush Jul 23 '18 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.