Close Menu
  • Home
  • Android
  • Android Operating
  • Apple
  • Apps
  • Gadgets
  • Galaxy
  • Ipad
  • IPhone
  • Smartphone
  • Tablet

Subscribe to Updates

Subscribe to our newsletter and never miss our latest news

Subscribe my Newsletter for New Posts & tips Let's stay updated!

What's Hot

Muse Dash, Hyperforma, Tower of Fortune 4, etc.

March 28, 2025

Best Kitchen Gadgets of 2025

March 18, 2025

The best drawing tablets of 2025: Expert tested and recommended

February 13, 2025
Facebook X (Twitter) Instagram
  • Home
  • About Us
  • Advertise with Us
  • Contact us
  • DMCA Policy
  • Privacy Policy
  • Terms & Conditions
Facebook X (Twitter) Instagram
Wtf AndroidWtf Android
  • Home
  • Android
  • Android Operating
  • Apple
  • Apps
  • Gadgets
  • Galaxy
  • Ipad
  • IPhone
  • Smartphone
  • Tablet
Wtf AndroidWtf Android
Home ยป How to create a custom Linux app menu using Zenity
Apps

How to create a custom Linux app menu using Zenity

adminBy adminOctober 19, 2024No Comments4 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Share
Facebook Twitter LinkedIn Pinterest Email


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.

Zenity

(Image credit: Tom’s Hardware)

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

Zenity

(Image credit: Tom’s Hardware)

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.

  1. Open a terminal and first update the software repository list and then install zenity.
sudo apt update && sudo apt install zenity
  1. 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.
  2. Start your code by pointing it to the Bash interpreter.
#!/bin/bash
  1. Create a loop that repeats until the user closes the application.
while true; do
  1. 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)
  1. Add an if condition check Activates when the user exits the dialog.
    if [ $? -ne 0 ]; then
        break
    fi
  1. 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
  1. Close the main loop.
done
  1. Save the code as menu.sh in your home directory.
  2. 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
  1. 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.

  1. Press the Windows / Super key and search for “Startup apps”. Select “Startup Applications”.
  1. Click Add.
  1. 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.
  1. After you restart and log in, the app launcher will autorun and be ready for use.

Get the best Tom’s Hardware news and in-depth reviews delivered right to your inbox.



Source link

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
admin
  • Website

Related Posts

Muse Dash, Hyperforma, Tower of Fortune 4, etc.

March 28, 2025

New Android spyware warning – don’t install these apps

October 31, 2024

Google Apps Finally Adds Material 3 Bottom Bar to Android

October 31, 2024
Add A Comment
Leave A Reply Cancel Reply

Editors Picks

Will Google’s new anti-theft feature be a game-changer for Android users?

October 13, 2024

Huawei’s Android replacement HarmonyOS Next launches next week, permanently discontinuing Google’s operating system on existing devices

October 11, 2024

Android 15 lets you turn your phone into a useful smart home dashboard โ€“ here’s how

October 11, 2024

Google ordered to open Android app store to competition

October 10, 2024
Top Reviews
Wtf Android
Facebook X (Twitter) Instagram Pinterest Vimeo YouTube
  • Home
  • About Us
  • Advertise with Us
  • Contact us
  • DMCA Policy
  • Privacy Policy
  • Terms & Conditions
© 2025 wtfandroid. Designed by wtfandroid.

Type above and press Enter to search. Press Esc to cancel.