Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show a GUI message box from a bash script in linux?

I'm writing a few little bash scripts under Ubuntu linux. I want to be able to run them from the GUI without needing a terminal window to enter any input or view any output.

So far the only input required is a password for sudo - and gksudo handles that fine. But I haven't found an easy way to show a message box yet. Is there some kind of 'gkmessage' command available? I'd prefer something present in a default Ubuntu install, but I don't mind installing a new package if necessary.

like image 328
Blorgbeard Avatar asked Aug 10 '08 04:08

Blorgbeard


People also ask

How do I show messages in Linux?

The echo command is one of the most basic and frequently used commands in Linux. The arguments passed to echo are printed to the standard output. echo is commonly used in shell scripts to display a message or output the results of other commands.

Does bash have a GUI?

In fact, you are able to include GUI (Graphical User Interface) based input/output components into your next bash script using the Zenity command line tool which helps us to display GTK dialog boxes.


2 Answers

If you are using Ubuntu many distros the notify-send command will throw one of those nice perishable notifications in the top right corner. Like so:

notify-send "My name is bash and I rock da house"

B.e.a.utiful!

like image 188
chmac Avatar answered Oct 08 '22 08:10

chmac


I believe Zenity will do what you want. It's specifically designed for displaying GTK dialogs from the command line, and it's available as an Ubuntu package.

like image 35
Derek Park Avatar answered Oct 08 '22 09:10

Derek Park