summaryrefslogtreecommitdiff
path: root/graphical_prompt.sh
blob: 6b82104c58ce7b61b746b8e4b5276df4b93d30ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

help_message() {
	echo "Usage: $0 COMMAND [PROMPT_TEXT]"
	echo "Example: $0 \"shutdown now\" \"Log Off and Shutdown?\""
	exit
}

case $1 in
	"" | "-h" | "--help" ) help_message;;
esac

PROMPT=$2
if [ -z $2 ]; then
	PROMPT="Are you sure?"
fi
echo $PROMPT
zenity --question --text="$PROMPT"
RES=$?

# 0 -> YES
# 1 -> NO

if [ $RES -eq 0 ]; then
	eval $1
fi