LinuxCommandLibrary

zenity

Display graphical dialog boxes from shell scripts

TLDR

Display the default question dialog

$ zenity --question
copy

Display an info dialog displaying the text "Hello!"
$ zenity --info --text="[Hello!]"
copy

Display a name/password form and output the data separated by ";"
$ zenity --forms --add-entry="[Name]" --add-password="[Password]" --separator="[;]"
copy

Display a file selection form in which the user can only select directories
$ zenity --file-selection --directory
copy

Display a progress bar which updates its message every second and show a progress percent
$ [(echo "#1"; sleep 1; echo "50"; echo "#2"; sleep 1; echo "100")] | zenity --progress
copy

SYNOPSIS

zenity [common-options] --info|--warning|--error|--question|--calendar|--entry|--file-selection|--list|--notification|--progress|--scale|--color-selection|--forms|--about

PARAMETERS

--help
    Display help and exit

--version
    Display version info

--title=TITLE
    Set dialog window title

--text=TEXT
    Set main dialog text

--width=WIDTH
    Set dialog width in pixels

--height=HEIGHT
    Set dialog height in pixels

--timeout=SECONDS
    Auto-close after seconds

--no-wrap
    Disable text wrapping

--error
    Display error dialog

--info
    Display info dialog

--warning
    Display warning dialog

--question
    Display yes/no question

--calendar
    Date selection calendar

--entry
    Single-line text entry

--password
    Password entry (masked)

--file-selection
    File or directory chooser

--list
    List, checklist, or radiolist

--notification
    Desktop notification

--progress
    Progress bar dialog

--scale
    Slider scale selector

--color-selection
    Color picker dialog

--forms
    Multi-field input forms

--about
    About application dialog

--window-icon=ICON
    Set window icon

--icon-name=ICON
    Set image icon name

--no-markup
    Disable Pango markup

DESCRIPTION

Zenity is a lightweight command-line tool that enables shell scripts to create and display graphical dialogs using the GTK+ toolkit. Ideal for adding user interaction to bash scripts, automation tasks, and system notifications without needing complex GUI development.

It supports a variety of dialog types, including informational messages (--info), warnings (--warning), errors (--error), yes/no questions (--question), date pickers (--calendar), text inputs (--entry or --password), file choosers (--file-selection), lists (--list), progress indicators (--progress), sliders (--scale), color pickers (--color-selection), forms (--forms), and notifications (--notification).

Common customizations include setting titles, text, dimensions, timeouts, and icons. Zenity integrates seamlessly with desktop environments like GNOME, handles internationalization via gettext, and respects system themes. Output can be captured for scripting logic, with exit codes signaling user choices (e.g., 0 for OK, 1 for Cancel).

Primarily used in Linux distributions for installers, backups, and user prompts, it's cross-compatible with GTK2 and GTK3 versions.

CAVEATS

Requires GTK+ and graphical display (X11/Wayland); fails silently in terminals. Some options dialog-specific. GTK3 version (zenity --version) may differ slightly from GTK2.

EXIT CODES

0: OK/Yes; 1: Cancel/No/Esc; -1: Timeout/Error

EXAMPLES

Info: zenity --info --title='Success' --text='Done'
File: FILE=$(zenity --file-selection)
Progress: (for i in {1..100}; do echo $i; sleep 0.1; done) | zenity --progress --auto-close

HISTORY

Introduced in 2002 with GNOME 2.0 as part of gnome-utils. Evolved to standalone package by GNOME 2.28 (2009). Supports GTK3 since 3.0 (2011); actively maintained for modern desktops.

SEE ALSO

dialog(1), yad(1), kdialog(1), notify-send(1)

Copied to clipboard