How to show an message box from terminal in Ubuntu

11,161

Using zenity:

sudo lsof | tee >(zenity --progress --pulsate) > out

enter image description here


zenity --question --text "Are you sure you want to shutdown?"; echo $?

enter image description here


zenity --warning --text "This will kill, are you sure?";echo $?

enter image description here


ans=$(zenity --scale --text "pick a number" --min-value=2 --max-value=100 --value=2 --step 2); echo "$ans"

enter image description here


sudo lsof | zenity --text-info --width 530

enter image description here



Using yad

Install yad

sudo apt-add repository ppa:webupd8team/y-ppa-manager
sudo apt-get update
sudo apt-get install yad

Create a example script example and add the lines below

#!/bin/bash
frmdata=$(yad --title "Test Form" --form --field "Address" --field="Name")

frmaddr=$(echo "$frmdata" | awk 'BEGIN {FS="|" } { print $1 }')
frmname=$(echo "$frmdata" | awk 'BEGIN {FS="|" } { print $2 }')

echo "$frmaddr" 
echo "$frmname"

enter image description here


Or more complex:

yad --width=400 --title="" --text="Please enter your details:" \
--image="/usr/share/icons/Tango/scalable/emotes/face-smile.svg" \
--form --date-format="%-d %B %Y" --item-separator="," \
--field="Last name" \
--field="First name" \
--field="Date of birth":DT \
--field="Last holiday":CBE \
"" "" "Click calendar icon" "Gold Coast, Bali,Phuket, Sydney, other"

enter image description here


Using notify-send

notify-send "Hello" "Hello world"

enter image description here

Using dialog

dialog --msgbox "Hello world" 10 30

enter image description here


Using whiptail

whiptail --msgbox "Hello world" 10 30

enter image description here

Share:
11,161

Related videos on Youtube

Eskils
Author by

Eskils

Recycle! This is the only planet with Swift.

Updated on September 18, 2022

Comments

  • Eskils
    Eskils almost 2 years

    I want to show an message box from terminal in Ubuntu, I have GNOME 3 desktop environment.

    How should I proceed?

    • g_p
      g_p about 9 years
      short answer is zenity. Use man zenity for more information.
  • JoKeR
    JoKeR about 9 years
    +1 I like too kinda fun also ;)
  • A.B.
    A.B. about 9 years
    @WhiteStone As you're a reputation 1 user: If this answer helped you, don't forget to click the grey at the left of this text, which means "yes, this answer is valid"! ;-)