Display dialog box from linux script

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

I am using Ubuntu with Gnome. Is there any dialog command that can return if OK or Cancel was clicked? Or is there some other way to get this effect?

+4
source share
2 answers

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

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

As usual.

+8
source

zenity --question

+4
source

Source: https://habr.com/ru/post/1286519/


All Articles