08-22-2021 09:52 PM - edited 08-23-2021 12:29 AM
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:
Looking forward to hear your comments and suggestions.
Thanks,
Gilad Darshan
Posted on 06-16-2022 09:33 AM
@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.
Posted on 11-29-2022 10:10 PM
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:
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.