Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
August 7, 2020 04:01 am GMT

Building GUI for your shell script using zenity

Sometimes the shell scripts that you write asks questions to the user so that they could change the some default value. We usually do this as text input. But for values like date, file path etc.. it would be nice if you show a calendar or a file picker.

There is a really nice command called zenity. Which allows you to build simple GUI for your shell script. Making your shell script more user friendly.

Let's say you want user to select a date you can do

$ zenity --calendar

and it will return you selected date as string

Alt Text

and for a file selection you can simply do

$ zenity --file-selection

When your shell scripts finishes you can notify the user using

$ zenity --notification --text "script completed"

zenity can do much more and it is has been out there for a while and it is available for most Linux distributions and even for other OS like Mac and Windows (but you may need to install them separately)

Edit: You can look for more details about all the options that zenity provides by runinng

$ man zenity

Original Link: https://dev.to/rafi993/building-gui-for-your-shell-script-using-zenity-1jmh

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To