[user-interface] How to make a GUI for bash scripts?

I want to make some graphical dialogs for my script but don't know how. I hear something about GTK-Server or something like that. If someone knows how to link Bash with tcl/tk I also be satisfied.

Please do not post something like "change to C++" because my project must be a script in Bash; there are no other options.

Any ideas?

EDIT: Thanks for answers but I don't want "graphics" as in colors in the console, but graphical windows which I can move, minimize etc. I will test xmessage, but I don't think that will be what I am searching for.

EDIT 2: I don't want make a simple dialog like yes/no, but some interface like progress bars and buttons, something like a game.

This question is related to user-interface bash gtk tcl tk

The answer is


You could use dialog that is ncurses based or whiptail that is slang based.

I think both have GTK or Tcl/Tk bindings.


You can gtk-server for this. Gtk-server is a program that runs in background and provides text-based interface to allow other programs (including bash scripts) to control it. It has examples for Bash (http://www.gtk-server.org/demo-ipc.bash.txt, http://www.gtk-server.org/demo-fifo.bash.txt)


there is a command called dialog which uses the ncurses library. "Dialog is a program that will let you to present a variety of questions or display messages using dialog boxes from a shell script. These types of dialog boxes are implemented (though not all are necessarily compiled into dialog)"

see http://pwet.fr/man/linux/commandes/dialog


Please, take a look at my library: http://sites.google.com/site/easybashgui

It is intended to handle, with the same commands set, indifferently all four big tools "kdialog", "Xdialog", "cdialog" and "zenity", depending if X is running or not, if D.E. is KDE or Gnome or other. There are 15 different functions ( among them there are two called "progress" and "adjust" )...

Bye :-)


If you have Qt/KDE installed, you can use kdialog, which pops up a Qt dialog window. You can easily specify to display a Yes/No dialog, OK/Cancel, simple text input, password input etc. You then have access to the return values from these dialogs at the shell.


If you want to write a graphical UI in bash, zenity is the way to go. This is what you can do with it:

Application Options:
  --calendar                                     Display calendar dialog
  --entry                                        Display text entry dialog
  --error                                        Display error dialog
  --info                                         Display info dialog
  --file-selection                               Display file selection dialog
  --list                                         Display list dialog
  --notification                                 Display notification
  --progress                                     Display progress indication dialog
  --question                                     Display question dialog
  --warning                                      Display warning dialog
  --scale                                        Display scale dialog
  --text-info                                    Display text information dialog

Combining these widgets you can create pretty usable GUIs. Of course, it's not as flexible as a toolkit integrated into a programming language, but in some cases it's really useful.


Well, if you can use Tcl/Tk in your environment, you probably should write a TCL script and use that. You might also look at wish.


Examples related to user-interface

Calling another method java GUI How do I center text vertically and horizontally in Flutter? Is it possible to put a ConstraintLayout inside a ScrollView? How to change color of the back arrow in the new material theme? How to create RecyclerView with multiple view type? Android RecyclerView addition & removal of items tkinter: how to use after method Presenting a UIAlertController properly on an iPad using iOS 8 Android ViewPager with bottom dots How do I get the height and width of the Android Navigation Bar programmatically?

Examples related to bash

Comparing a variable with a string python not working when redirecting from bash script Zipping a file in bash fails How do I prevent Conda from activating the base environment by default? Get first line of a shell command's output Fixing a systemd service 203/EXEC failure (no such file or directory) /bin/sh: apt-get: not found VSCode Change Default Terminal Run bash command on jenkins pipeline How to check if the docker engine and a docker container are running? How to switch Python versions in Terminal?

Examples related to gtk

How to make a GUI for bash scripts? How do you find out which version of GTK+ is installed on Ubuntu? How to show a GUI message box from a bash script in linux?

Examples related to tcl

Waiting for background processes to finish before exiting script How to make a GUI for bash scripts?

Examples related to tk

Background color for Tk in Python How to make a GUI for bash scripts?