1

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.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • 1
    What's wrong with just printing these messages to the current shell? – Benjamin W. Dec 17 '18 at 21:00
  • 1
    There are *lots* of different `dialog` tools for this purpose. Which one is appropriate for your purpose is a tool-selection question, and we disallow those here; however, you mind find https://invisible-island.net/dialog/ a reasonable place to start, as while it's written by the author of one of these tools, it links to several others ([Zenity](https://en.wikipedia.org/wiki/Zenity), [kdialog](https://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs), gdialog, [whiptail](https://en.wikibooks.org/wiki/Bash_Shell_Scripting/Whiptail), etc). – Charles Duffy Dec 17 '18 at 21:11
  • @BenjaminW. There is just too much going on in the current shell The user won't be able to understand whats happing, it looks messy, and whatever i do print there will just get lost too quick – User-78436752871 Dec 17 '18 at 21:44
  • @CharlesDuffy Since this is will be used for multiple users/clients I wouldn't want to have everyone have to go and download dialog tools before being able to run the script, but thanks! – User-78436752871 Dec 17 '18 at 21:46

1 Answers1

0

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."'
Yoric
  • 1,761
  • 2
  • 13
  • 15