gDialog - macOS Dialogs and Prompts

gdarshan
New Contributor

Hello Jamf Nation!

 

I'm happy to announce the release of gDialog, a new utility for macOS dialogs and prompts from terminal and scripts. 

gDialog is available for macOS Big Sur and Catalina and currently only as an Intel package, M1 Macs will require Rosetta in order to use gDialog.

The CLI was designed to be as close as possible to CocoaDialog where it made sense for an easy transition in the different workflows.

 

Full documentation, examples and download link can be found at https://github.com/giladdarshan/gdialog.

 

Available dialogs:

  • Message Box

          gdialog-msgbox.png

  • Input Box

          gdialog-inputbox.png

  • Secure Input Box

          gdialog-secure-inputbox.png

  • Text Box - macOS Big Sur+

          gdialog-textbox.png

  • Credentials Box

          gdialog-credentialsbox.png

  • HTML Box - Capable of displaying simple HTML forms and advanced pages or websites and also a "kiosk" mode for a locked down full screen dialogs

          gdialog-htmlbox.png   gdialog-htmlbox-jamfnation.png

  • Progress Bar

          gdialog-progressbar.gif   gdialog-progressbar-indeterminate.gif

  • Picker Box

          gdialog-pickerbox-dropdown.gif

          gdialog-pickerbox-radio.png

          gdialog-pickerbox-segmented.gif

  • File Select

          gdialog-fileselect-2.png

          gdialog-fileselect.png

  • File Save

          gdialog-filesave-2.png

          gdialog-filesave.png

  • Banner Box

          gdialog-bannerbox.png

          gdialog-bannerbox-one-button.png

          gdialog-bannerbox-two-buttons.png

  • Notification (via Notification Center)

          gdialog-notification-bigsur.png

 

Looking forward to hear your comments and suggestions.

 

Thanks,

Gilad Darshan

2 REPLIES 2

steve_summers
Contributor III

@gdarshan hey there....love gdialog and am attempting to use it in a rollout I'm working on.  I need to ask a question regarding the Credentials Box.  I've been reviewing the documentation and am unable to discern how the username and password are saved via the dialog box.  Would you be able to let me know how I can save these values so I can call them later?  I appreciate what you've created here.  Thanks. 

Hey @steve_summers,

Very sorry for the delay, Jamf didn't send me a notification on the comment so I recommend next time to open an issue in GitHub.

 

For the Credentials Box, you get back the values in separate lines:

  • Number of button clicked
  • Value of first field
  • Value of second field

 

For example, when entering "aloha" in the first field and "fluffy" in the second field:

 

Mac:~ root# /usr/local/gDialog/gDialog.app/Contents/MacOS/gDialog credentialsbox --title "Title" --header "Header" --text "Enter your corporate credentials:" --focus
1
aloha
fluffy

 

 

To save the values, you need to convert the result multi-line string to an array and save it in a variable.

I would also recommend to use the "--encode_text" option which will encode the values in base64 to ensure special characters are not being interpreted and you get exactly the values that were entered in the dialog (for example "\n" in the value will be interpreted as a new line).

 

First we run the command, convert it to array and store it in a variable called "CREDENTIALS":

 

Mac:~ root# CREDENTIALS=($(/usr/local/gDialog/gDialog.app/Contents/MacOS/gDialog credentialsbox --title "Title" --header "Header" --text "Enter your corporate credentials:" --focus --encode_text))

 

 

Now we can get the stored values, since we used "--encode_text", the second and third array items will require decoding the base64:

 

Mac:~ root# echo -n "${CREDENTIALS[1]}"
1
Mac:~ root# echo -n "${CREDENTIALS[2]}" | base64 -D
aloha
Mac:~ root# echo -n "${CREDENTIALS[3]}" | base64 -D
fluffy

 

As you can see above, array item 1 is the number of the button that was pressed and does not require decoding, item 2 is the encoded value of the first field and requires decoding the base64, item 3 is the encoded value of the second field and also requires decoding.

 

Please let me know if it answered your question or not.