Creating graphics and presentations on the Linux CLI

In this article, we are going to learn how to make presentations and how to create graphics on the CLI. For this, we are going to use a tool named dialog.dialog is a Linux command-line tool used for taking input from users and to create message boxes.

Prerequisites

Besides having a terminal open, make sure you have the dialog utility installed on your system. Install it by using the apt command. APT stands for Advanced Package Tool. Using the apt command, you can manage software from the command line for debian-based Linux. The apt command easily interacts with the dpkg packaging system.

How to do it

We are going to write a script for a Yes/No box. In that script, we are going to use the if condition. Create the yes_no.sh script and add the following content to it:

dialog --yesno "Do you wish to continue?" 0 0 
a=$? 
if [ "${a}" == "0" ]; then 
	echo Yes 
else 
	echo No 
fi

We’ll use dialog’s calendar. Create a calendar_dialog.sh script. In that, we’ll select a specific date:

dialog --calendar "Select a date... " 0 0 1 1 2018 
val=$?

We’re going to use the checklist option of dialog. Create a checklist_dialog.sh script. In that, we’ll select multiple options:

dialog --stdout --checklist "Enable the account options you want:" 10 40 3 \ 
	1 "Home directory" on \ 
	2 "Signature file" off \ 
	3 "Simple password" off

Now, we are going to write a script to raise the border of an image. Create a raise_border.sh script. We’ll use the convert command with the raise option:

convert -raise 5x5 mountain.png mountain-raised.png

How it works

Now we will see a description of the options and commands written in the preceding scripts:

  • We wrote code for a Yes/No box using the dialog tool in Linux. We used the if condition to take an answer of either Yes or No.
  • We used the --calendar option of the dialog tool. It asks for a date to be selected. We selected a date from the year 2018.
  • We used the checklist option of the dialog tool. We made a checklist, which had three options: Home directory, Signature file, and Simple Password.
  • We raised the border of an image using the convert command and the –raise option, and then the new image was saved as mountain-raised.png.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Related Articles