settings: use bash array args to close #849

pull/880/head
Botspot 3 years ago
parent fa64b37b4d
commit 416d55b975

@ -28,10 +28,9 @@ if [ "$1" == 'refresh' ];then
done done
IFS="$PREIFS" IFS="$PREIFS"
exit 0 exit 0
fi
elif [ "$1" == 'revert' ];then #If $1 equals 'revert', then overwrite all settings with the defaults and then the script will exit.
#$1 is usually left blank. If it equals 'revert', then overwrite all settings with the defaults and then the script will exit.
if [ "$1" == 'revert' ];then
#overwrite all settings with the defaults #overwrite all settings with the defaults
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')" settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS" PREIFS="$IFS"
@ -61,8 +60,8 @@ exitloop=''
while [ -z $exitloop ];do while [ -z $exitloop ];do
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')" settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
yadparams='' yadparams=()
tooltips='' tooltips=()
PREIFS="$IFS" PREIFS="$IFS"
IFS='|' IFS='|'
for name in $settings for name in $settings
@ -88,25 +87,17 @@ $(echo "$params" | grep -vx "$curval")"
#echo "Params of ${name}: ${params}" #echo "Params of ${name}: ${params}"
#echo "Tooltip of ${name}: ${tooltip}" #echo "Tooltip of ${name}: ${tooltip}"
yadparams="${yadparams} yadparams+=(--field=:CB "${params}")
--field=:CB tooltips+=(--field="${name}":!!"${tooltip}":BTN '')
${params}"
tooltips="${tooltips}
--field=${name}:!!${tooltip}:BTN
''"
done done
IFS="$PREIFS" IFS="$PREIFS"
#replace all space ' ' characters with a special kind of space: a punctuation space (). This way, bash won't split the strings into separate words.
yadparams="$(echo "$yadparams" | sed 's/ //g')"
tooltips="$(echo "$tooltips" | sed 's/ //g')"
output="$(yad --center --title='Pi-Apps Settings' --width=310 --height=300 \ output="$(yad --center --title='Pi-Apps Settings' --width=310 --height=300 \
--form --separator='\n' --window-icon="${DIRECTORY}/icons/logo.png" --columns=2 \ --form --separator='\n' --window-icon="${DIRECTORY}/icons/logo.png" --columns=2 \
$tooltips \ "${tooltips[@]}" \
--field='Categories...'!"${DIRECTORY}/icons/categories.png":FBTN "bash -c '${DIRECTORY}/etc/categoryedit &>/dev/null'" \ --field='Categories...'!"${DIRECTORY}/icons/categories.png":FBTN "bash -c '${DIRECTORY}/etc/categoryedit &>/dev/null'" \
--field='Log files...'!"${DIRECTORY}/icons/log-file.png":FBTN "bash -c '${DIRECTORY}/etc/logviewer &>/dev/null'" \ --field='Log files...'!"${DIRECTORY}/icons/log-file.png":FBTN "bash -c '${DIRECTORY}/etc/logviewer &>/dev/null'" \
$yadparams \ "${yadparams[@]}" \
--field='New App...'!"${DIRECTORY}/icons/create.png":FBTN "bash -c '${DIRECTORY}/createapp &>/dev/null'" \ --field='New App...'!"${DIRECTORY}/icons/create.png":FBTN "bash -c '${DIRECTORY}/createapp &>/dev/null'" \
--button='Reset'!"${DIRECTORY}/icons/backup.png"!'Reset all settings to their defaults':2 \ --button='Reset'!"${DIRECTORY}/icons/backup.png"!'Reset all settings to their defaults':2 \
--button=Cancel!"${DIRECTORY}/icons/exit.png":1 \ --button=Cancel!"${DIRECTORY}/icons/exit.png":1 \

Loading…
Cancel
Save