Exploring Zenity Command

M G GOVARDHAN GOWDA
4 min readSep 25, 2021

Zenity is a rewrite of gdialog, the GNOME port of dialog which allows you to display dialog boxes from the command line and shell scripts.

https://help.gnome.org/users/zenity/

1️⃣ What is Zenity?

👉 Zenity is an open-source and cross-platform application that displays GTK+ Dialog Boxes in command-line and using shell scripts. It allows to ask and present information to/from the shell in Graphical Boxes. The application lets you create Graphical dialog boxes in the command line and makes the interaction between user and shell very easy.

2️⃣ How do we come to know zenity is installed or not 🤔...?

zenity --version

Let's start Exploring Zenity commands

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

1.) About zenity

zenity --about

Output:-

2.) Man zenity

man zenity command gives us complete information about zenity commands including commands.

output:-

man zenity

3.)Zenity calendar

displays calendar dialog

zenity --calendar

Output:-

4.) Zenity entry

Displays the entry dialog

zenity --entry

Output:-

The text entered in the dialog box gets printed in the terminal

5.) Zenity error

Displays the error dialog

zenity --error

Output:-

5.1) We can edit the text to be displayed on the dialog box

zenity --error --title "ARTH_2.0" --text "Task_1.1"

Output:-

6.) Zenity File selection

Displays the file selection dialog

zenity --file-selection

Output:-

6.1) If any file selected

It displays the the location of the selected file.

Output:-

7.) Zenity info

Displays the info dialog

zenity --info

Output:-

7.1) We can edit the text to be displayed on the dialog box

zenity --info --title "ARTH_2.0" --text "Task_1.1"

Output:-

7.2) Date command on the info dialog box

The present date gets displayed on the dialog box

zenity --info --title "ARTH_2.0" --text "Todays date is $(date)"

Output:-

8.) Zenity List

Displays the list dialog

zenity --list

Output:-

Note:-There is no output because, list needs data to be entered in column. If there is no data then no list.

let us try with our PG data 🤩

zenity --list \--title='Shivani PG' \--column='SL.no' --column='Name'  --column='Room No' --column='Phone No' \1 Govardhan_M_G 305 8197307618 \2 Hithesh_Kumar_N 305 9108228731 \3 Dileep_Kumar_S_R 302 9110619797 \4 Chethan 302 9449036429\

Output:-

9.) Zenity Warning

Displays the warning dialog

zenity --warning

Output:-

10.) Zenity Scale

Displays the scale dialog

zenity --scale

Output:-

11.) Zenity Color Selection

Displays the Selected Color dialog

zenity --color-selection

Output:-

11.1) Zenity Color palette display

Displays the Selected Color on the palette dialog

zenity --color-selection --show-palette

Output:-

12.) Zenity with other commands

Takes the command as input from the entry dialog and displays the output of the command in the info dialog box

zenity --info --text "$($(zenity --entry))"

Output:-

--

--

M G GOVARDHAN GOWDA

MLOPS internship trainee @LinuxWorld informatics Pvt. LTD. || Student @Dayananda Sagar University |