Hazem Allbabidi

March 28, 2023 | 5 min read

Blue Screen Menus in Linux

The Linux operating system has to be one of my favorite tools to study and work on. I got the opportunity recently to work on a tool that displays text boxes, menus, input boxes, and more in a GUI-based or even Terminal-based Linux.

This tool is called Dialog. It is basically a tool that covers the full screen of a terminal (or the full screen if it was a terminal-based OS) showing only the data to be displayed inside the dialog box.

Today, I will be showing you how to install and use this tool on an Ubuntu 20.04 System and how you can utilize it to improve the experience of a user who is not very familiar with using a terminal.

Installing The Tool

You can install the tool by using the apt package manager on Ubuntu:

sudo apt install dialog

Structure of The Command

dialog --title "Trying Out Dialog" --infobox "This is cool" 10 20

This are multiple parts in the above command, these parts are explained below:

The image below shows the result of running the command explained above: Dialog Infobox

Many More Options

As explained above, the command can take many more options for the type of dialog being displayed, the most common ones include:


Working With Menus

For the sake of this tutorial, I will focus on building a menu using Dialog and how you can display items, as well as run functions or commands based on the choice made on the dialog by the user.

This project will have a menu that asks the user whether they prefer eating waffles or pancakes, and run a function based on the choice made.

We can start off by creating a file that will run all of this. Create a file called waffles_vs_pancakes.sh.

touch waffles_vs_pancakes.sh

Then run the below command to give it read, write, and execute permissions:

chmod 0777 waffles_vs_pancakes.sh

Now we can start editing the file, you can use any code editor you prefer and start by typing the below:

dialog --menu  "Which do you prefer more?"  0  0  0  \
	"Waffles"  "Waffles are better"  \
	"Pancakes"  "Pancakes are better" 2> results.txt

Command explained:

Once the above is done and ran, it should look like this: Dialog Menu

Next, we can start writing the logic for what happens after they make a choice:

case  `cat results.txt`  in
	Waffles) dialog --infobox "Waffles are better" 0 0;;
	Pancakes) dialog --infobox "Pancakes are better" 0 0;;

Command explained:

The result of this would display a dialog like the one below: Dialog Infobox 2

After completing the file, you can run it from the terminal by running the below command:



Thank you for reading this tutorial, I hope it benefited from it and gained some new knowledge. You can checkout the below links for more details on Dialog and how you can go further with it. https://github.com/tolik-punkoff/dialog-examples - Dialog Option Examples https://www.linuxjournal.com/article/2807 - An Introductory Tutorial https://linuxcommand.org/lc3_adv_dialog.php - More detailed documentation

Thanks again for reading and best of luck!


Proof-of-Work and Mining


My Linux From Scratch Experience
Sign Up To Binance To Get 10% Off Commission Fees Sign Up To Kucoin