-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings
More file actions
executable file
·155 lines (136 loc) · 5.79 KB
/
settings
File metadata and controls
executable file
·155 lines (136 loc) · 5.79 KB
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
#!/bin/bash
APP_STORE_DIRECTORY="apps"
CATEGORIES_FILE="etc/categories"
THEMES_DIRECTORY="/usr/share/themes"
THEMES_FILE="etc/theme"
show_settings() {
pkill -f "yad.*"
selectedtheme=$(cat "etc/theme" 2>/dev/null)
if [[ ! -f "etc/theme" ]]; then
./api error "etc/theme does not exist"
fi
#echo "$selectedtheme"
if [[ -z "$selectedtheme" || "$selectedtheme" == " " ]]; then
themes=("System Default")
else
themes=("${selectedtheme} (currently selected)!System Default")
fi
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
selectededitor=$(cat "etc/editor" 2>/dev/null | sed -r 's/ \(currently selected\)//g')
#echo "$selectededitor"
if [[ ! -f "./etc/editor" ]]; then
./api error "etc/editor does not exist"
fi
if [[ -z "$selectededitor" || "$selectededitor" == " " ]]; then
texteditors="System Default"
else
texteditors="${selectededitor} (currently selected)!System Default"
fi
texteditors+="!Visual Studio Code!Geany!Gedit!Mousepad!VSCodium"
accents=""
if [ -e "etc/accent" ]; then
ACCENT=$(cat etc/accent)
if [[ "$ACCENT" == "" ]]; then
accents+="Default!"
else
accents+="$ACCENT (currently selected)!"
accents+="Default!"
fi
else
accents+="Default!"
fi
accents+="red!orangered!orange!yellow!limegreen!green!teal!lightblue!blue!purple!pink!grey"
import_piapps_file=$(cat "etc/pi-apps-import" 2>/dev/null)
if [[ ! -f "./etc/pi-apps-import" ]]; then
./api error "etc/pi-apps-import does not exist"
fi
#echo "$selectededitor"
if [[ -z "$import_piapps_file" || "$import_piapps_file" == " " ]]; then
import_piapps="FALSE"
else
import_piapps="${import_piapps_file}"
fi
express_updates_file=$(cat "etc/express-updates" 2>/dev/null)
if [[ ! -f "./etc/express-updates" ]]; then
./api error "etc/express-updates does not exist"
fi
#echo "$selectededitor"
if [[ -z "$express_updates_file" || "$express_updates_file" == " " ]]; then
express_updates="FALSE"
else
express_updates="${express_updates_file}"
fi
# I don't know why these are around this way, and why they only work that way.
settings=$(yad --form \
--title="Settings" --columns=1 --output-by-row \
--width="300" --height="450" --center --borders=20 \
--field="<big><b>LinStore Settings</b></big>":LBL "" \
--field="<b>Theme</b>":CB "$theme_string" \
--field="<b>Text Editor</b>":CB "$texteditors" \
--field="<b>Accent Colour</b>":CB "$accents" \
--field="Show apps from Pi-Apps (if installed)":CHK "${import_piapps}" \
--field="Express Updates":CHK "${express_updates}" \
--field=":LBL" "" \
--field="<big><b>App Management</b></big>":LBL "" \
--field="<b>Create App</b>"!document-new!"Create an app for LinStore and Pi-Apps!":FBTN "./createapp create" \
--field="<b>Import App</b>"!document-open!"Import an app not available in the repository":FBTN "./createapp import" \
--field="<b>Multi-Install</b>"!"images/button/install.png"!"Install multiple applications at once":FBTN "./gui multi-install" \
--button="<b>OK</b>!gtk-ok":0 \
--button="<b>Cancel</b>!gtk-cancel":1)
# Extracting the selected text editor value from settings
yad_ret=$?
if [[ $yad_ret -eq 0 ]]; then
echo "$settings"
fixed_settings=$(echo "$settings" | sed -r 's/ \(currently selected\)//g')
echo "$fixed_settings"
selected_text_editor=$(echo "$fixed_settings" | awk -F '|' '{print $3}')
echo "$selected_text_editor"
# Echoing to the 'etc/editor' file based on the selected text editor
case "$selected_text_editor" in
"System Default") echo "xdg-open" >"etc/editor" ;;
"Visual Studio Code") echo "code" >"etc/editor" ;;
"Geany") echo "geany" >"etc/editor" ;;
"Gedit") echo "gedit" >"etc/editor" ;;
"Mousepad") echo "mousepad" >"etc/editor" ;;
"VSCodium") echo "codium" >"etc/editor" ;;
*) echo "$selected_text_editor" >"etc/editor" ;;
esac
selected_theme=$(echo "$fixed_settings" | awk -F '|' '{print $2}')
echo $selected_theme
if [[ "$selected_theme" == "System Default" ]]; then
echo "yes"
selected_theme_path=""
echo "$selected_theme_path" >"$THEMES_FILE"
else
selected_theme_path=$(find "$THEMES_DIRECTORY" -maxdepth 1 -mindepth 1 -type d -name "$selected_theme" -exec basename {} \; -quit)
echo "$selected_theme_path" >"$THEMES_FILE"
fi
accent_colour=$(echo "$fixed_settings" | awk -F '|' '{print $4}' | sed -r 's/ \(currently selected\)//g')
case "$accent_colour" in
"Default") echo "green" >"etc/accent" ;;
*) echo "$accent_colour" >"etc/accent" ;;
esac
import_from_piapps=$(echo "$fixed_settings" | awk -F '|' '{print $5}')
echo $import_from_piapps > "etc/pi-apps-import"
express_updates=$(echo "$fixed_settings" | awk -F '|' '{print $6}')
echo $express_updates > "etc/express-updates"
./gui
elif [[ $yad_ret -eq 252 ]]; then
./gui
elif [[ $yad_ret -eq 1 ]]; then
./gui
fi
}
show_settings > /dev/null
#show_settings