bashmacosterminalshtput

Display a splash screen or dialog box from bash script while script is running


I want to create a splash screen/ active dialog box while my script is running in the background to inform the user what is happening. My script file starts up different components of a local application and has a bunch of words & stuff that the user doesn't need to see/won't understand. I know how to make the script run in the background but I would like to know how I can possibly bring up a dialog box, new terminal window, notification, or similar to let the user know once each component has started.

For instance I have 4 components so the box would come up and say:

Component 1 of 4 successfully started..

Component 2 of 4 successfully started..

and so on...

Any help appreciated as I have searched for a while with no luck. One thing to add is that I was able to bring up a new terminal window with the following code: /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal &

Which would be fine, however when I echo it still goes to the first one.


Solution

  • You may also notify the user with launching notification messages:

    osascript -e 'display notification "hello"'
    

    Or even a dialog box, but this will wait for the user to click the "OK" button:

    osascript -e 'display alert "Hello"'
    

    Example:

    #!/bin/bash
    
    osascript -e 'display notification "Component 1 of 4 successfully started.." with title "in progress"'
    sleep 2
    osascript -e 'display notification "Component 2 of 4 successfully started.." with title "in progress"'
    sleep 2
    osascript -e 'display alert "Processing done."'