The man page says to make buttons with "name:exitcode" and I have done this, but $? is always 0. Also, for some reason the items I have checked don't show up in the variable either. Of course, it could be I have misunderstood how this is supposed to work. Here is the code I am working with that fails. It should return a list of plugins to enable/disable or to set keyboard shortcuts for, but it's not currently working because of the 2 problems listed above:configure_plugins()
{
local ifs="$IFS"
IFS=$'\n'
local pluginList="$(ls -1 ${xdgPath}/plugins-available/-.)"
if [ -n "$pluginList" ]; then
pluginList="${pluginList}"$'\n'
fi
pluginList="${pluginList}$(ls -1 /usr/share/SOPS/plugins/plugins-available/-.)"
local pluginName=""
declare -A local pluginPath
local checkList=""
local i=""
for i in $pluginList ; do
pluginName="$((basename "${i%-}") | sed 's/startnotify\|blockcall\|stopnotify//')"
pluginPath[$pluginName]="$i"
if ! ls -1 "${xdgPath}/plugins-enabled/${pluginPath[$pluginName]##/}" &> /dev/null ; then
checkList="${checkList}FALSE"$'\n'"${pluginName}"$'\n'"Disabled"$'\n'
else
checkList="${checkList}FALSE"$'\n'"${pluginName}"$'\n'"Enabled"$'\n'
fi
done
local items="$(yad --list --title "Simple Orca Plugin Manager" --text "Configure plugins:" --checklist --button "Toggle Selected Plugins:0" --button "Change Keyboard Shortcut:1" --button "Cancel:2" --separator $'\n' --column "" --column "Plugin" --column "Status" $checkList)"
if [ $? -eq 2 ]; then
exit 0
fi
if [ $? -eq 0 ]; then
for i in $items ; do
if ! ls -1 "${xdgPath}/plugins-enabled/${pluginPath[$i]##/}" &> /dev/null ; then
ln -s "${pluginPath[$i]}" "${xdgPath}/plugins-enabled/"
else
unlink "${xdgPath}/plugins-enabled/${pluginPath[$i]##/}"
fi
done
fi
if [ $? -eq 1 ]; then
for i in $items ; do
if ls -1 "${xdgPath}/plugins-enabled/${pluginPath[$i]##/}" &> /dev/null ; then
unlink "${xdgPath}/plugins-enabled/${pluginPath[$i]##/}"
fi
get_keyboard_shortcut fileName $i
mv "${xdgPath}/plugins-available/$i" "${xdgPath}/plugins-available/$fileName" || die "Could not make new shortcut."
done
fi
IFS="$ifs"
if [ -n "$items" ]; then
echo "Plugins updated! Restarting Orca..."
orca -r &
fi
}
Sorry if the code is poorly formated, sourceforges ticket system is very difficult to use with a screen reader lol.
you check the exit code of "local items=$(blah-blah)" operation, not the yad's one
Last edit: Victor Ananjevsky 2016-03-07