Boost your zenity manual

Laxman Naik
4 min readOct 9, 2021

--

Hello everyone!πŸ™‹β€β™‚οΈπŸ™‹β€β™‚οΈπŸ™‹β€β™‚οΈ

In this blog, we will read about zenity command and it’s various tool

What is zenity?

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.

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.

[root@localhost ~]# zenity --version[root@localhost ~]# whereis zenity

If it’s not installed, you can install it using Yum command as shown below.

[root@localhost ~]# yum install zenity

There are various commands of zenity, few of them are listed below:

To read the complete manual of zenity, we use:

[root@localhost ~]# man zenity
output of <man zenity> command in linux terminal

Zenity basic dialog boxes

Some of the basic Dialogs of Zenity, which can be invoked directly from the command-line.

  1. How about a quick calendar dialog?
[root@localhost ~]# zenity --calendar

2. An error Dialog Box

[root@localhost ~]# zenity --error

3. A General text Entry Dialog Box

[root@localhost ~]# zenity --entry

4. An Information Dialog

[root@localhost ~]# zenity --info[root@localhost ~]# zenity --info --title="Welcome to my Blog" --text="How's your day"

5. A question Dialog box

[root@localhost ~]# zenity --question

6. A progress Bar

[root@localhost ~]# zenity --progress

7. Scale Dialog

[root@localhost ~]# zenity --scale

8. A Password Dialog

[root@localhost ~]# zenity --password

9. A Form Dialog box

[root@localhost ~]# zenity --forms

10. An about Dialog

[root@localhost ~]# zenity --about
commands in linux terminal
dialog boxes

Now we will discuss about displaying result of linux command inside zenity information dialog box. Although we can run these command directly inside the terminal see output there but how about creating dialog box which can display of output linux command inside it.

How about displaying current date and time inside dialog box.

[root@localhost ~]# zenity --info --text="$(date)" --title="Your current date and time is displayed below"

Now we will discuss about how to link two dialog boxes. How about an interactive dialog box which takes input from you, and shows the result. In this we linked two dialog boxes the detailed procedure is shown below:

  1. create a file containing below lines of code using any text editor like gedit/nano/vim.
#!/bin/bash 
first=$(zenity --title="Your's First Name" --text "What is your first name?" --entry)
zenity --info --title="Welcome" --text="Mr./Ms. $first"
last=$(zenity --title="Your's Last Name" --text "$first what is your last name?" --entry)
zenity --info --title="Nice Meeting You" --text="Mr./Ms. $first $last"
file containing codes

2. Save manually it to any name with .sh extension like in this case it is saved to name.sh

3. Then make it executable, set the permission 775 on it.

[root@localhost ~]# chmod 775 name.sh

4. Run the file.

[root@localhost ~]# sh name.sh
Enter First Name
welcome dialog
Enter Your Last Name
Welcome Message

This is how we can create interactive dialog boxes. For more information on how to create custom dialog boxes, visit at following reference page Zenity.

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

One can directly ask for help regarding zenity by typing the following command in terminal:

[root@localhost ~]# zenity --help

Thank you…..

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response