-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateapp
executable file
·137 lines (119 loc) · 4.84 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
#!/bin/bash
APP_STORE_DIRECTORY="apps"
CATEGORIES_FILE="etc/categories"
get_editor() {
app_name="$1"
creator_file="etc/editor"
if [ -e "$creator_file" ]; then
cat "$creator_file"
else
echo "xdg-open"
fi
}
select_category_pane() {
category_list=()
while read -r category; do
category_list+=("$category")
done < "$CATEGORIES_FILE"
selected_category=$(yad --title="Select Category" \
--text="Choose a category for the app:" \
--field="Category:" \
--width="400" --height="300" --center --on-top --borders=10 --columns=1 "${category_list[@]}" \
--list --column="Categories" )
if [ -z "$selected_category" ]; then
yad --error --title="Error" --text="Please select a category." --center --on-top --borders=10
return
fi
app_directory="$APP_STORE_DIRECTORY"
# Create or update the app files with the collected information
echo "${selected_category//|/}" >"$app_directory/category"
# Call the function to create the app with the selected category
create_new_app_pane
}
create_new_app_pane() {
app_data=$(yad --form \
--title="Create New App" \
--text="Enter the following details for the new app:" \
--field="App Name:" \
--field="Website:" \
--field="Creator:" \
--field="x64 (amd64):CHK" \
--field="x86 (i386/x86):CHK" \
--field="ARM 32-bit (armv7l):CHK" \
--field="ARM 64-bit (aarch64):CHK" \
--width="400" --center --on-top --borders=10 --separator="|")
# Extracting values from the form data
app_name=$(echo "$app_data" | awk -F '|' '{print $1}')
website=$(echo "$app_data" | awk -F '|' '{print $2}')
creator=$(echo "$app_data" | awk -F '|' '{print $3}')
install_x64=$(echo "$app_data" | awk -F '|' '{print $4}')
install_x86=$(echo "$app_data" | awk -F '|' '{print $5}')
install_32=$(echo "$app_data" | awk -F '|' '{print $6}')
install_64=$(echo "$app_data" | awk -F '|' '{print $7}')
# Create the app directory
app_directory="$APP_STORE_DIRECTORY/$app_name"
mkdir -p "$app_directory"
mv "$APP_STORE_DIRECTORY/category" "$app_directory/category"
# Create or update the app files with the collected information
echo "$website" >"$app_directory/website"
echo "$creator" >"$app_directory/creator"
# Open a separate dialog for description input
description=$(yad --form \
--title="Create New App - Description" \
--text="<b>Enter a description for the app:</b>" \
--field="<b>Description:</b>:TXT" \
--width="400" --height="200" --center --on-top --borders=10)
description=$(echo "$description" | awk -F '|' '{print $1}')
echo "$description" >"$app_directory/description"
# Generate and resize the icon
icon_file=$(yad --file-selection --title="Select Icon for App" --width="400" --center --on-top)
if [ -n "$icon_file" ]; then
cp "$icon_file" "$app_directory/icon-original.png"
convert "$icon_file" -resize 48x48 "$app_directory/icon-48.png"
convert "$icon_file" -resize 24x24 "$app_directory/icon-24.png"
convert "$icon_file" -resize 16x16 "$app_directory/icon-16.png"
fi
# Create or update the install scripts based on user preferences
if [ "$install_x64" == "TRUE" ] || [ "$install_x86" == "TRUE" ] || [ "$install_32" == "TRUE" ] || [ "$install_64" == "TRUE" ]; then
separate_scripts=$(yad --width="400" --height="200" \
--title="Install Scripts" \
--text="Do you want separate install scripts?" \
--button="All in one:0" \
--button="Separate:1" \
--center --on-top --borders=10)
if [ $? -eq 0 ]; then
gedit "$app_directory/install" &
else
if [ "$install_x64" == "TRUE" ]; then
gedit "$app_directory/install-x64" &
fi
if [ "$install_x86" == "TRUE" ]; then
gedit "$app_directory/install-x86" &
fi
if [ "$install_32" == "TRUE" ]; then
gedit "$app_directory/install-32" &
fi
if [ "$install_64" == "TRUE" ]; then
gedit "$app_directory/install-64" &
fi
fi
fi
# Create or update the uninstall script and open it in gedit
gedit "$app_directory/uninstall" &
}
import_zip_file() {
import_file=$(yad --file-selection --title="Select Zip File to Import" --width="400" --center --on-top)
if [ -z "$import_file" ]; then
yad --error --title="Error" --text="No file selected for import." --center --on-top --borders=10
return
fi
unzip "$import_file" -d "$APP_STORE_DIRECTORY"
}
if [ "$1" == "import" ]; then
import_zip_file
elif [ "$1" == "create" ]; then
select_category_pane
else
echo "Invalid argument. Please provide 'create' or 'import'."
exit 1
fi