-
Notifications
You must be signed in to change notification settings - Fork 205
/
createapp
executable file
·539 lines (459 loc) · 24.9 KB
/
createapp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
#!/bin/bash
DIRECTORY="$(readlink -f "$(dirname "$0")")"
function error {
echo -e "\e[91m$1\e[39m"
exit 1
}
source "${DIRECTORY}/api" || error "failed to source ${DIRECTORY}/api"
#Use 'settings' window icon on all windows of this script
yadflags=(--class Pi-Apps-Settings --name "Pi-Apps Settings" --center --window-icon="${DIRECTORY}/icons/settings.png" --title="Pi-Apps" --separator='\n')
#you can specify a pre-existing app with variable 1
if [ ! -z "$1" ];then
name="$1"
step=2
editing=yes
else
name=''
step=0
fi
#start on this step:
#step=2
#start with this app name:
#name='myapp'
#start with this app type:
#app_type=package
#ensure imagemagick is installed
if ! command -v convert >/dev/null ;then
yad "${yadflags[@]}" --text="To resize the images, imagemagick must be installed."$'\n'"Install now?" \
--text-align=center --title='Quick question' \
--button=No!"${DIRECTORY}/icons/exit.png":1 --button=Yes!"${DIRECTORY}/icons/check.png":0
button=$?
if [ $button == 0 ];then
sudo apt install -y --no-install-recommends imagemagick || icon=''
else
exit 0
fi
fi
while true;do
#set the app_type: the type of app we're working with. allowed values: 'standard', 'package'
if [ -z "$name" ];then
app_type=''
elif [ -z "$app_type" ];then
if [ "$(app_type "$name")" == standard ];then
app_type=standard
elif [ "$(app_type "$name")" == package ];then
app_type=package
else
app_type=''
fi
fi
echo -e "\nName: $name\napp_type: $app_type\nStep: $step"
case $step in
0) #Introduction
echo "Welcome to the Create App wizard!
With a few simple steps, your project can take advantage of Pi-Apps' features and be displayed in the app-list.
This wizard will save your work as you go." | yad "${yadflags[@]}" --text-info --fontname=12 --wrap --show-uri \
--image="${DIRECTORY}/icons/in-progress.png" --image-on-top \
--text="<a href="\""https://github.com/Botspot/pi-apps/wiki/Creating-an-app"\"">READ THIS TUTORIAL FIRST!!</a>" \
--title="Create App Wizard" --width=310 --height=300 \
--button=Cancel!"${DIRECTORY}/icons/exit.png":1 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 || exit 0
step=$((step+1))
;;
1) #Choose name of app and its app-type
fields=() #this array contains the yad window options
if [ -z "$name" ];then
#if name variable is empty, make the field editable
fields+=(--field="Name of app:" "$name")
else
#if name variable is set, make the field read-only
fields+=(--field="Name of app: <b>$name</b>":RO '')
fi
#if the app_type has not already been determined, make it an option
if [ -z "$app_type" ];then
fields+=(--field="App type:":CB 'standard - Use scripts to install the app!package - Will install apt package(s)')
elif [ "$app_type" == package ];then
fields+=(--field="App type: <b>package</b>":RO '')
elif [ "$app_type" == standard ];then
fields+=(--field="App type: <b>standard</b>":RO '')
else
error "Unknown app type: '$app_type'"
fi
output="$(yad "${yadflags[@]}" --form \
--title="Create App: Step $step" --width=310 --height=300 --separator='\n' \
--text="Step ${step}: The basics" \
"${fields[@]}" \
--button=Previous!"${DIRECTORY}/icons/back.png":2 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 \
2>/dev/null)"
button=$? #get exit code to determine which button was pressed
echo "$button"
echo "Output: ${output}EOO"
if [ "$button" == 0 ];then
#Next clicked
#fill in variables based on yad output
[ -z "$name" ] && name="$(echo "$output" | sed -n 1p)"
[ -z "$app_type" ] && app_type="$(echo "$output" | sed -n 2p | awk '{print $1}')"
if [ -z "$name" ];then
echo 'Name of app may not be left blank!'
yad "${yadflags[@]}" --title="Error" \
--text="Name of app may not be left blank!" --timeout=10 \
--button=OK:0
elif [ -d "${DIRECTORY}/apps/${name}" ] && [ "$app_type" != "$(app_type "$name")" ];then
#allow switching from package-app to script-app by rewmoving files of old type
if [ "$app_type" == standard ];then
echo -e "$name was a package-app, but user wants it to be a standard app.\nRemoving 'packages' file..."
rm -f "${DIRECTORY}/apps/${name}/packages"
elif [ "$app_type" == package ];then
echo -e "$name was a standard app, but user wants it to be a package app.\nMoving scripts to Trash..."
gio trash "${DIRECTORY}/apps/${name}/install" 2>/dev/null
gio trash "${DIRECTORY}/apps/${name}/install-32" 2>/dev/null
gio trash "${DIRECTORY}/apps/${name}/install-64" 2>/dev/null
gio trash "${DIRECTORY}/apps/${name}/uninstall" 2>/dev/null
fi
step=$((step+1))
else
#name field populated
step=$((step+1))
#create app folder
mkdir -p "${DIRECTORY}/apps/${name}" || error "failed to create app folder: ${DIRECTORY}/apps/${name}!"
fi
elif [ "$button" == 2 ];then
#previous - don't save changes
step=$((step-1))
else
#like clicking the X or something
exit 0
fi
echo "at the end of step 1, the step value is $step"
;;
2) #Fill in information about the pre-chosen app name
[ -z "$name" ] && error "name variable must be filled for step $step."
[ ! -d "${DIRECTORY}/apps/${name}" ] && error "The $name app-folder must exist for step $step."
[ -z "$app_type" ] && error "app_type variable must be filled for step $step."
fields=() #this array contains the yad window options
#if app_type is 'standard', add the website field, icon field, and script-compatibility field
if [ "$app_type" == standard ];then
#make icon field read-only if the icon exists
if [ -f "${DIRECTORY}/apps/${name}/icon-64.png" ];then
fields+=("--field=Icon::RO" "apps/${name}/icon-64.png")
else
#point yad to a nonexistent directory so it opens the file browser to the $HOME directory
fields+=("--field=Icon::FL" "${HOME}/keiucheuchkoec")
fi
fields+=(--field="Website:" "$(cat "${DIRECTORY}/apps/${name}/website" 2>/dev/null)")
#if chosen app already has scripts, set cpu architecture compatibility and grey it out, otherwise make it choosable.
if [ -z "$(script_name "$name")" ];then
#no scripts found for the app - make it a choice
fields+=("--field=Compatibility::CB" "64bit and 32bit!32bit only!64bit only")
elif [ "$(script_name "$name")" == 'install' ] || [ "$(script_name "$name")" == 'install-32 install-64' ];then
#Either 'install' or 'install-32 install-64' scripts found.
fields+=("--field=Compatibility::RO" "64bit and 32bit")
elif [ "$(script_name "$name")" == 'install-32' ];then
#if only install-32 script found
fields+=("--field=Compatibility::RO" "32bit only")
elif [ "$(script_name "$name")" == 'install-64' ];then
#if only install-64 script found
fields+=("--field=Compatibility::RO" "64bit only")
fi
#if app_type is 'package', add the packages field
elif [ "$app_type" == package ];then
if [ -s "${DIRECTORY}/apps/${name}/packages" ];then
fields+=("--field=Package(s) to install:" "$(cat "${DIRECTORY}/apps/${name}/packages")")
else
#point yad to a nonexistent directory so it opens the file browser to the $HOME directory
fields+=("--field=Package(s) to install:" '')
fi
fields+=(--field="Website:" "$(cat "${DIRECTORY}/apps/${name}/website" 2>/dev/null)")
fi
output="$(yad "${yadflags[@]}" --form --separator='\n' \
--title="Create App: Step $step" --width=310 --height=600 \
--text="Step ${step}: Fill in information about <b>$name</b>." \
"${fields[@]}" \
--field="Description:":TXT "$(cat "${DIRECTORY}/apps/${name}/description" 2>/dev/null || cat "${DIRECTORY}/apps/template/description")" \
--field="Credits:":TXT "$(cat "${DIRECTORY}/apps/${name}/credits" 2>/dev/null || cat "${DIRECTORY}/apps/template/credits")" \
$([ ! -z $editing ] && echo "--button=Save!${DIRECTORY}/icons/save.png:4") \
--button=Previous!"${DIRECTORY}/icons/back.png":2 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 \
2>/dev/null)"
button=$? #get exit code to determine which button was pressed
echo "$button"
echo "Output: ${output}EOO"
if [ $button == 2 ];then
#previous - don't save changes
step=$((step-1))
# if -------- next -- or -------- save ----- was clicked
elif [ $button == 0 ] || [ $button == 4 ];then
#fill out information fields
if [ "$app_type" == package ];then
packages="$(echo "$output" | sed -n '1p')"
website="$(echo "$output" | sed -n '2p')"
description="$(echo -e "$(echo "$output" | sed -n '3p')")"
credits="$(echo -e "$(echo "$output" | sed -n '4p')")"
echo -e "packages=$packages\ndescription=$description\ncredits=$credits"
#try to get a program icon based on the package names given
if [ ! -f "${DIRECTORY}/apps/${name}/icon-64.png" ];then
icon="$(get_icon_from_package $packages)"
echo "got this icon: $icon"
if [ -z "$icon" ];then
icon="$(yad "${yadflags[@]}" --form --title="Icon for $name" --width=310 --height=400 \
--text="Please choose an icon for the $name app:" "--field=:FL" "${HOME}/keiucheuchkoec" \
--button=OK)"
else
#resize the detected icon to be displayed in the confiromation window
tmp_png="$(mktemp -u).png"
convert "$icon" -resize 64x64 "$tmp_png"
icon="$(yad "${yadflags[@]}" --form --title="Icon for $name" --separator='\n' --width=310 --height=400 \
--image="$tmp_png" --image-on-top \
--text="Pi-Apps found an icon from the <b>$(echo "$packages" | awk '{print $1}')</b> package."$'\n'"You can use a different one if you wish." \
"--field=:FL" "$icon" \
--button=OK:0)"
fi
fi
#Skip the script-creation steps
step=$((step+3))
else #app_type is standard
icon="$(echo "$output" | sed -n '1p')"
website="$(echo "$output" | sed -n '2p')"
compatibility="$(echo "$output" | sed -n '3p')"
description="$(echo -e "$(echo "$output" | sed -n '4p')")"
credits="$(echo -e "$(echo "$output" | sed -n '5p')")"
echo -e "icon=$icon\nwebsite=$website\ncompatibility=$compatibility\ndescription=$description\ncredits=$credits"
#translate the compatibility variable from human-readable to machine-readable
if [ -z "$(script_name "$name")" ];then
#if app contains no install scripts, then parse yad output
#convert compatibility var into machine-readable
if [ "$compatibility" == "64bit and 32bit" ];then
compatibility='install-32 install-64'
elif [ "$compatibility" == "64bit and 32bit" ];then
compatibility='install'
elif [ "$compatibility" == "32bit only" ];then
compatibility='install-32'
elif [ "$compatibility" == "64bit only" ];then
compatibility='install-64'
fi
else #app contains install scripts, so ignore yad window's setting (it was greyed out anyway) and set compatibility to whatever it was already.
compatibility="$(script_name "$name")"
fi
#This is an app; proceed to script-creation step
step=$((step+1))
fi
#if icon variable is populated and if file exists
if [ ! -z "$icon" ] && [ -f "$icon" ];then
generate_app_icons "$icon" "$name"
echo "Generated icons from $icon"
fi
#if packages field is populated
if [ ! -z "$packages" ];then
echo "$packages" > "${DIRECTORY}/apps/${name}/packages"
echo "Created ${DIRECTORY}/apps/${name}/packages"
fi
#if website field is populated
if [ ! -z "$website" ] && [ "$website" != "$(cat "${DIRECTORY}/apps/template/website")" ];then
echo "$website" > "${DIRECTORY}/apps/${name}/website"
echo "Created ${DIRECTORY}/apps/${name}/website"
fi
#if description field is populated
if [ ! -z "$description" ] && [ "$description" != "$(cat "${DIRECTORY}/apps/template/description")" ];then
echo "$description" > "${DIRECTORY}/apps/${name}/description"
echo "Created ${DIRECTORY}/apps/${name}/description"
fi
#if credits field is populated
if [ ! -z "$credits" ] && [ "$credits" != "$(cat "${DIRECTORY}/apps/template/credits")" ];then
echo "$credits" > "${DIRECTORY}/apps/${name}/credits"
echo "Created ${DIRECTORY}/apps/${name}/credits"
elif [ -z "$credits" ] && [ -f "${DIRECTORY}/apps/${name}/credits" ] ;then
#clear credits if the user wanted them cleared.
echo '' > "${DIRECTORY}/apps/${name}/credits"
fi
#if Save was clicked then exit now
if [ $button == 4 ];then
exit 0
fi
else
#like clicking the X or something
exit 0
fi
;;
3) #Create install script
#ask if two install scripts are necessary, of if both architectures can share 1 script
if [ "$compatibility" == "install-32 install-64" ] && [ -z "$(script_name "$name")" ];then
echo "In the previous page, you said this app is compatible with 64bit and 32bit.
Do you want two install scripts, one for 32bit and the other for 64bit?
Or do you want one combined install script?" | yad "${yadflags[@]}" --text-info --fontname=12 --wrap --show-uri \
--title="Install script" --width=310 --height=400 \
--button="Previous!${DIRECTORY}/icons/back.png":1 \
--button='2 scripts':2 \
--button='1 script':0
button=$? #get exit code to determine which button was pressed
if [ $button == 1 ];then
#button clicked: Previous
step=$((step-1))
continue #back to top of while loop
elif [ ! $button == 0 ] && [ ! $button == 2 ];then
#Window manager X, or escape, or terminated
exit 0
elif [ $button == 0 ];then
#button clicked: '1 script'
compatibility=install #change compatibility var from 'install-32 install-64' to 'install', to show that only an install script will be created
elif [ $button == 2 ];then
#button clicked: '2 scripts'
true #do nothing, as $compatibility already contains "install-32 install-64"
fi
fi #end of asking for 1 script or 2 scripts
#copy right files from template, based on $compatibility variable
if [ "$compatibility" == "install-32" ];then
cp -n "${DIRECTORY}/apps/template/install" "${DIRECTORY}/apps/${name}/install-32"
elif [ "$compatibility" == "install-64" ];then
cp -n "${DIRECTORY}/apps/template/install" "${DIRECTORY}/apps/${name}/install-64"
elif [ "$compatibility" == "install" ];then
cp -n "${DIRECTORY}/apps/template/install" "${DIRECTORY}/apps/${name}/install"
elif [ "$compatibility" == "install-32 install-64" ];then
cp -n "${DIRECTORY}/apps/template/install" "${DIRECTORY}/apps/${name}/install-32"
cp -n "${DIRECTORY}/apps/template/install" "${DIRECTORY}/apps/${name}/install-64"
fi
#open the correct file in text editor
if [ "$compatibility" == "install-32" ];then
text_editor "${DIRECTORY}/apps/${name}/install-32" &
elif [ "$compatibility" == "install-64" ];then
text_editor "${DIRECTORY}/apps/${name}/install-64" &
elif [ "$compatibility" == "install-32 install-64" ];then
text_editor "${DIRECTORY}/apps/${name}/install-64" &
text_editor "${DIRECTORY}/apps/${name}/install-32" &
elif [ "$compatibility" == "install" ];then
text_editor "${DIRECTORY}/apps/${name}/install" &
fi
#install shellcheck if not installed
command -v shellcheck >/dev/null || sudo apt install -y shellcheck
#if creating 2 scripts
if [ "$compatibility" == 'install-32 install-64' ];then
yad "${yadflags[@]}" --form --on-top \
--title="Install scripts" --width=310 --height=400 \
--text="Now it's time to make your install-32 and install-64 scripts.
One of these scripts will be executed when somebody clicks your app's Install button.
Two text editors should have opened and you can create your scripts.
Need help? <a href="\""https://github.com/Botspot/pi-apps/wiki/Creating-an-app"\"">Read the tutorial!</a>
Still need help? Botspot can try to help you if you <a href="\""https://github.com/Botspot/pi-apps/issues/new/choose"\"">open in issue.</a>" \
--field="Run install-32 script":FBTN "${DIRECTORY}/etc/terminal-run "\""cd $HOME ; DIRECTORY='$DIRECTORY' ; set -a ; source '${DIRECTORY}/api' ; app='$name' ; '${DIRECTORY}/apps/${name}/install-32' | cat ; echo 'Press Enter to exit.';read enter"\"" "\""Running install-32 script of $name"\""" \
--field="Shellcheck install-32"!!'Having problems? This utility helps you locate syntax errors.':FBTN "${DIRECTORY}/etc/terminal-run "\""shellcheck $'${DIRECTORY}/apps/${name}/install-32';echo 'Press Enter to exit.';read enter"\"" "\""Shellcheck"\""" \
--field="Run install-64 script":FBTN "${DIRECTORY}/etc/terminal-run "\""cd $HOME ; DIRECTORY='$DIRECTORY' ; set -a ; source '${DIRECTORY}/api' ; app='$name' ; '${DIRECTORY}/apps/${name}/install-64' | cat ; echo 'Press Enter to exit.';read enter"\"" "\""Running install-64 script of $name"\""" \
--field="Shellcheck install-64"!!'Having problems? This utility locates syntax errors.':FBTN "${DIRECTORY}/etc/terminal-run "\""shellcheck $'${DIRECTORY}/apps/${name}/install-64';echo 'Press Enter to exit.';read enter"\"" "\""Shellcheck"\""" \
--button=Previous!"${DIRECTORY}/icons/back.png":2 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 \
2>/dev/null
button=$? #get exit code to determine which button was pressed
else #if creating 1 script
yad "${yadflags[@]}" --form --on-top \
--title="Install script" --width=310 --height=400 \
--text="Now it's time to make your ${compatibility} script. This will be executed anytime somebody clicks the Install button.
A text editor should have opened and you can create your install script.
Need help? <a href="\""https://github.com/Botspot/pi-apps/wiki/Creating-an-app"\"">Read the tutorial!</a>
Still need help? Botspot can try to help you if you <a href="\""https://github.com/Botspot/pi-apps/issues/new/choose"\"">open in issue.</a>" \
--field="Run ${compatibility} script":FBTN "${DIRECTORY}/etc/terminal-run "\""cd $HOME ; DIRECTORY='$DIRECTORY' ; set -a ; source '${DIRECTORY}/api' ; app='$name' ; '${DIRECTORY}/apps/${name}/${compatibility}' | cat ; echo 'Press Enter to exit.';read enter"\"" "\""Running ${compatibility} script of $name"\""" \
--field="Shellcheck ${compatibility}"!!'Having problems? This utility locates syntax errors.':FBTN "${DIRECTORY}/etc/terminal-run "\""shellcheck $'${DIRECTORY}/apps/${name}/${compatibility}';echo 'Press Enter to exit.';read enter"\"" "\""Shellcheck"\""" \
--button=Previous!"${DIRECTORY}/icons/back.png":2 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 \
2>/dev/null
button=$? #get exit code to determine which button was pressed
fi
if [ $button == 0 ];then
#next
step=$((step+1))
elif [ $button == 2 ];then
#previous
step=$((step-1))
else
#like clicking the X or something
exit 0
fi
;;
4) #Create uninstall script
cp -n "${DIRECTORY}/apps/template/uninstall" "${DIRECTORY}/apps/${name}/uninstall"
text_editor "${DIRECTORY}/apps/${name}/uninstall" &
#install shellcheck if not installed
command -v shellcheck >/dev/null || sudo apt install -y shellcheck
output="$(yad "${yadflags[@]}" --form --on-top \
--title="Uninstall script" --width=310 --height=400 \
--text="Now it's time to make your uninstall script. This will be executed anytime somebody clicks the Uninstall button.
A text editor should have opened... Never mind, you know what to do." \
--field="Run uninstall script":FBTN "${DIRECTORY}/etc/terminal-run "\""cd $HOME ; DIRECTORY='$DIRECTORY' ; set -a ; source '${DIRECTORY}/api' ; app='$name' ; $'${DIRECTORY}/apps/${name}/uninstall' | cat ; echo 'Press Enter to exit.';read enter"\"" "\""Running uninstall script of $name"\""" \
--field="Shellcheck uninstall"!!'Having problems? This utility helps you locate syntax errors.':FBTN "${DIRECTORY}/etc/terminal-run "\""shellcheck $'${DIRECTORY}/apps/${name}/uninstall';echo 'Press Enter to exit.';read enter"\"" "\""Shellcheck"\""" \
--button=Previous!"${DIRECTORY}/icons/back.png":2 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 \
2>/dev/null)"
button=$? #get exit code to determine which button was pressed
if [ $button == 0 ];then
#next
step=$((step+1))
elif [ $button == 2 ];then
#previous
step=$((step-1))
else
#like clicking the X or something
exit 0
fi
;;
5) #Verify in app list
LIST="${DIRECTORY}/apps/${name}/icon-24.png
$name
"\("uninstalled"\)" $(echo "$(cat "${DIRECTORY}/apps/${name}/description" 2>/dev/null || echo "Description unavailable")" | head -n1)"
echo -e "$LIST" | yad "${yadflags[@]}" --list \
--title="List view" --width=310 --height=400 \
--text="Make sure everything looks right.
Here's what it will look like in the app list:" \
--column=:IMG --column=Name --column=tip:HD --tooltip-column=4 --no-headers \
--button=Previous!"${DIRECTORY}/icons/back.png":2 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 \
2>/dev/null
button=$? #get exit code to determine which button was pressed
if [ $button == 0 ];then
step=$((step+1))
elif [ $button == 2 ];then
#go back - if the app is a package, then skip script-creation steps
if [ "$app_type" == standard ];then
step=$((step-1))
elif [ "$app_type" == package ];then
step=$((step-3))
fi
else
#like clicking the X or something
exit 0
fi
;;
6) #Verify in Details window
cat "${DIRECTORY}/apps/${name}/description" 2>/dev/null | yad "${yadflags[@]}" --text-info --fontname=12 --wrap --show-uri \
--text="Make sure everything looks right.
Here's a preview of the Details window:
- Current status: $(echo "$(app_status "$name")" | sed 's/corrupted/corrupted (installation failed)/g' | sed 's/disabled/disabled (installation is prevented on your system)/g')
- Website: <a href="\""$(cat "${DIRECTORY}/apps/${name}/website" 2>/dev/null | head -n1)"\"">$(cat "${DIRECTORY}/apps/${name}/website" 2>/dev/null | head -n1)</a>" \
--title="Details window" --width=700 --height=400 \
--image="${DIRECTORY}/apps/${name}/icon-64.png" --image-on-top \
--button=Previous!"${DIRECTORY}/icons/back.png":2 \
--button=Next!"${DIRECTORY}/icons/forward.png":0 \
2>/dev/null
button=$? #get exit code to determine which button was pressed
if [ $button == 0 ];then
step=$((step+1))
elif [ $button == 2 ];then
step=$((step-1))
else
#like clicking the X or something
exit 0
fi
;;
7) #All done
echo "Your app is located at ${DIRECTORY}/apps/${name}
To add your app to the Pi-Apps official repository, put that folder in a .ZIP file and open an issue on the Pi-Apps repository: https://github.com/Botspot/pi-apps/issues/new/choose" | yad "${yadflags[@]}" --text-info \
--text="Done!" \
--fontname=12 --wrap --show-uri \
--image="${DIRECTORY}/icons/in-progress.png" --image-on-top \
--title="Create App Wizard" --width=310 --height=400 \
--button=Previous!"${DIRECTORY}/icons/back.png":0 \
--button=Close!"${DIRECTORY}/icons/exit.png":1 || exit 0
step=$((step-1))
;;
*)
error "Unknown step ${step}!"
;;
esac
done