Linux — Zenity Command

Rishabh Arya
5 min readSep 23, 2021
Zenity command in Linux

What is Zenity?

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

There are other alternatives, but nothing compares to the simplicity of Zenity, specially when you don’t need complex programming. Zenity, a tool you must have your hands on.

Zenity Features

1. FOSS Software

2. Cross Platform Application

3. Allow GTK+ Dialog Box Execution

4. Command Line Tool

5. Support in Shell Scripting

Uses of Zenity

1. Easy GUI Creation

2. Less features than other complex Tools

3. Enables shell scripts to interact with a GUI users

4. Simple dialog creation is possible for graphical user interaction

Since Zenity is available for all known major platforms, and based on GTK+ library, Zenity program can be ported to/from another platform.

1. Calendar

Syntax : [root@localhost ~]#zenity — calendar

Here we simply can see the calendar displayed into a dialogue box. Here we can select the date we want and we get that date as output .

Under option calendar there are many other options. We can put our own text by using option — text=”TEXT” and also set particular day or month or year and display it by default using options

— day=INT_DATE , — month=INT_MONTH , — year=INT_YEAR

Here, we have given text input as CALENDAR and set date using above mentioned options as 3/4/2002 and that date is displayed by default in our calendar.

2. Entry

Syntax : [root@localhost ~]#zenity — entry

Entry dialogue box

3. Error

Syntax : [root@localhost ~]#zenity — error

Error dialogue box

We can also give title to this dialogue box and edit the text inside box as we did above.

4. File-selection

Syntax : [root@localhost ~]#zenity — file-selection

When we simply use only file-selection option, we can select one file at a time.

Here we can select only one file .

If we ant to select multiple files then we can use option ‘— multiple’ to choose many files at a time.

We can choose multiple files at a time.

Also if we want a file to be selected by default then we can give name of file in option — filename=FILENAME

We gave name of the file and that file is selected by default

5. Info

Syntax : [root@localhost ~]#zenity — info

This command option simply displays a dialogue box where we can display any text we want.

Here we can see that dialogue box is displayed

We can specify the text and title of this dialogue box as we did previously.

Specifying the message to be displayed
Adding title

6. List

Syntax : [root@localhost ~]#zenity — list column=COLUMN_NAME

We can display a list using list option and also first we have to make a column and give it name. Also we can display text using text option. Also we can pass the elements in list by specifying them into alternate way which is little difficult.

Creating one column
Creating two columns
Adding elements in column
Adding elements in two columns

Also we can give check boxes and radio-list the elements in list :

Check-list
Radio-list

7. Notification

Syntax : [root@localhost ~]#zenity — notification

We have to simply use notification option and add the text to be displayed in notification using text option.

We displayed notification “THIS IS A NOTIFICATION”

8. Progress

Syntax : [root@localhost ~]#zenity — progress

We can simply display a progress bar and some text above it using text option.

Progress bar with text

Also we can specify the percentage in progress bar using option

— percentage=INT

Progress bar with percentage

Also we can add the pulsation to progress bar using option , — pulsate

Progress bar with text and percentage and pulstation

9. Question

Syntax : [root@localhost ~]#zenity — question

We can simply ask any question to user and specify question using text option

Question

10. Warning

Syntax : [root@localhost ~]#zenity — warning

We can specify warning to be displayed with text option,

Warning

11. Scale

Syntax : [root@localhost ~]#zenity — scale

This option displays a scale bar where we can select a value,

Scale

Also,we can specify text using text option and also we can specify default value by option , — value=INT . Also, we can set minimum and maximum values to be selected using options , — minimum=INT , — maximum=INT respectively. Also we can specify the steps by which value can be increased or decreased.

Scale with min value 10
Scale with maximum range 90

12. Colour Selection

Syntax : [root@localhost ~]#zenity — colour-selection

We can select the colour we want using this option.

Colour-selection

13. Password

Syntax : [root@localhost ~]#zenity — password

This option simple collects our password,

Password

14. Forms

Syntax : [root@localhost ~]#zenity — forms

This option opens up a form in which we can specify text,

Form

To know more about zenity , use command man zenity .

Thank You!!!

--

--

Rishabh Arya

I am an active learner who likes to challenge every problem with a can-do mindset in order to make any idea a reality.