home

Quickies, by Andrea Olivato

text

Zenity questions

Quick examples on how to launch Zenity questions from Bash and use the returned values.

#!/bin/bash

# Creates a Zenity question dialog, 
# similar to JS confirm().
# Put the answer code on a variable.

ANSWER=`zenity --question --text "Do you like me?"; echo $?`;

# Check what the user pressed
if [[ $ANSWER -eq 1 ]]
then
	# 1 => pressed cancel
	echo "No, you don't";
else
	# 0 => pressed ok
	echo "Oh yes, you do";
fi;

2 years ago

July 6, 2009
Comments (View)
blog comments powered by Disqus