Ubuntu – How to edit YAD question labels (example)

scriptsyadzenity

YAD is a Zenity fork.

I have this yad script:

#!/bin/bash

yad --text="Execute the file? (press 'Cancel' to open in text editor)" 

case $? in
    0)thunar "$1"
    ;;
    1)gedit $1
    ;;
esac

Associated with a desktop file as application launcher, it can be used to display a window when clicking a file (e.g. a script, etc).

enter image description here

In zenity, the name of the labels can be edited:

The same script with Zenity should look like so:

#!/bin/bash

zenity --question --text="What to do?" \
       --ok-label=Run \
       --cancel-label=Edit

case $? in
    0)thunar "$1"
    ;;
    1)gedit $1
    ;;
esac

And Run and Edit can be changed.

I think that here it says that yad has means to edit the labels:

–button=BUTTON:ID

Add the dialog button. May be used multiply times. ID is an exit code or a command. BUTTON may be gtk stock item name for predefined

buttons (like gtk-close or gtk-ok) or text in a form
LABEL[!ICON[!TOOLTIP]] where `!' is an item separator. Full list of
stock items may be found in gtk-demo program, in snippet called "Stock
Items and Icon Browser". If no buttons specified OK and Cancel buttons
used. See Exit Status section for more. If ID have a non-numeric value
it treats like a command and click on such button doesn't close the
dialog.

But I'm not sure. And I don't know what to make of that info. I need an example on how the buttons of my yad script above may have their names changed.

I have reasons to use yad instead of zenity – the zenity script cannot me dismissed with close or Esc.

Best Answer

I am not totally sure what you mean, but if I understand it correctly you want something like this:

#!/bin/bash

yad --text="Execute the file?" --button="Execute" --button="Edit"

case $? in
    0)thunar "$1"
    ;;
    1)gedit $1
    ;;
esac

I found a link (ubuntuusers.de), but it is in German. There are a few code examples and pictures though, that might help. And you can always translate it with google.

I would have written this as a comment if I could, but I am not yet allowed to. Hope it helps.