Zenity command in Linux :

Ankita Ludbe
3 min readSep 22, 2021

--

What is zenity and why do we use it?

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.

In simple words Zenity enables you to create the various types of simple dialog.

How to install zenity ?

Zentity is by default installed or available in repository of most of the Standard Linux distribution of today. You can check if is installed onto your machine or not by executing following commands.

zenity — version

After checking the zenity is installed successfully , we can run the dialogs now :

Here are some of the dialogs in zenity,

1. info dialog : This dialog is used to show the information.

“ zenity — info”

2. Calendar dialog : This shows calendar.

“zenity —calendar”

3. Error dialog : This command will display error message with some text.

“zenity — error — title=’You are not allowed’ ”

4.Entry dialog :Dialog is used to take entry/input from the user.

“x=$(zenity — entry)”

This command will take input for user and store it in x :

The output we took into variable x will be displayed using echo :

“ echo $x”

5. Color-selection : By using this we can make user choose color from the palette,

“zenity — color-selection — show-palette”

6. List Dialog: To make zenity display this type of dialogue we use the --list option and define the columns and their contents,

“x=$(zenity — list — title=’Menu’ — column=’Name’ — column=’Price’ Pizza Rs.250 Burger Rs.100 waterbottle Rs.20)”

This command will take the selected item from the list we specified and store it in variable x.

7. Notification dialog : This dialog is used to display notification.

As we selected pizza from the list which was stored in x variable,now we will display this selected item in the form of notification.

“zenity — notification — text=$x”

8. Password dialog : Dialog will take password from the user.

The following command will take username and password from the user and store it a variable,

“x=$(zenity — password — username)”

The following command with show you all the dialogs associated with zenity,

“man zenity”

Thank You for reading…!!

--

--

Ankita Ludbe

I am just a learner who wants to learn new things and share the knowledge I have…..