-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme
executable file
·46 lines (38 loc) · 1.51 KB
/
theme
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
APP_STORE_DIRECTORY="apps"
CATEGORIES_FILE="etc/categories"
THEMES_DIRECTORY="/usr/share/themes"
THEMES_FILE="etc/theme"
show_theme_selection() {
themes=()
while IFS= read -r -d '' theme; do
# Extract just the name of the theme directory from its full path
theme_name=$(basename "$theme")
themes+=("$theme_name")
done < <(find "$THEMES_DIRECTORY" -maxdepth 1 -mindepth 1 -type d -print0 | sort -z)
theme_string=""
for theme in "${themes[@]}"; do
if [ -n "$theme_string" ]; then
theme_string+="!"
fi
theme_string+="$theme"
done
selected_theme=$(yad --title="Select Theme" \
--text="Choose a theme:" \
--width="400" --height="100" --center --on-top --borders=10 --form \
--field="Theme":CB "$theme_string")
echo "$selected_theme"
# Extract selected theme name from the dropdown result
selected_theme="${selected_theme//|/}"
if [ -z "$selected_theme" ]; then
yad --error --title="Error" --text="Please select a theme." --center --on-top --borders=10
return
fi
# Get the full path of the selected theme using 'find'
selected_theme_path=$(find "$THEMES_DIRECTORY" -maxdepth 1 -mindepth 1 -type d -name "$selected_theme" -exec basename {} \; -quit)
if [ -n "$selected_theme_path" ]; then
echo "$selected_theme_path" > "$THEMES_FILE"
else
yad --error --title="Error" --text="Selected theme not found." --center --on-top --borders=10
fi
}
show_theme_selection