Zenity Command-- Linux
Atishay Jain
CSE'2024 | Cyber Security | C++ | Python | Salesforce Developer | web-Development | SQL | Git-hub | DSA
What is Zenity ?
Zenity is a program that will display GTK+ dialogs, and return the user's input. This allows you to present information, and ask for information from the user, from all manner of shell scripts.
The application lets you create Graphical dialog boxes in the command line and makes the interaction between user and shell very easy.
There are other alternatives, but nothing compares to the simplicity of Zenity, especially when you don’t need complex programming. Zenity, a tool you must have your hands on.
Read more at: https://www.commandlinux.com/man-page/man1/zenity.1.html
Zenity Features :--
1. FOSS Software
2. Cross Platform Application
3. Allow GTK+ Dialog Box Execution
4. Command Line Tool
5. Support in Shell Scripting
Basic 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.
When the user closes the dialog, Zenity prints the text produced by the dialog to standard output.
Functions we can use in Zenity :--
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. 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.
3. Entry :-
Syntax : [root@localhost ~]#zenity — entry
Entry dialogue box
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 me.
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!!!