Linux Commands Examples

A great documentation place for Linux commands


display GTK+ dialogs

see also : gdialog - dialog


zenity [options]

add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!


command=$(zenity --entry --text="Run a command")
exec `zenity --entry --text=''`&
zenity --info --text='Goodbye, World!'
zenity --error --text "Error: $1"
channel=`zenity --entry --text="What channel?"`
channel_changer $channel

Display a file selector with the title Select a file to remove. The file selected is returned on standard output.

zenity --title="Select a file to remove" --file-selection

Display a text entry dialog with the title Select Host and the text Select the host you would like to flood-ping. The entered text is returned on standard output.

zenity --title "Select Host" --entry --text "Select the host you would like to flood-ping"

Display a dialog, asking Microsoft Windows has been found! Would you like to remove it?. The return code will be 0 (true in shell) if OK is selected, and 1 (false) if Cancel is selected.

zenity --question --title "Alert" --text "Microsoft Windows has been found! Would you like to remove it?"

Show the search results in a list dialog with the title Search Results and the text Finding all header files....

find . -name ’*.h’ | zenity --list --title "Search Results" --text "Finding all header files.." --column "Files"

Show a notification in the message tray

zenity --notification --window-icon=update.png --text "System update necessary!"

Display a weekly shopping list in a check list dialog with Apples and Oranges pre selected

zenity --list --checklist --column "Buy" --column "Item" TRUE Apples TRUE Oranges FALSE Pears FALSE Toothpaste

Display a progress dialog while searching for all the postscript files in your home directory

find $HOME -name ’*.ps’ | zenity --progress --pulsate

djview "$(zenity --file-selection)"

Getting zenity and at to work properly

Check your /var/log/messages, chances are you'll have some "Cannot open display" errors from your X Server.

You need to provide utilities like at and cron access to your X Display by name. Edit your ~/.bashrc to include the following:

xhost local:USERNAME > /dev/null

Substitute your username for the USERNAME value above. This will provide the at utility with the name of your X Display so it can attempt to fork zenity on it.

Modify your zenity command to include the --display switch:

echo "zenity --info --display=:0.0" | at now + 1 min 

Can UDEV somehow trigger zenity for a logged in user in a session?

You already found the answer. The script (zenity) needs an X Window Server for displaying a message. The script is run from udev and has no display attached to it. You can solve this by hardwiring the DISPLAY variable in your script, i.e.


The drawback to this is, it works only, if you are the only user and/or know the display in advance. If there are multiple users on your system, the display might be anything else, for example :1, :2, and so on. Or another users gets the zenity message on his screen.

A better approach would be to split the detection of the event and the interaction with the user or display of the message.

For this you can create a script or program, which runs in your GUI session and listens for a trigger from a daemon or the udev trigger script.

A third possibility could be to connect to the udisks-daemon and ask for information, when the external device is plugged in. You can try udisks --monitor or udisks --monitor-detail for this and parse the output, whenever an event happens.

There seems to be a udisksctl command, which does the same with a slightly different syntax. Maybe it's just a newer version of the udisks command.

You can also look at some Gui tools like GNOME Disks, which rely on the udev/udisks system as well.


The multiple invocations usually arise from the report of the various subsystems. You can see that, when you log the environment to some log file in the /usr/local/bin/ script

umask 077
mkdir -p /tmp/udevtest.d
env >>/tmp/udevtest.d/udevtest.log

When I plugin a USB stick, I get the following reports

$ grep -e ACTION -e SUBSYSTEM /tmp/udevtest.d/udevtest.log

You can also add DEVTYPE to distinguish between the two usb or disk reports. So, in order to reduce the reports to just a few or even only one call, you must be more specific and add additional conditions to your udev rules file, for example choose the SUBSYSTEM=scsi_disk or whatever is appropriate for your device.


zenity is a program that will display GTK+ dialogs, and return (either in the return code, or on standard output) the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts.

