LinuxCommandLibrary

kdialog

Display KDE dialog boxes from shell scripts

TLDR

Open a dialog box displaying a specific message

$ kdialog --msgbox "[message]" "[optional_detailed_message]"
copy

Open a question dialog with a yes and no button, returning 0 and 1, respectively
$ kdialog --yesno "[message]"
copy

Open a warning dialog with a yes, no, and cancel button, returning 0, 1, or 2 respectively
$ kdialog --warningyesnocancel "[message]"
copy

Open an input dialog box and print the input to stdout when OK is pressed
$ kdialog --inputbox "[message]" "[optional_default_text]"
copy

Open a dialog to prompt for a specific password and print it to stdout
$ kdialog --password "[message]"
copy

Open a dialog containing a specific dropdown menu and print the selected item to stdout
$ kdialog --combobox "[message]" "[item1]" "[item2]" "[...]"
copy

Open a file chooser dialog and print the selected file's path to stdout
$ kdialog --getopenfilename
copy

Open a progressbar dialog and print a D-Bus reference for communication to stdout
$ kdialog --progressbar "[message]"
copy

SYNOPSIS

kdialog [--title title] [--icon icon] [--geometry geometry] {dialog-type [arguments]}

PARAMETERS

--title title
    Sets the window title for the dialog

--icon icon
    Specifies an icon file or name for the dialog

--passivepopup text [--timeout secs]
    Shows a non-interactive popup notification

--msgbox text
    Displays a simple informational message box

--sorry text
    Shows a message with a red 'sorry' icon

--warning text
    Displays a warning message with caution icon

--error text
    Shows an error message with stop icon

--yesno text
    Yes/No dialog; returns 0 for Yes, 1 for No

--yesnocancel text
    Yes/No/Cancel; returns 0/1/2

--inputbox var prompt [default]
    Text input dialog storing result in var

--password var prompt
    Password input with hidden text

--textbox file [width height]
    Scrollable text viewer for file contents

--calendar var [date]
    Date selection calendar outputting to var

--combobox var prompt value:value:...
    Dropdown selector for predefined values

--menu var prompt label1|value1 ...
    Single-selection menu

--checklist var prompt label1|value1 ... [--keep]
    Multi-select checkboxes; --keep retains selections

--radiolist var prompt label1|value1 ...
    Single-select radio buttons

--separate-output
    Outputs multi-selections on separate lines

--print
    Prints result to stdout instead of variable

--geometry WxH+X+Y
    Sets dialog window geometry

--help
    Displays usage information

DESCRIPTION

kdialog is a versatile command-line tool from the KDE Plasma desktop environment, designed to display native graphical dialog boxes directly from shell scripts. It enables interactive user interfaces for tasks like confirmations, data input, file browsing, and notifications without requiring full-fledged GUI programming.

Supporting a wide range of dialog types—including message boxes, yes/no prompts, password entries, combo boxes, menus, checklists, and calendars—kdialog integrates seamlessly with Qt/KDE widgets for consistent appearance. Users set dialog content via arguments, capture outputs in variables, and control aspects like titles, icons, geometry, and timeouts. Ideal for automating user interactions in scripts, such as setup wizards, error reporting, or configuration tools.

While lightweight and script-friendly, it depends on a graphical session, making it unsuitable for headless servers. Its simplicity contrasts with more complex GUI frameworks, promoting quick prototyping in bash or other shells.

CAVEATS

Requires KDE Plasma or compatible Qt graphical session; fails silently in text-only environments. Some dialogs block until dismissed; use --passivepopup for non-blocking.

EXIT STATUS

0: OK/Yes/selected; 1: Cancel/No; 2+: other (e.g., error). Use echo $? to check.

EXAMPLE USAGE

kdialog --title 'Confirm' --yesno 'Delete file?'
if [ $? -eq 0 ]; then rm file; fi
VALUE=$(kdialog --inputbox 'Enter name' 'Name:')

HISTORY

Developed in late 1990s as part of KDE 1.x kdelibs for scriptable dialogs. Evolved through KDE 3/4/Plasma eras; now in KDE Frameworks, with ongoing maintenance for Plasma 5/6 compatibility.

SEE ALSO

zenity(1), dialog(1), yad(1), gxmessage(1)

Copied to clipboard