I'm using YAD to create a "app store" with a GUI and I can't find any tutorial on how to execute a command when I select an option from a list and click on the 'ok' button ('ok' will be replaced with 'install'). I want to use shell script only.
This is the script I wrote. It's a simple list with 2 columns and 2 items in them. The windows icon is just a test.
yad --list --center --width=800 --height=600
--title "apps4pi" \
--column "app name" --column "description" \
SimpleScreenRecorder " powerful feature packed yet simple and easy to use screen recorder" \
System-Tools "system maintenance commands all done for you"
The following code shows how to run some actions on a selected row:
The example command prints the columns of the row line by column in standard error device. "Exit and Install" button does the command by exiting
yad
and using its output. "Install" button gets the selection from a temporary file, so it does not have to wait for the output;--select-action
is used for updating that file. You can also run the action as double-click action on selection; you do not need a temporary file for that. Seeman yad
for more documentation about the options.As for the icon names I used for buttons, I selected them from among Standard Action Icons specified in the freedesktop.org's Icon Naming Specification.
If you want "installing" to happen only after
yad
has exited and exiting and installing happen when you choose "Install", useYou can change the column separator to what you like using the
--separator
option or use the default|
. Replace theprintf
line with your command.