For example, zenity --question will return either 0, 1 or 5, depending on whether the user pressed OK, Cancel or timeout has been reached. zenity --entry will output on standard output what the user typed into the text entry field.

Comprehensive documentation is available in the GNOME Help Browser, under GNOME/Utilities.


This program follows the usual GNU command line syntax, with long options starting with two dashes (’-’).

Dialog options

Display calendar dialog


Display text entry dialog


Display error dialog


Display file selection dialog


Display info dialog


Display list dialog


Display notification


Display progress indication dialog


Display question dialog


Display text information dialog


Display warning dialog


Display scale dialog


Display color selection dialog


Display password dialog


Display forms dialog

General options

Set the dialog title


Set the window icon with the path to an image. Alternatively, one of the four stock icons can be used: ’error’, ’info’, ’question’ or ’warning’


Set the dialog width


Set the dialog height


Set the dialog timeout in seconds

Calendar options

Set the dialog text


Set the calendar day


Set the calendar month


Set the calendar year


Set the format for the returned date. The default depends on the user locale or be set with the strftime style. For example %A %d/%m/%y

Text entry options

Set the dialog text


Set the entry text


Hide the entry text

Error options

Set the dialog text


Do not enable text wrapping


Do not enable pango markup

File selection options

Set the file or directory to be selected by default


Allow selection of multiple filenames in file selection dialog


Activate directory-only selection


Activate save mode


Specify separator character when returning multiple filenames


Confirm file selection if filename already exists

--file-filter=NAME | PATTERN1 PATTERN2

Sets a filename filter

Info options

Set the dialog text


Do not enable text wrapping


Do not enable pango markup

List options

Set the dialog text


Set the column header


Use check boxes for first column


Use radio buttons for first column


Set output separator character


Allow multiple rows to be selected


Allow changes to text


Specify what column to print to standard output. The default is to return the first column. ’ALL’ may be used to print all columns.


Hide a specific column


Hides the column headers

Notification options

Set the notification text


Listen for commands on stdin. Commands include ’message’, ’tooltip’, ’icon’, and ’visible’ separated by a colon. For example, ’message: Hello world’, ’visible: false’, or ’icon: /path/to/icon’. The icon command also accepts the four stock icon: ’error’, ’info’, ’question’, and ’warning’

Progress options

Set the dialog text


Set initial percentage


Close dialog when 100% has been reached


Kill parent process if cancel button is pressed


Pulsate progress bar


Hides the cancel button

Question options

Set the dialog text


Do not enable text wrapping


Do not enable pango markup


Set the text of the OK button


Set the text of the cancel button

Text options

Open file


Allow changes to text


Enable a checkbox for use like a ’I read and accept the terms.’


Set the text of the OK button


Set the text of the cancel button

Warning options

Set the dialog text


Do not enable text wrapping


Do not enable pango markup

Scale options

Set the dialog text


Set initial value


Set minimum value


Set maximum value


Set step size


Print partial values


Hide value

Color selection options

Set the initial color


Show the palette

Password dialog options

Display the username field

Forms dialog options

Add a new Entry in forms dialog


Add a new Password Entry in forms dialog


Add a new Calendar in forms dialog


Set the dialog text


Set output separator character


Set the format for the returned date. The default depends on the user locale or be set with the strftime style. For example %A %d/%m/%y

Miscellaneous options
-?, --help

Show summary of options.


Display an about dialog.


Show version of program.

Also the standard GTK+ options are accepted. For more information about the GTK+ options, execute following command.

zenity --help-gtk


Normally, zenity detects the terminal window from which it was launched and keeps itself above that window. This behavior can be disabled by unsetting the WINDOWID environment variable.

see also

gdialog , dialog


Zenity was written by Glynn Foster <glynn.foster[:at:]sun[:dot:]com>.

This manual page was written by Ross Burton <ross[:at:]burtonini[:dot:]com>.

How can this site be more helpful to YOU ?

give  feedback