-
Notifications
You must be signed in to change notification settings - Fork 2
/
Setup-openwith.app
605 lines (575 loc) · 23.3 KB
/
Setup-openwith.app
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#!/bin/sh
#
# Setup-openwith script by Lit
VERSION="1.5.1"
# https://github.com/Lighting/Setup-openwith
#
# --------------------------------------------------------------------------
# List of known readers names
#
# READERS_APPS - list of readers executable files (in bin/ directory)
# READERS_NAMES - list of readers title names
#
READERS_APPS="AdobeViewer.app,fbreader.app,eink-reader.app,eink-reader_with_rmsdk.app,eink-reader_with_pdfium.app,djviewer.app,picviewer.app,browser.app,cr3-pb.app,pbimageviewer.app,koreader.app,7z.so"
READERS_NAMES="@OpenWithAdobe,@OpenWithFbreader,PB Reader,@eink-reader_with_rmsdk,@eink-reader_with_pdfium,DjView,@Gallery,@Browser,Cool Reader 3,Pbimageviewer,KOReader,Pbimageviewer(7z.so)"
#
# BINS - List of third-party reader's binaries
# BIN#_EXT$ - additional extensions.cfg string $ for # reader's binary
#
BINS="cr3-pb.app,pbimageviewer.app,7z.so,koreader.app"
BIN1_EXT1="asp:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT2="cgi:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT3="chm:@Z_HTML_file:1:cr3-pb.app:ICON_CHM"
BIN1_EXT4="epub:@EPUB_file:1:cr3-pb.app:ICON_EPUB"
BIN1_EXT5="fb2:@FB2_file:1:cr3-pb.app:ICON_FB2"
BIN1_EXT6="htm:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT7="html:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT8="jsp:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT9="mht:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT10="php:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT11="pl:@HTML_file:1:cr3-pb.app:ICON_HTM"
BIN1_EXT12="rtf:@RTF_file:1:cr3-pb.app:ICON_RTF"
BIN1_EXT13="txt:@Text_file:1:cr3-pb.app:ICON_TXT"
BIN2_EXT1="tar:@TAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT2="tar.gz:@TAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT3="tgz:@TAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT4="tar.bz2:@TAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT5="tbz2:@TAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT6="zip:@ZIP_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT7="cbz:@ZIP_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT8="rar:@RAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT9="cbr:@RAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN2_EXT10="jpg:@JPEG_image:2:pbimageviewer.app:ICON_JPG"
BIN2_EXT11="jpeg:@JPEG_image:2:pbimageviewer.app:ICON_JPG"
BIN2_EXT12="png:@PNG_image:2:pbimageviewer.app:ICON_PNG"
BIN2_EXT13="bmp:@BMP_image:2:pbimageviewer.app:ICON_BMP"
BIN2_EXT14="tif:@TIFF_image:2:pbimageviewer.app:ICON_TIFF"
BIN2_EXT15="tiff:@TIFF_image:2:pbimageviewer.app:ICON_TIFF"
BIN3_EXT1="7z:@ZIP_file:1:pbimageviewer.app:ICON_ZIP"
BIN3_EXT2="cb7:@ZIP_file:1:pbimageviewer.app:ICON_ZIP"
BIN3_EXT3="cbt:@TAR_file:1:pbimageviewer.app:ICON_ZIP"
BIN4_EXT1="pdf:@PDF_file:1:koreader.app:ICON_PDF"
BIN4_EXT2="djvu:@DJVU_file:1:koreader.app:ICON_DJVU"
BIN4_EXT3="epub:@EPUB_file:1:koreader.app:ICON_EPUB"
BIN4_EXT4="fb2:@FB2_file:1:koreader.app:ICON_FB2"
BIN4_EXT5="mobi:@MOBI_file:1:koreader.app:ICON_MOBI"
BIN4_EXT6="zip:@ZIP_file:1:koreader.app:ICON_ZIP"
BIN4_EXT7="cbz:@ZIP_file:1:koreader.app:ICON_ZIP"
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Fast-switch feature for .fb2 extension
#
# FAST_SWITCH_APP - new app for fast-switch
# default_switch_app - default app switched with new app and vice versa
# ALTERNATE_SWITCH_APP - alternate default app if founded for .fb2 extension
# FAST_SWITCH_SHORTCUT - element in theme replaced by fast-switch
#
FAST_SWITCH_APP="cr3-pb.app"
default_switch_app="fbreader.app"
ALTERNATE_SWITCH_APP="eink-reader.app"
FAST_SWITCH_SHORTCUT="control.panel.shortcut.5."
FAST_SWITCH_TEXT="FB2:"
OPEN_SWITCH_NAME="OpenWith"
FAST_SWITCH_SUFFIX="(CR3)"
DEFAULT_SWITCH_SUFFIX="(Reader)"
# --------------------------------------------------------------------------
DEFAULT_THEME="Line"
TEMP_THEME="/tmp/theme.pbt"
TEMP_THEME_CFG="/tmp/theme.cfg"
TEMP_THEME2_CFG="/tmp/theme2.cfg"
EBRMAIN_CONFIG="/ebrmain/config"
EBRMAIN_LANG="/ebrmain/language"
EBRMAIN_THEME="/ebrmain/themes"
SYSTEM_PATH="/mnt/ext1/system"
SYSTEM_BIN="$SYSTEM_PATH/bin"
SYSTEM_SETTINGS="$SYSTEM_PATH/config/settings"
EBRMAIN_EXTENSIONS_CFG="$EBRMAIN_CONFIG/extensions.cfg"
SYSTEM_EXTENSIONS_CFG="$SYSTEM_PATH/config/extensions.cfg"
SYSTEM_GLOBAL_CFG="$SYSTEM_PATH/config/global.cfg"
SYSTEM_OPENWITH_CFG="$SYSTEM_PATH/config/openwith.cfg"
LNG="`awk -F= '/^language=/ {print $2}' "$SYSTEM_GLOBAL_CFG"|tr -d '\r'`"
Get_word()
{
w="`awk -F= '/^'"$2"'=/ {print $2}' "$EBRMAIN_LANG/${LNG:-en}.txt"|tr -d '\r'`"
eval "$1=\"${w:-$2}\""
}
Get_word w1 "@Install"
Get_word w2 "@Advanced"
Get_word w3 "@PersonalSettings"
Get_word w4 "@OpenWith"
/ebrmain/bin/dialog 2 "" "$w1: $w2
\"$w3 -> $w4\" v$VERSION" "@Install_q" "@Cancel"
[ "$?" != "1" ] && exit 1
Get_reader_name()
{
app_count=1
for app in $READERS_APPS; do
if [ "$app" = "$2" ]; then
app_name="`echo "$READERS_NAMES"|cut -d , -f$app_count`"
eval "$1=\"$app_name\""
return
fi
app_count="`expr $app_count + 1`"
done
eval "$1=\"${2%.app}\""
}
extensions=""
app_ext_count=1
for str in `awk /:/ "$EBRMAIN_EXTENSIONS_CFG"|tr -d '\r'`; do
ext="${str%%:*}"
apps="`echo "$str"|cut -d : -f4`"
extensions="$extensions,$ext"
eval "APP_EXT$app_ext_count=\"$apps\""
[ "$apps" != "${apps/,}" ] && eval "APP_SYS$app_ext_count=1"
app_ext_count="`expr $app_ext_count + 1`"
done
extensions="${extensions:1}"
for str in `awk /:/ "$SYSTEM_EXTENSIONS_CFG"|tr -d '\r'`; do
ext="${str%%:*}"
apps="`echo "$str"|cut -d : -f4`"
count=1
IFS=,
for ext_def in $extensions; do
if [ "$ext_def" = "$ext" ]; then
eval "APP_EXT$count=\"\$APP_EXT$count,$apps\""
eval "APP_DEF$count=\"${apps%%,*}\""
continue 2
fi
count="`expr $count + 1`"
done
extensions="$extensions,$ext"
eval "APP_EXT$app_ext_count=\"$apps\""
app_ext_count="`expr $app_ext_count + 1`"
done
Add_extention_text()
{
if [ "$reader" = "$count" ]; then
extensions_text="$extensions_text, $ext"
else
Get_reader_name reader_name_first "$bin_file"
if [ "$extensions_text" ]; then
extensions_text="$extensions_text.
- $reader_name_first: $ext"
else
extensions_text="- $reader_name_first: $ext"
fi
reader="$count"
fi
}
reader=0
extensions_cfg=""
extensions_text=""
extensions2="$extensions"
count=0
IFS=,
for bin_file in $BINS; do
count="`expr $count + 1`"
[ -e "$SYSTEM_BIN/$bin_file" ] || continue
count2=1
while true; do
eval "str=\"\$BIN${count}_EXT$count2\""
count2="`expr $count2 + 1`"
[ "$str" ] || break
ext="${str%%:*}"
apps="`echo "$str"|cut -d : -f4`"
count3=1
for ext_def in $extensions2; do
if [ "$ext_def" = "$ext" ]; then
eval "reader_apps=\",\${APP2_EXT$count3:-\$APP_EXT$count3}\""
eval "APP2_EXT$count3=\"\${APP2_EXT$count3:-\$APP_EXT$count3},$apps\""
for reader_app in $apps; do
if [ "$reader_apps" = "${reader_apps/,$reader_app}" ]; then
Add_extention_text
echo "$extensions_cfg"|grep -q -e "^$ext:.*" || grep -q -e "^$ext:.*" "$SYSTEM_EXTENSIONS_CFG" || extensions_cfg="$extensions_cfg$str
"
continue 3
fi
done
continue 2
fi
count3="`expr $count3 + 1`"
done
extensions2="$extensions2,$ext"
eval "APP2_EXT$app_ext_count=\"$apps\""
app_ext_count="`expr $app_ext_count + 1`"
extensions_cfg="$extensions_cfg$str
"
Add_extention_text
done
done
if [ "$extensions_text" ]; then
[ "$extensions_text" ] && extensions_text="$extensions_text."
extensions_new="${extensions_new:1}"
Get_word w1 "@SearchFound"
Get_word w2 "@DetailSoftwareInfo"
Get_word w3 "@Add"
Get_word w4 "@AllNew"
Get_word w5 "@Formats"
Get_word w6 "@Filters"
/ebrmain/bin/dialog 2 "" "$w1: $w2.
$w3 $w4 $w5 & $w6
$SYSTEM_EXTENSIONS_CFG?
$extensions_text" "$w3"
if [ "$?" = "1" ]; then
echo -n "$extensions_cfg" >> "$SYSTEM_EXTENSIONS_CFG"
extensions="`echo -e "${extensions2//,/\\\n}"|sort`"
extensions="${extensions//
/,}"
count=0
for ext in $extensions; do
count="`expr $count + 1`"
count2=1
for ext_def in $extensions2; do
if [ "$ext_def" = "$ext" ]; then
eval "COUNT_EXT$count=\"$count2\""
continue 2
fi
count2="`expr $count2 + 1`"
done
done
sort -o "$SYSTEM_EXTENSIONS_CFG" "$SYSTEM_EXTENSIONS_CFG"
extensions2="1"
else
extensions2=""
fi
else
extensions2=""
fi
mkdir -p "$SYSTEM_SETTINGS"
sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "$EBRMAIN_CONFIG/settings/personalize.json"|head -n -1 > "$SYSTEM_SETTINGS/personalize.json"
echo -e ',
\t{
\t\t"control_type" : "submenu",
\t\t"icon_id" : "ci_panel_config",
\t\t"id" : "openwith",
\t\t"from_file" : "./openwith.json",
\t\t"title_id" : "@OpenWith"
\t}
]' >> "$SYSTEM_SETTINGS/personalize.json"
echo -e '[
\t{
\t\t"control_type" : "executable",
\t\t"icon_id" : "ci_optimize_db",
\t\t"id" : "openwith_apply",
\t\t"storage" : [ "${SYSTEM_APPLICATION_PATH}/openwith_apply.app" ],
\t\t"title_id" : "@PS_ApplyingChanges"
\t},
\t{
\t\t"control_type" : "executable",
\t\t"icon_id" : "ci_scanmode",
\t\t"id" : "openwith_clear",
\t\t"storage" : [ "${SYSTEM_APPLICATION_PATH}/openwith_clear.app" ],
\t\t"title_id" : "@BrowserClearHistory"
\t},' > "$SYSTEM_SETTINGS/openwith.json"
rm -f "$SYSTEM_OPENWITH_CFG"
Get_word w1 "@Default"
fast_switch=0
count=0
for ext in $extensions; do
count="`expr $count + 1`"
if [ "$extensions2" ]; then
eval "count2=\"\$COUNT_EXT$count\""
eval "apps=\"\${APP2_EXT$count2:-\$APP_EXT$count2}\""
else
eval "apps=\"\$APP_EXT$count\""
count2="$count"
fi
[ "$apps" = "${apps/,}" ] && continue
reader_app_first="${apps%%,*}"
Get_reader_name reader_name_first "$reader_app_first"
echo -e '\t{
\t\t"control_type" : "list",
\t\t"icon_id" : "ci_dict",
\t\t"id" : "ext_'"$ext"'",
\t\t"kind" : "text",
\t\t"default" : ":'"$reader_app_first:$reader_name_first"'",
\t\t"storage" : [ "${SYSTEM_CONFIG_PATH}/openwith.cfg, '"$ext"'" ],
\t\t"values" : [' >> "$SYSTEM_SETTINGS/openwith.json"
reader_apps=""
for reader_app in $apps; do
if [ "$ext" = "fb2" ]; then
[ "$reader_app" = "$FAST_SWITCH_APP" ] && fast_switch=1
[ "$reader_app" = "$ALTERNATE_SWITCH_APP" ] && default_switch_app="$ALTERNATE_SWITCH_APP"
fi
[ "$reader_apps" != "${reader_apps/,$reader_app}" ] && continue
reader_apps="$reader_apps,$reader_app"
Get_reader_name reader_name "$reader_app"
echo -e '\t\t\t":'"$reader_app:$reader_name"'",' >> "$SYSTEM_SETTINGS/openwith.json"
done
echo -ne '\t\t\t],
\t\t"title_id" : ".'"$ext" >> "$SYSTEM_SETTINGS/openwith.json"
eval "reader_app_sys=\"\$APP_SYS$count2\""
if [ "$reader_app_sys" = "1" ]; then
Get_word reader_name_def "$reader_name_first"
echo -n " ($w1 $reader_name_def)" >> "$SYSTEM_SETTINGS/openwith.json"
fi
echo -e '"
\t},' >> "$SYSTEM_SETTINGS/openwith.json"
eval "reader_app_def=\"\$APP_DEF$count2\""
[ "$reader_app_def" ] || reader_app_def="$reader_app_first"
/ebrmain/bin/iv2sh WriteConfig "$SYSTEM_OPENWITH_CFG" "$ext" "$reader_app_def"
new_apps="$reader_app_def`echo ",$reader_apps"|sed "s/,*$reader_app_def//g"|sed s/,,*/,/g`"
sed -i "s/^\($ext:.*:.*:\).*\(:.*\)$/\1$new_apps\2/" "$SYSTEM_EXTENSIONS_CFG"
done
echo -e '\t{
\t\t"control_type" : "executable",
\t\t"icon_id" : "ci_remove_packages",
\t\t"id" : "openwith_remove",
\t\t"storage" : [ "${SYSTEM_APPLICATION_PATH}/openwith_remove.app" ],
\t\t"title_id" : "@Delete"
\t}
]' >> "$SYSTEM_SETTINGS/openwith.json"
echo '#!/bin/sh
LNG="`awk -F= '\''/^language=/ {print $2}'\'' "'"$SYSTEM_GLOBAL_CFG"'"|tr -d '\''\r'\''`"
Get_word()
{
w="`awk -F= '\''/^'\''"$2"'\''=/ {print $2}'\'' "'"$EBRMAIN_LANG"'/${LNG:-en}.txt"|tr -d '\''\r'\''`"
eval "$1=\"${w:-$2}\""
}
Get_word w1 "@Delete"
Get_word w2 "@Advanced"
Get_word w3 "@OpenWith"
/ebrmain/bin/dialog 4 "" "$w1
$w2
\"$w3\"?" "@Delete"
if [ "$?" = "1" ]; then
rm -f "'"$SYSTEM_SETTINGS/personalize.json"'"
rm -f "'"$SYSTEM_SETTINGS/openwith.json"'"
rm -f "'"$SYSTEM_OPENWITH_CFG"'"
openwith="'"$SYSTEM_PATH"'/profiles/*/config/settings/openwith.json"
if [ "$openwith" = "`echo $openwith`" ]; then
rm -f "'"$SYSTEM_BIN/openwith_apply.app"'"
rm -f "'"$SYSTEM_BIN/openwith_clear.app"'"
rm -f "'"$SYSTEM_BIN/openwith_remove.app"'"
rm -f "'"$SYSTEM_BIN/openwith_fb2.app"'"
GLOBAL_THEME="`awk -F= '\''/^theme=/ {print $2}'\'' "'"$SYSTEM_GLOBAL_CFG"'"|tr -d '\''\r'\''`"
[ "${GLOBAL_THEME%'"-$OPEN_SWITCH_NAME"'*}" != "$GLOBAL_THEME" ] && /ebrmain/bin/iv2sh WriteConfig "'"$SYSTEM_GLOBAL_CFG"'" theme ""
rm -f "'"$SYSTEM_PATH"'/themes/"*"'"$OPEN_SWITCH_NAME"'"*.pbt
fi
sync
killall settings.app
/ebrmain/bin/iv2sh SendEventTo -1 154
fi' > "$SYSTEM_BIN/openwith_remove.app"
echo '#!/bin/sh
Set_default()
{
apps="`echo "$str"|cut -d : -f4`"
new_apps="$def_app`echo ",$apps"|sed "s/,*$def_app//g"|sed s/,,*/,/g`"
sed -i "s/^\($ext:.*:.*:\).*\(:.*\)$/\1$new_apps\2/" "'"$SYSTEM_EXTENSIONS_CFG"'"
}
while read def_str; do
apply=0
def_ext="${def_str%%=*}"
def_app="${def_str#*=}"
for str in `awk /:/ "'"$SYSTEM_EXTENSIONS_CFG"'"|tr -d '\''\r'\''`; do
ext="${str%%:*}"
[ "$ext" != "$def_ext" ] && continue
Set_default
apply=1
done
if [ "$apply" = "0" ]; then
for str in `awk /:/ "'"$EBRMAIN_EXTENSIONS_CFG"'"|tr -d '\''\r'\''`; do
ext="${str%%:*}"
[ "$ext" != "$def_ext" ] && continue
echo "$str" >> "'"$SYSTEM_EXTENSIONS_CFG"'"
Set_default
done
fi
done < "'"$SYSTEM_OPENWITH_CFG"'"
sync
/ebrmain/bin/iv2sh SendEventTo -1 154' > "$SYSTEM_BIN/openwith_apply.app"
echo '#!/bin/sh
LNG="`awk -F= '\''/^language=/ {print $2}'\'' "'"$SYSTEM_GLOBAL_CFG"'"|tr -d '\''\r'\''`"
Get_word()
{
w="`awk -F= '\''/^'\''"$2"'\''=/ {print $2}'\'' "'"$EBRMAIN_LANG"'/${LNG:-en}.txt"|tr -d '\''\r'\''`"
eval "$1=\"${w:-$2}\""
}
Get_word w1 "@BrowserClearHistory"
Get_word w2 "@BooksOpened"
Get_word w3 "@APP_file"
/ebrmain/bin/dialog 2 "" "$w1:
$w2 - $w3
('"$SYSTEM_PATH/config/handlers.cfg"')?" "@Clear"
[ "$?" = "1" ] && rm -f "'"$SYSTEM_PATH/config/handlers.cfg"'" && sync' > "$SYSTEM_BIN/openwith_clear.app"
if [ "$fast_switch" = "1" ]; then
GLOBAL_THEME="`awk -F= '/^theme=/ {print $2}' "$SYSTEM_GLOBAL_CFG"|tr -d '\r'`"
current_theme="${GLOBAL_THEME:-$DEFAULT_THEME}"
if [ -e "$SYSTEM_PATH/themes/$current_theme.pbt" ]; then
current_theme_path="$SYSTEM_PATH/themes/$current_theme.pbt"
elif [ -e "$EBRMAIN_THEME/$current_theme.pbt" ]; then
current_theme_path="$EBRMAIN_THEME/$current_theme.pbt"
else
current_theme="$DEFAULT_THEME"
current_theme_path="$EBRMAIN_THEME/$current_theme.pbt"
fi
cp -f "$current_theme_path" "$TEMP_THEME"
current_theme_path="$TEMP_THEME"
openwith_theme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EOgjXXRbWZEj/TFmNYC1H29v4vV1NV2ebRFVXXVXu1SV73WoC2tbtSa
qq6ovlq7UWMBM2pahhXpYwFsLrqRYgHkkB7oWrPRb0WGWCAaMaMsMLA7Ye4eFq1lsMBQIh2QJXAe
EUafocdJTiCpuEWaY/hvIQ1ZYBAEupLYRiMs0LVtSwDb4MAuFtCj4UEjghp1xMMRw4jsFuJl/Fv9
huNBZDjWD6tJaBNa+kyT0V5B+7bQGbEsI9aXtnTzv19byjVaAcot5/5fE/lTfsqrQ7xaKefc02si
18pP+S78KibymuQox6OQO6z0l/P/Gmmb5Cj3m4FMa5U78/L9fSsT+U9yVCvHq4WP8/27nok8JznK
8UYoukGxW74vvJGJuiCcaiPkFvNQ7dJzMxP39SRHtZVyV36TKM+DamyHIke1OOYWNeqS8yvL6VI/
1TrtFcEasW/Mj1+vIufUCBCXdr4cwR2KHN2FdGJxsnUX6vu2Ikd7U27J+b8hlOXuZJU8mIHcDOQe
r75Q7i4hl8KSid+bGoQ+7zy5Hyj6DkDuQMP5v5eU8XEmfnMhU+L3o4Xlskz8RuLshZAb/xS5p6Vd
kqO7kkc+Re7XMiYkJ36XEr9JuRU5mtdvFX20B49fjsnP00fwe0XORb+9LF14fZ+XeklO3BWd7195
qV+QeFDSJHfVPDmCV4Wucy61Qe66BfSVfSs/A5ArLiD3H/YonaGAHAAA'|base64 -d|gzip -d > "$SYSTEM_BIN/pbtheme-openwith"
Get_reader_name fast_switch_app_name "$FAST_SWITCH_APP"
Get_reader_name default_switch_app_name "$default_switch_app"
Get_word default_switch_app_text "$default_switch_app_name"
$SYSTEM_BIN/pbtheme-openwith -e "$current_theme_path" "$TEMP_THEME_CFG"
fast_switch_shortcut_position="${FAST_SWITCH_SHORTCUT//./\\.}position="
sed -i "s/^\($fast_switch_shortcut_position.*$\)/#\1/" "$TEMP_THEME_CFG"
sed -i "/^${FAST_SWITCH_SHORTCUT//./\\.}.*$/d" "$TEMP_THEME_CFG"
sed -i "s/^#\($fast_switch_shortcut_position.*$\)/\1/" "$TEMP_THEME_CFG"
sed -i "/^$fast_switch_shortcut_position.*$/a${FAST_SWITCH_SHORTCUT}icon.name=desktop_launcher_library" "$TEMP_THEME_CFG"
sed -i "/^$fast_switch_shortcut_position.*$/a${FAST_SWITCH_SHORTCUT}focus.icon.name=desktop_launcher_library_f" "$TEMP_THEME_CFG"
sed -i "/^$fast_switch_shortcut_position.*$/a${FAST_SWITCH_SHORTCUT}path=$SYSTEM_BIN/openwith_fb2.app" "$TEMP_THEME_CFG"
cp -f "$TEMP_THEME_CFG" "$TEMP_THEME2_CFG"
sed -i "/^$fast_switch_shortcut_position.*$/a${FAST_SWITCH_SHORTCUT}text=$FAST_SWITCH_TEXT$fast_switch_app_name" "$TEMP_THEME_CFG"
$SYSTEM_BIN/pbtheme-openwith -r "$current_theme_path" "$TEMP_THEME_CFG" "$SYSTEM_PATH/themes/$openwith_theme$FAST_SWITCH_SUFFIX.pbt"
sed -i "/^$fast_switch_shortcut_position.*$/a ${FAST_SWITCH_SHORTCUT}text=$FAST_SWITCH_TEXT$default_switch_app_text" "$TEMP_THEME2_CFG"
$SYSTEM_BIN/pbtheme-openwith -r "$current_theme_path" "$TEMP_THEME2_CFG" "$SYSTEM_PATH/themes/$openwith_theme$DEFAULT_SWITCH_SUFFIX.pbt"
rm -f "$SYSTEM_BIN/pbtheme-openwith"
rm -f "$TEMP_THEME"
rm -f "$TEMP_THEME_CFG"
rm -f "$TEMP_THEME2_CFG"
echo '#!/bin/sh
LNG="`awk -F= '\''/^language=/ {print $2}'\'' "'"$SYSTEM_GLOBAL_CFG"'"|tr -d '\''\r'\''`"
Get_word()
{
w="`awk -F= '\''/^'\''"$2"'\''=/ {print $2}'\'' "'"$EBRMAIN_LANG"'/${LNG:-en}.txt"|tr -d '\''\r'\''`"
eval "$1=\"${w:-$2}\""
}
Set_default()
{
apps="`echo "$str"|cut -d : -f4`"
app_default="'"$default_switch_app"'"
app_fast="'"$FAST_SWITCH_APP"'"
GLOBAL_THEME="`awk -F= '\''/^theme=/ {print $2}'\'' "'"$SYSTEM_GLOBAL_CFG"'"|tr -d '\''\r'\''`"
current_theme="${GLOBAL_THEME:-'"$DEFAULT_THEME"'}"
change_theme="no"
if [ "${current_theme%'"-$OPEN_SWITCH_NAME"'*}" != "$current_theme" ]; then
change_theme="yes"
if [ "${current_theme%'"-$OPEN_SWITCH_NAME$FAST_SWITCH_SUFFIX"'*}" != "$current_theme" ]; then
def_app=$app_default
def_app_name="'"$default_switch_app_name"'"
/ebrmain/bin/iv2sh WriteConfig "'"$SYSTEM_GLOBAL_CFG"'" "theme" "${current_theme%'"-$OPEN_SWITCH_NAME"'*}'"-$OPEN_SWITCH_NAME$DEFAULT_SWITCH_SUFFIX"'"
elif [ "${current_theme%'"-$OPEN_SWITCH_NAME$DEFAULT_SWITCH_SUFFIX"'*}" != "$current_theme" ]; then
def_app=$app_fast
def_app_name="'"$fast_switch_app_name"'"
/ebrmain/bin/iv2sh WriteConfig "'"$SYSTEM_GLOBAL_CFG"'" "theme" "${current_theme%'"-$OPEN_SWITCH_NAME"'*}'"-$OPEN_SWITCH_NAME$FAST_SWITCH_SUFFIX"'"
else
change_theme="need"
fi
fi
if [ "$change_theme" != "yes" ]; then
if [ "${apps%%,*}" != "$app_fast" ]; then
def_app=$app_fast
def_app_name="'"$fast_switch_app_name"'"
else
def_app=$app_default
def_app_name="'"$default_switch_app_name"'"
fi
fi
new_apps="$def_app`echo ",$apps"|sed "s/,*$def_app//g"|sed s/,,*/,/g`"
sed -i "s/^\($ext:.*:.*:\).*\(:.*\)$/\1$new_apps\2/" "'"$SYSTEM_EXTENSIONS_CFG"'"
/ebrmain/bin/iv2sh WriteConfig "'"$SYSTEM_OPENWITH_CFG"'" "$ext" "$def_app"
sync
[ "$change_theme" != "no" ] && /ebrmain/bin/iv2sh SendEventTo -1 154
exit 0
}
for str in `awk /:/ "'"$SYSTEM_EXTENSIONS_CFG"'"|tr -d '\''\r'\''`; do
ext="${str%%:*}"
[ "$ext" != "fb2" ] && continue
Set_default
done
for str in `awk /:/ "'"$EBRMAIN_EXTENSIONS_CFG"'"|tr -d '\''\r'\''`; do
ext="${str%%:*}"
[ "$ext" != "fb2" ] && continue
echo "$str" >> "'"$SYSTEM_EXTENSIONS_CFG"'"
Set_default
done' > "$SYSTEM_BIN/openwith_fb2.app"
Get_word w1 "@ChangeWidget"
Get_word w2 "@KA_srch"
Get_word w3 "@Settings"
Get_word w4 "@PersonalSettings"
Get_word w5 "@Theme"
fs_text="
$w1 \"$w2\"
(\"$default_switch_app_text\"/\"$fast_switch_app_name\"):
$w3->$w4->
$w5:$openwith_theme
"
else
fs_text=""
fi
Get_word w1 "@Install_complete"
Get_word w2 "@Delete_book"
Get_word w3 "@No"
/ebrmain/bin/dialog 3 "" "$w1
$fs_text
$w2
(""$0"")" "@Yes" "> $w3 <"
[ "$?" = "1" ] && rm -f "$0"
sync
killall settings.app
# SendEventTo ALLTASKS EVT_CONFIGCHANGED
/ebrmain/bin/iv2sh SendEventTo -1 154