Swap tabs for spaces, fix listitems creation

listitems creation was not taking into account app names with spaces, ie Google Chrome would be cut off into Google.
This commit is contained in:
Adam Codega
2022-02-28 18:38:10 -05:00
parent 682f1334e6
commit ea27f9b609

View File

@@ -28,24 +28,24 @@ dialog_command_file="/var/tmp/dialog.log"
# check we are running as root # check we are running as root
if [[ $(id -u) -ne 0 ]]; then if [[ $(id -u) -ne 0 ]]; then
echo "This script should be run as root" echo "This script should be run as root"
exit 1 exit 1
fi fi
# *** functions # *** functions
# execute a dialog command # execute a dialog command
function dialog_command(){ function dialog_command(){
echo "$1" echo "$1"
echo "$1" >> $dialog_command_file echo "$1" >> $dialog_command_file
} }
function finalise(){ function finalise(){
dialog_command "progresstext: Install of applications complete" dialog_command "progresstext: Install of applications complete"
dialog_command "progress: complete" dialog_command "progress: complete"
dialog_command "button1text: Done" dialog_command "button1text: Done"
dialog_command "button1: enable" dialog_command "button1: enable"
exit 0 exit 0
} }
function appCheck(){ function appCheck(){
@@ -66,11 +66,11 @@ echo "at item number $progress_index"
progress_total=${#apps[@]} progress_total=${#apps[@]}
# set icon based on whether computer is a desktop or laptop # set icon based on whether computer is a desktop or laptop
hwType=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book") hwType=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book")
if [ "$hwType" != "" ]; then if [ "$hwType" != "" ]; then
icon="SF=laptopcomputer.and.arrow.down,weight=thin,colour1=#51a3ef,colour2=#5154ef" icon="SF=laptopcomputer.and.arrow.down,weight=thin,colour1=#51a3ef,colour2=#5154ef"
else else
icon="SF=desktopcomputer.and.arrow.down,weight=thin,colour1=#51a3ef,colour2=#5154ef" icon="SF=desktopcomputer.and.arrow.down,weight=thin,colour1=#51a3ef,colour2=#5154ef"
fi fi
dialogCMD="$dialogApp -p --title \"$title\" \ dialogCMD="$dialogApp -p --title \"$title\" \
@@ -83,7 +83,7 @@ dialogCMD="$dialogApp -p --title \"$title\" \
# create the list of apps # create the list of apps
listitems="" listitems=""
for app in "${apps[@]}"; do for app in "${apps[@]}"; do
listitems="$listitems --listitem \"$(echo "$app" | cut -d ',' -f1)\"" listitems="$listitems --listitem '$(echo "$app" | cut -d ',' -f1)'"
done done
# final command to execute # final command to execute
@@ -98,9 +98,9 @@ sleep 2
progress_index=0 progress_index=0
(for app in "${apps[@]}"; do (for app in "${apps[@]}"; do
step_progress=$(( 1 + progress_index )) step_progress=$(( 1 + progress_index ))
dialog_command "progress: $step_progress" dialog_command "progress: $step_progress"
appCheck & appCheck &
done done
wait) wait)