I want to make a zenity question that goes further depending on the answer you choose.

The question in my script is:

zenity --question --text="Would you like to participate in a little form?" 


Full script


if [ "$(whoami)" != "root" ]; then
  echo "Put this is /sbin/ and chmod 755 it."
    zenity --info --text="Hi! Welcome to !!Name yet to be found!!"
    sleep 0.5
    zenity --question --text="Would you like to participate in a little form?" 
    sleep 1
    zenity --info --text="Getting important run files"

    sleep 1
    zenity --info --text="Done!"
    sleep 1
    zenity --info --text="I will this program will move to /sbin/ and chmod 
775 it for you!
No need to thank me.
My program creator made me this way :(" 
    sudo chmod 755 ~/!!!
    mv ~/!!! /sbin/ 
    sleep 1
    zenity --info --text="Done!"
    sleep 2
    sudo xdg-open /sbin
    zenity --info --text="Well look for yourself!"
    sleep 10
    zenity --info --text="Dont rerun this file!"
    zenity --info --text="This is just the install part."

How can I achieve this?


zenity --question will return the user's answer in its exit code. You can collect it from the $? special variable, like so

zenity --question --text="Are you there?"

or use it directly in a conditional like this

if zenity --question --text="Do you want to answer stupid questions?"
    zenity --entry --text="Why?"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.