Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display dialog box from linux script

I have a cron entry that runs a script at a certain time each day. The script sets the DISPLAY to :0 and launches a program for the user to run (this is a single-user desktop). I want to change this so that the user first sees a dialog box so he can indicate whether he wants to run the program.

I'm using Ubuntu with Gnome. Is there some kind of dialog box command that can return whether OK or Cancel was clicked? Or is there some other way to get this effect?

like image 969
Jeremy Stein Avatar asked Dec 17 '22 07:12

Jeremy Stein


2 Answers

You could use Zenity. It allows you to use GTK dialogs, and I think the yes/no ones just store their value in $?. You can use:

if zenity --question --text="Are you sure?"; then
    sudo rm -rf / # kidding!
fi

Just like usual.

like image 67
Lucas Jones Avatar answered Dec 28 '22 06:12

Lucas Jones


zenity --question

like image 36
cube Avatar answered Dec 28 '22 07:12

cube