@@ -151,21 +151,21 @@ file_is_property_clean() {
151
151
fi
152
152
}
153
153
154
- # file_set_property_direct ()
155
- # Set property of a give properties file directly without checks
154
+ # file_set_property ()
155
+ # Set property of a given properties file directly without checks
156
156
#
157
- # %usage: file_set_property_direct filepath property value
157
+ # %usage: file_set_property filepath property value
158
158
# $parameters
159
159
# filepath - Path to file
160
160
# property - Property to change
161
161
# value - Value to set property to
162
- file_set_property_direct () {
163
- fspd_filepath =" $1 "
164
- fspd_property =" $2 "
165
- fspd_value =" $3 "
162
+ file_set_property () {
163
+ fsp_filepath =" $1 "
164
+ fsp_property =" $2 "
165
+ fsp_value =" $3 "
166
166
167
- echo " [INFO] Setting file '$fspd_filepath ' property '$fspd_property ' value '$fspd_value ' directly now." >> " $logfile "
168
- if sed -i -E " s/$fspd_property =/& $fspd_value /" " $fspd_filepath "
167
+ echo " [INFO] Setting file '$fsp_filepath ' property '$fsp_property ' value '$fsp_value ' directly now." >> " $logfile "
168
+ if sed -i -E " s/$fsp_property =.^$/ $fsp_property = $fsp_value /" " $fsp_filepath "
169
169
then
170
170
echo " [INFO] File property was set successfully." >> " $logfile "
171
171
else
@@ -174,25 +174,82 @@ file_set_property_direct() {
174
174
fi
175
175
}
176
176
177
- # file_set_property ()
178
- # Set property of a given properties file
177
+ # file_set_property_wrapper ()
178
+ # Set property of a given properties file with all the checks
179
179
#
180
- # %usage: file_set_property filepath property value
180
+ # %usage: file_set_property_wrapper filepath property value
181
181
# $parameters
182
182
# filepath - Path to file
183
183
# property - Property to change
184
184
# value - Value to set property to
185
- file_set_property () {
186
- fsp_filepath=" $1 "
187
- fsp_property=" $2 "
188
- fsp_value=" $3 "
185
+ file_set_property_wrapper () {
186
+ fspw_filepath=" $1 "
187
+ fspw_property=" $2 "
188
+ fspw_value=" $3 "
189
+
190
+ echo " [INFO] Setting file '$fspw_filepath ' property '$fspw_property ' value '$fspw_value '." >> " $logfile "
191
+ if filepath_exists " $fspw_filepath " ; then
192
+ file_clear_property " $fspw_filepath " " $fspw_property "
193
+ if file_is_property_clean " $fspw_filepath " " $fspw_property " ; then
194
+ if is_empty " $fspw_value " ; then
195
+ file_set_property " $fspw_filepath " " $fspw_property " " $fspw_value "
196
+ return 0
197
+ else
198
+ echo " [INFO] No value was set due to parameters." >> " $logfile "
199
+ return 0
200
+ fi
201
+ else
202
+ return 1
203
+ fi
204
+ else
205
+ error_add " fileexists"
206
+ echo " [ERR!] File '$fspw_filepath ' doesn't exist." >> " $logfile "
207
+ return 1
208
+ fi
209
+ }
189
210
190
- echo " [INFO] Setting file '$fsp_filepath ' property '$fsp_property ' value '$fsp_value '." >> " $logfile "
191
- if filepath_exists " $fsp_filepath " ; then
192
- file_clear_property " $fsp_filepath " " $fsp_property "
193
- if file_is_property_clean " $fsp_filepath " " $fsp_property " ; then
194
- if is_empty " $fsp_value " ; then
195
- file_set_property_direct " $fsp_filepath " " $fsp_property " " $fsp_value "
211
+ # file_prepend_value_to_property()
212
+ # Prepend value to property of a given properties file directly without checks
213
+ #
214
+ # %usage: file_prepend_value_to_property filepath property value
215
+ # $parameters
216
+ # filepath - Path to file
217
+ # property - Property to change
218
+ # value - Value to prepend to property
219
+ file_prepend_value_to_property () {
220
+ favtp_filepath=" $1 "
221
+ favtp_property=" $2 "
222
+ favtp_value=" $3 "
223
+
224
+ echo " [INFO] Setting file '$favtp_filepath ' property '$favtp_property ' value '$favtp_value ' directly now." >> " $logfile "
225
+ if sed -i -E " s/$favtp_property =/&$fsp_value /" " $fsp_filepath "
226
+ then
227
+ echo " [INFO] File property was set successfully." >> " $logfile "
228
+ else
229
+ error_add " sed.setprop"
230
+ echo " [ERR!] File property set failed." >> " $logfile "
231
+ fi
232
+ }
233
+
234
+ # file_prepend_value_to_property_wrapper()
235
+ # Prepend value to property of a given properties file with all the checks
236
+ #
237
+ # %usage: file_prepend_value_to_property_wrapper filepath property value
238
+ # $parameters
239
+ # filepath - Path to file
240
+ # property - Property to change
241
+ # value - Value to prepend to property
242
+ file_prepend_value_to_property_wrapper () {
243
+ favtpw_filepath=" $1 "
244
+ favtpw_property=" $2 "
245
+ favtpw_value=" $3 "
246
+
247
+ echo " [INFO] Setting file '$favtpw_filepath ' property '$favtpw_property ' value '$favtpw_value '." >> " $logfile "
248
+ if filepath_exists " $favtpw_filepath " ; then
249
+ file_clear_property " $favtpw_filepath " " $favtpw_property "
250
+ if file_is_property_clean " $favtpw_filepath " " $favtpw_property " ; then
251
+ if is_empty " $favtpw_value " ; then
252
+ file_prepend_value_to_property " $favtpw_filepath " " $fspw_property " " $favtpw_value "
196
253
return 0
197
254
else
198
255
echo " [INFO] No value was set due to parameters." >> " $logfile "
@@ -203,7 +260,7 @@ file_set_property() {
203
260
fi
204
261
else
205
262
error_add " fileexists"
206
- echo " [ERR!] File '$fsp_filepath ' doesn't exist." >> " $logfile "
263
+ echo " [ERR!] File '$favtpw_filepath ' doesn't exist." >> " $logfile "
207
264
return 1
208
265
fi
209
266
}
@@ -219,7 +276,7 @@ module_set_message() {
219
276
msm_property=" description"
220
277
msm_value=" $1 "
221
278
222
- file_set_property " $msm_filepath " " $msm_property " " $msm_value "
279
+ file_set_property_wrapper " $msm_filepath " " $msm_property " " $msm_value "
223
280
}
224
281
225
282
# file_remove_xml_key_value()
@@ -389,9 +446,9 @@ mount_file() {
389
446
module_set_status () {
390
447
echo " [INFO] Setting module status."
391
448
if [ " $error_count " -gt 0 ]; then
392
- module_set_message " β οΈβ [WARN/ERROR] - Failed to set standalone mode with ($error_count ) error(s): $error_message ||| "
449
+ module_set_message " β οΈβ [WARN/ERROR] - Failed to set standalone mode with ($error_count ) error(s): $error_message . "
393
450
else
394
- module_set_message " β
[OK] - Samsung DeX standalone mode set ||| "
451
+ module_set_message " β
[OK] - Samsung DeX standalone mode set"
395
452
fi
396
453
}
397
454
0 commit comments