zenity Cheat Sheet

MD MOQADDAS
7 min readSep 24, 2021

--

Hello, We are going to expose the zenity command and make a pattern in such a way in your mind that can help you to write zenity commands.

Summary -:

→ Introduction to zenity

→ How to write zenity command

→ Deep dive into zenity

→ Demo

Body

Introduction to zenity -:

zenity is software, we know but the main part is it will display dialog box using shell script in command-line.

the dialog box looks like

let’s understand how using shell script in command line

see the below image where we write the command on bash shell it executing some program to pop-up the message.

Before using we know it is software so first, we have to install it.

yum install zenity

→ How to write zenity command:-

To write any command we use the below syntax

syntax:

zenity options

e.g-:

zenity --calendar

→ Deep dive into zenity -:

Let’s see its awesome options to solve real-world use-cases, we know every command gives the document like this zenity also have a doc.

there are two main options zenity have

  1. Help Options
  2. Application Options

Help Options -: If you want to learn any command this is the best way to learn the command.

Let’s take first help and see all the options of the zenity command

Help Options

Application Options -: Total application options here

Help Options and Application Options are not two different topics, let’s directly going to solve real-world problems using zenity then it makes more clarity how its works.

  1. zenity --calendar: It is used to see the calendar command output in the dialog box.

Now it's time to see the help option of zenity --calendar.

in yellow color to special help of application options.

Here two helps for each Application options,

  1. --help-general”: in this case, you will get these options for any Application options

2. “--help-calendar”: in this case you will get all the help regarding a particular Application option like in this case helps of calendar.

That’s solved now you are able to make any type of command in zenity worlds, now we are going to directly jumpy to the practicals.

Demos -:)

  1. --calendar:

zenity --calendar --title=Calendar --width=400

--height=200

2. --entry:

It is used to display the text on the console which is entered into the dialog box.

Real World Use Caes: It is very helpful if we want to take passwords separately we can use this option in apps

1st image
2nd image
3rd

3. --error:

You can show an error kind of notification using the “--error” option

By default --error option

4. --info:

Used to see an information dialog

by default --info

Let’s see the help for --info

5. --file-selection:

It is used to select the file

When you run the program it pop up files to select
All the options for --file-selection
Select multiple files
To select the directory
To create pop to save the file

6. --list:

It is used to create list also have lots of way to make a dynamic list

1st image
2nd image
3rd image
output of above command

7. --notification:

this kind of notification pop up

8. --progress:

Display progress indication dialog

By default progress command

9. --question:

Display question dialog

default

Total option for zenity --question

Command
Out put

10. --warning:

Display warning dialog.

11. --scale:

Display Scale Dialog

Default scale
Set the initial option using the above tool
Set initial value with min and max value
Minimum Value
Maximum Value
--print-partial option prints the value on the console
hide the value of scale

12. --text-info:

Display text information dialog

Special help of --text-info

reading file from “a.txt”

12. --color-selection:

Display color selection dialog

By default --color-selection
Extra Options in --color-selection

13. --password:

Display password dialog

Be default password dialog

14. --forms:

Display forms dialog

By default, it’s look like

This kind of form we can create

Conclusion :-

Zenity is an interesting program we can use in a program to make it more interactable and mature, it also helps to take inputs in different forms like password, form, list, error, notification, and lots more

Thanks

MD MOQADDAS

--

--

MD MOQADDAS
MD MOQADDAS

No responses yet