Creating a GUI (graphical user interface) on any operating system looks like this: Ncurses / whip tail Enter the GUI for the terminal or the full-fledged GUI on your desktop. Build the latter, but use Terminal to run commands. Zenitya tool that displays GTK dialog boxes from terminal and shell scripts, is a great tool and very easy to use.
In this how-to, you’ll create a simple application launcher using a Bash script. Selecting an application triggers a terminal command to open the application. Leave the app launcher ready to run other applications.
Zenity is a great tool for creating GUI applications via the terminal, and Zenity projects include full manual About how to use it.
This project requires a computer running a Linux operating system. I chose Ubuntu 24.04, but it will also work with Debian, Fedora, and many other Linux distributions. CrunchbangPlusPlus When tested on Linux, Zenity worked as expected.
Create a custom application launcher
The first step is to create a custom application launcher. To do this, use a text editor and write the following: Bash shell script. Bash is a great programming language to learn and expand what you can do with your operating system.
- Open a terminal and first update the software repository list and then install zenity.
sudo apt update && sudo apt install zenity
- Open a text editor and write your code. I’m using Geany here, but feel free to use any text editor you like. Ubuntu 24.04 uses the Gnome “text editor” by default, but you can also install Microsoft’s Visual Studio Code editor.
- Start your code by pointing it to the Bash interpreter.
#!/bin/bash
- Create a loop that repeats until the user closes the application.
while true; do
- Create a list of applications in the Zenity app. The application window must have a title (app menu) and be formatted into columns. Add as many application names as needed. Height and width can be adjusted later to suit your requirements
CHOICE=$(zenity --list --title="App menu" \
--column="Apps" \
"Chrome" \
"Geany" \
"Thonny" \
"Inkscape" \
"GIMP" \
--height=400 --width=300)
- Add an if condition check Activates when the user exits the dialog.
if [ $? -ne 0 ]; then
break
fi
- Create a case statement (Used to simplify long conditions) Stored in the CHOICE variable as a long list for checking user input. If your selection matches an entry in the list, the corresponding command is launched. If there are no matches (unlikely, but I use this just in case), you’ll see an error message.
case $CHOICE in
"Chrome")
google-chrome &
;;
"Geany")
geany &
;;
"Thonny")
thonny &
;;
"Inkscape")
inkscape &
;;
"GIMP")
gimp &
;;
*)
zenity --error --text="Invalid option, please try again."
;;
esac
- Close the main loop.
done
- Save the code as menu.sh in your home directory.
- Open a terminal window and set the file as executable. It can also be made executable via a file manager. Right-click >> “Properties” and set permissions to “Executable as a program”.
chmod +x menu.sh
- Test that it works by running the code in the terminal.
./menu.sh
complete code list
#!/bin/bash
while true; do
CHOICE=$(zenity --list --title="App menu" \
--column="Apps" \
"Chrome" \
"Geany" \
"Thonny" \
"Inkscape" \
"GIMP" \
--height=400 --width=300)
if [ $? -ne 0 ]; then
break
fi
case $CHOICE in
"Chrome")
google-chrome &
;;
"Geany")
geany &
;;
"Thonny")
thonny &
;;
"Inkscape")
inkscape &
;;
"GIMP")
gimp &
;;
*)
zenity --error --text="Invalid option, please try again."
;;
esac
done
Run code when Ubuntu boots
The code is written, but you have to start it manually when you need it. However, you can configure the menu to launch when the desktop loads. All you need to do is tell the OS where to find the file.
- Press the Windows / Super key and search for “Startup apps”. Select “Startup Applications”.
- Click Add.
- Set the application name to App Launcher and specify the location of menu.sh (your home directory) in the command. Add comments to specify the behavior of the command. Click Add and save.
- After you restart and log in, the app launcher will autorun and be ready for use.