Gdialog

1 view
Skip to first unread message

Dallas Themshirts

unread,
Aug 3, 2024, 1:31:25 PM8/3/24
to namantoular

@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.

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).

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.

Jamf's purpose is to simplify work by helping organizations manage and secure an Apple experience that end users love and organizations trust. Jamf is the only company in the world that provides a complete management and security solution for an Apple-first environment that is enterprise secure, consumer simple and protects personal privacy. Learn about Jamf.

This site contains User Content submitted by Jamf Nation community members. Jamf does not review User Content submitted by members or other third parties before it is posted. All content on Jamf Nation is for informational purposes only. Information and posts may be out of date when you view them. Jamf is not responsible for, nor assumes any liability for any User Content or other third-party content appearing on Jamf Nation.

The problem is the switch case executes and the control flow reaches the first case or second case but the line after the declaration of MSG variable does not execute. I am intending to ask the user if they want to continue by using a yes/no gdialog. What am I doing wrong here?

dialog will write its result to the standard error unless you do some workaround with redirection, or use the --stdout option (because, like any curses application, it writes its display to the standard output by default, and reports on the standard error). You wouldn't notice that with gdialog, since it writes its display to another window.

Because of this, gdialog would be writing nothing to the standard output, and $choice would be empty. The script will execute the case-statement, but not match any of the cases. As a rule, case statements should have a default, e.g., *) so that you can put a message there and see what is going on.

Not part of the question, but how to work around the problem seems to be expected. The script refers to gdialog, which likely is a script calling zenity (the original gdialog is long gone). Neither has the --stdout option, though that probably predates either program (see changelog entry from 2000). You can work around that in the shell by exchanging the file-descriptors for the standard output and error. That has been in dialog's sample scripts since late 2000 also, using a suggestion by Carey Evans (tn5250 developer):

After recognizing the importance of front ends, many developers started writing tools that could be used to easily create front ends for programs. Initially there was Dialog, which could be used to create more user-friendly text interfaces for command-line tools. As the Linux GUI userbase grew, developers created GUIs such as Xdialog, gdialog, and KDialog.

Zenity evolved from gdialog to create Gtk-specific front ends, and can be used to display GTK+ dialog boxes. Its usage and options are similar to those of gdialog, but, as its home page claims, it has a cooler name and is easier to use. Front ends created with Zenity have the same look and feel as those of other graphical applications under GNOME.

To create a basic menu, you need to use the --list option along with either the --checklist or the --radiolist option. Other options, such as --title, have the same usage as dialog and Xdialog. For example, to create a radio list, use:

Notice the two --column switches. They are a must. You cannot have a list without the two columns. That is, you cannot create a list with just one or no columns. The first column shows a checkbox or a radio button, depending on what kind of list you wish to create, and the other lists the available options.

When you run this code, the selected fruit is displayed on the screen, because Zenity writes the output to standard display by default. To save the selection to a text file, simply redirect the output to a file using > filename at the end of the command.

You can use the --calendar option to display a calendar. When used without any other options, such as --month, --day, and --year, it displays the current day and month. All options expect an integer value, so the year 1985 is 1985, Wednesday is 4, and so on. Be careful when specifying the year. If you write 1985 as 85, all days are moved up by one. That is, September 2, 1985, which was a Monday, becomes Sunday if the year is specified as 85, because it actually calculates for 2085.

The $? variable stores the return value. It is 0 if you press Ok and 1 if you press Cancel. Once you select a file, its path is stored in the SELECTED_FILE variable. The --text-info option enables us to view the file. The --editable option makes the file editable. When you are through editing the files, the changes are stored in a new file.

You can make a message box with --msgbox. If you wish to display more than one line in the message box, you can use n to signify a new line: kdialog --msgbox "This is first line. n This is second line.". You cannot specify the dimensions of a msgbox. The width and height depend on the length and the number of lines of text.

In certain situations, such as copying files from one location to another, the warning box needs to have Yes/No options, while Continue/Cancel options are required when the user chooses to delete files. The --warningyesno or --warningcontinuecancel options allow you to do those.

Use the --inputbox dialog box if you want the user to insert some text. The string entered is displayed on standard output. To display a dialog box where the user can enter a name, use kdialog --title "An input dialog" --inputbox "Enter your full name:" . You can also display a default text string in the input box with kdialog --title "An input dialog" --inputbox "Enter your full name:" "John Doe"

To open a file selection dialog box, use the --getopenfilename dialog box. It requires a start directory position. To open the current directory you run the command kdialog --getopenfilename . where . represents the current directory. Replacing the . with /etc would open the /etc directory.

Optionally, you can use filter arguments to restrict what types of files are displayed. kdialog --getopenfilename /home/linuxlala/Desktop/me/ "image/png text/plain" would display only PNG and text files. You can even use wildcards to restrict files, such as *.mp3 in place of the MIME filter arguments.

KDialog seems far more helpful in terms of the basic options it provides. Other than that, both tools work flawlessly out of the box and require almost no getting used to. A basic shell scripting knowledge is a must, though, if you wish to create front ends for your favorite commands.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages