Parcourir la source

Better implementation of selecting all apps

Bob Mottram il y a 8 ans
Parent
révision
5edcf011f4
1 fichiers modifiés avec 11 ajouts et 29 suppressions
  1. 11
    29
      src/freedombone-addremove

+ 11
- 29
src/freedombone-addremove Voir le fichier

56
 done
56
 done
57
 
57
 
58
 function show_apps {
58
 function show_apps {
59
+    select_all_apps=$1
59
     applist=""
60
     applist=""
60
     n=1
61
     n=1
61
     app_index=0
62
     app_index=0
62
     for a in "${APPS_AVAILABLE[@]}"
63
     for a in "${APPS_AVAILABLE[@]}"
63
     do
64
     do
64
-        if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
65
+        if [[ ${APPS_INSTALLED[$app_index]} == "0" &&  "$select_all_apps" != "add-all" ]]; then
65
             applist="$applist $n $a off"
66
             applist="$applist $n $a off"
66
         else
67
         else
67
             applist="$applist $n $a on"
68
             applist="$applist $n $a on"
130
 }
131
 }
131
 
132
 
132
 function install_apps_selected {
133
 function install_apps_selected {
133
-    select_all_apps=$1
134
     # which apps need to be installed?
134
     # which apps need to be installed?
135
     installs=""
135
     installs=""
136
     app_index=0
136
     app_index=0
137
     n=0
137
     n=0
138
-
139
-    if [ ! $select_all_apps ]; then
140
-        for a in "${APPS_INSTALLED[@]}"
141
-        do
142
-            if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
143
-                if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
144
-                    if [ ${n} -gt 0 ]; then
145
-                        installs="$installs ${APPS_AVAILABLE[$app_index]}"
146
-                    else
147
-                        installs="${APPS_AVAILABLE[$app_index]}"
148
-                    fi
149
-                    n=$[n+1]
150
-                fi
151
-            fi
152
-            app_index=$[app_index+1]
153
-        done
154
-    fi
155
-
156
-    if [[ $select_all_apps == "add-all" ]]; then
157
-        for a in "${APPS_INSTALLED[@]}"
158
-        do
159
-            if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
138
+    for a in "${APPS_INSTALLED[@]}"
139
+    do
140
+        if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
141
+            if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
160
                 if [ ${n} -gt 0 ]; then
142
                 if [ ${n} -gt 0 ]; then
161
                     installs="$installs ${APPS_AVAILABLE[$app_index]}"
143
                     installs="$installs ${APPS_AVAILABLE[$app_index]}"
162
                 else
144
                 else
164
                 fi
146
                 fi
165
                 n=$[n+1]
147
                 n=$[n+1]
166
             fi
148
             fi
167
-            APPS_CHOSEN[$app_index]="1"
168
-            app_index=$[app_index+1]
169
-        done
170
-    fi
149
+        fi
150
+        app_index=$[app_index+1]
151
+    done
171
 
152
 
172
     # if no apps to be installed then don't do anything
153
     # if no apps to be installed then don't do anything
173
     if [ ${n} -eq 0 ]; then
154
     if [ ${n} -eq 0 ]; then
206
     exit 1
187
     exit 1
207
 fi
188
 fi
208
 
189
 
209
-show_apps
190
+show_apps $1
210
 
191
 
211
 clear
192
 clear
212
 
193
 
213
 remove_apps_selected
194
 remove_apps_selected
195
+
214
 if [[ $1 == "add-all" ]]; then
196
 if [[ $1 == "add-all" ]]; then
215
     install_apps_selected add-all
197
     install_apps_selected add-all
216
 else
198
 else