@@ -10,13 +10,14 @@ apply_theme() {
1010 Default
1111 )
1212
13+ if [[ ! -f ${APPLICATION_INI_FILE} ]]; then
14+ run_script ' config_create'
15+ fi
16+
1317 local ThemeFile DialogFile
14- local DefaultMenuIniFile =" ${THEME_FOLDER } /${MENU_INI_NAME } "
18+ local DefaultIniFile =" ${DEFAULTS_FOLDER } /${APPLICATION_INI_NAME } "
1519 if [[ -z ${ThemeName-} ]]; then
16- if [[ ! -f ${MENU_INI_FILE} ]]; then
17- cp " ${DefaultMenuIniFile} " " ${MENU_INI_FILE} "
18- fi
19- ThemeName=" $( run_script ' config_get' Theme " ${MENU_INI_FILE} " ) "
20+ ThemeName=" $( run_script ' config_get' Theme) "
2021 if ! run_script ' theme_exists' " ${ThemeName} " ; then
2122 for Name in " ${DefaultThemes[@]} " ; do
2223 if run_script ' theme_exists' " ${Name} " ; then
@@ -95,37 +96,39 @@ apply_theme() {
9596 local DialogOptions=" --colors --output-fd 1 --cr-wrap --no-collapse"
9697
9798 local LineCharacters Borders Scrollbar Shadow
98- if run_script ' env_var_exists' Scrollbar " ${MENU_INI_FILE } " ; then
99- Scrollbar=" $( run_script ' config_get' Scrollbar " ${MENU_INI_FILE} " ) "
99+ if run_script ' env_var_exists' Scrollbar " ${APPLICATION_INI_FILE } " ; then
100+ Scrollbar=" $( run_script ' config_get' Scrollbar) "
100101 else
101- Scrollbar=" $( run_script ' config_get' Scrollbar " ${DefaultMenuIniFile } " ) "
102- run_script ' config_set' Scrollbar " ${Scrollbar} " " ${MENU_INI_FILE} "
102+ Scrollbar=" $( run_script ' config_get' Scrollbar " ${DefaultIniFile } " ) "
103+ run_script ' config_set' Scrollbar " ${Scrollbar} "
103104 fi
104- if run_script ' env_var_exists' Shadow " ${MENU_INI_FILE } " ; then
105- Shadow=" $( run_script ' config_get' Shadow " ${MENU_INI_FILE} " ) "
105+ if run_script ' env_var_exists' Shadow " ${APPLICATION_INI_FILE } " ; then
106+ Shadow=" $( run_script ' config_get' Shadow) "
106107 else
107- Shadow=" $( run_script ' config_get' Shadow " ${DefaultMenuIniFile } " ) "
108- run_script ' config_set' Shadow " ${Shadow} " " ${MENU_INI_FILE} "
108+ Shadow=" $( run_script ' config_get' Shadow " ${DefaultIniFile } " ) "
109+ run_script ' config_set' Shadow " ${Shadow} "
109110 fi
110111 # Migrate old LineCharacters variable to Borders if Borders doesn't exist
111- if run_script ' env_var_exists' Borders " ${MENU_INI_FILE } " ; then
112- Borders=" $( run_script ' config_get' Borders " ${MENU_INI_FILE} " ) "
113- if run_script ' env_var_exists' LineCharacters " ${MENU_INI_FILE } " ; then
114- LineCharacters=" $( run_script ' config_get' LineCharacters " ${MENU_INI_FILE} " ) "
112+ if run_script ' env_var_exists' Borders " ${APPLICATION_INI_FILE } " ; then
113+ Borders=" $( run_script ' config_get' Borders) "
114+ if run_script ' env_var_exists' LineCharacters " ${APPLICATION_INI_FILE } " ; then
115+ LineCharacters=" $( run_script ' config_get' LineCharacters) "
115116 else
116- LineCharacters=" $( run_script ' config_get' LineCharacters " ${DefaultMenuIniFile } " ) "
117- run_script ' config_set' LineCharacters " ${LineCharacters} " " ${MENU_INI_FILE} "
117+ LineCharacters=" $( run_script ' config_get' LineCharacters " ${DefaultIniFile } " ) "
118+ run_script ' config_set' LineCharacters " ${LineCharacters} "
118119 fi
119120 else
120- if run_script ' env_var_exists' LineCharacters " ${MENU_INI_FILE } " ; then
121- Borders=" $( run_script ' config_get' LineCharacters " ${MENU_INI_FILE} " ) "
121+ if run_script ' env_var_exists' LineCharacters " ${APPLICATION_INI_FILE } " ; then
122+ Borders=" $( run_script ' config_get' LineCharacters) "
122123 else
123- Borders=" $( run_script ' config_get' Borders " ${DefaultMenuIniFile } " ) "
124+ Borders=" $( run_script ' config_get' Borders " ${DefaultIniFile } " ) "
124125 fi
125- run_script ' config_set' Borders " ${Borders} " " ${MENU_INI_FILE} "
126- LineCharacters=" $( run_script ' config_get' LineCharacters " ${DefaultMenuIniFile } " ) "
127- run_script ' config_set' LineCharacters " ${LineCharacters} " " ${MENU_INI_FILE} "
126+ run_script ' config_set' Borders " ${Borders} "
127+ LineCharacters=" $( run_script ' config_get' LineCharacters " ${DefaultIniFile } " ) "
128+ run_script ' config_set' LineCharacters " ${LineCharacters} "
128129 fi
130+
131+ # Set the dialog options based on the settings in the .ini file
129132 if is_true " ${Borders} " ; then
130133 if is_false " ${LineCharacters} " ; then
131134 DialogOptions+=" --ascii-lines"
@@ -145,13 +148,17 @@ apply_theme() {
145148 else
146149 DialogOptions+=" --no-shadow"
147150 fi
151+
148152 echo " ${DialogOptions} " > " ${DIALOG_OPTIONS_FILE} " ||
149- fatal " Failed to save dialog options file.\nFailing command: ${C["FailingCommand"]} echo \" ${DialogOptions} \" > \" ${DIALOG_OPTIONS_FILE} \" "
153+ fatal \
154+ " Failed to save dialog options file.\n" \
155+ " Failing command: ${C["FailingCommand"]} echo \" ${DialogOptions} \" > \" ${DIALOG_OPTIONS_FILE} \" "
150156 run_script ' set_permissions' " ${DIALOG_OPTIONS_FILE} "
151157
152158 cp " ${DialogFile} " " ${DIALOGRC} "
153- run_script ' config_set' Theme " ${ThemeName} " " ${MENU_INI_FILE} "
154- sort -o " ${MENU_INI_FILE} " " ${MENU_INI_FILE} "
159+ run_script ' set_permissions' " ${DIALOGRC} "
160+
161+ run_script ' config_set' Theme " ${ThemeName} "
155162}
156163
157164test_apply_theme () {
0 commit comments