kdialog
Display KDE dialog boxes from shell scripts
TLDR
Open a dialog box displaying a specific message
Open a question dialog with a yes and no button, returning 0 and 1, respectively
Open a warning dialog with a yes, no, and cancel button, returning 0, 1, or 2 respectively
Open an input dialog box and print the input to stdout when OK is pressed
Open a dialog to prompt for a specific password and print it to stdout
Open a dialog containing a specific dropdown menu and print the selected item to stdout
Open a file chooser dialog and print the selected file's path to stdout
Open a progressbar dialog and print a D-Bus reference for communication to stdout
SYNOPSIS
kdialog [generic options] [box options]
PARAMETERS
--title
Sets the titlebar text.
--yes-button
Sets the label for the Yes button.
--no-button
Sets the label for the No button.
--msgbox
Displays a message box with the specified text.
--inputbox
Displays an input box with the specified text. The optional
--textbox
Displays the contents of the specified file in a text box.
--menu
Displays a menu with the specified options.
--checklist
Displays a checklist with the specified items and initial status (on/off).
--radiolist
Displays a radio button list with the specified items and initial status (on/off).
--getopenfilename [
Displays a file selection dialog for opening a file. The optional
--getsavefilename [
Displays a file selection dialog for saving a file. The optional
--getexistingdirectory [
Displays a directory selection dialog. The optional
--color
Displays a color selection dialog.
--password
Displays a password input box.
--progressbar
Displays a progress bar.
--error
Displays an error message box.
--warning
Displays a warning message box.
--info
Displays an information message box.
--yesno
Displays a yes/no question dialog box.
--ok-cancel
Displays an ok/cancel dialog box.
DESCRIPTION
kdialog is a powerful command-line utility that allows you to display KDE dialog boxes from within shell scripts. It provides a simple way to interact with the user graphically, without needing to write complex GUI code. kdialog can be used to create a wide variety of dialogs, including message boxes, input dialogs, file selection dialogs, color selection dialogs, and more. This makes it a versatile tool for creating interactive shell scripts, system administration tools, and other applications where user input is required.
kdialog relies on the KDE libraries being installed, which is generally the case in KDE Plasma Desktop environments or systems with KDE applications installed. When executed, kdialog communicates with the X server to create and display the dialog box. The user's interaction with the dialog (e.g., clicking a button, entering text) results in kdialog returning a specific exit code or printing data to standard output, which the calling script can then process.
CAVEATS
kdialog requires the KDE libraries to be installed and a running X server. It might not work as expected in environments without KDE or a graphical interface.
The appearance and behavior of the dialogs may vary depending on the KDE theme and settings.
EXIT CODES
kdialog returns different exit codes based on the user's action:
0: Ok/Yes was pressed
1: Cancel/No was pressed
255: An error occurred
USING WITH PIPES
kdialog can be effectively used with pipes. For instance, you can pipe the output of a command into a kdialog textbox. Example:
ls -l | kdialog --textbox -
HISTORY
kdialog has been part of the KDE project for a long time, providing a convenient way to integrate graphical dialogs into shell scripts. It has evolved over the years, with new dialog types and options added to enhance its functionality.