8

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

How should I proceed?

1
  • short answer is zenity. Use man zenity for more information.
    – g_p
    Jun 27, 2015 at 8:17

1 Answer 1

19

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

3
  • 1
    Cannot resist upvoting this nice overview :) +1 Jun 27, 2015 at 9:31
  • +1 I like too kinda fun also ;)
    – JoKeR
    Jun 27, 2015 at 11:43
  • @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"! ;-)
    – A.B.
    Jun 27, 2015 at 19:10

Not the answer you're looking for? Browse other questions tagged .