@@ -21,22 +21,46 @@ function depends_esthemes() {
21
21
fi
22
22
}
23
23
24
+ function _has_pixel_pos_esthemes() {
25
+ local pixel_pos=0
26
+ # get the version of emulationstation installed so we can check whether to show
27
+ # themes that use the new pixel based positioning - we run as $user as the
28
+ # emulationstation launch script will exit if run as root
29
+ local es_ver=" $( sudo -u $user /usr/bin/emulationstation --help | grep -oP " Version \K[^,]+" ) "
30
+ # if emulationstation is newer than 2.10, enable pixel based themes
31
+ compareVersions " $es_ver " ge " 2.10" && pixel_pos=1
32
+ echo " $pixel_pos "
33
+ }
34
+
24
35
function install_theme_esthemes() {
25
36
local theme=" $1 "
26
37
local repo=" $2 "
27
- local default_branch
38
+ local branch=" $3 "
39
+
40
+ local pixel_pos=" $( _has_pixel_pos_esthemes) "
41
+
28
42
if [[ -z " $repo " ]]; then
29
43
repo=" RetroPie"
30
44
fi
45
+
31
46
if [[ -z " $theme " ]]; then
32
47
theme=" carbon"
33
48
repo=" RetroPie"
49
+ [[ " $pixel_pos " -eq 1 ]] && theme+=" -2021"
50
+ fi
51
+
52
+ local name=" $theme "
53
+
54
+ if [[ -z " $branch " ]]; then
55
+ # Get the name of the default branch, fallback to 'master' if not found
56
+ branch=$( runCmd git ls-remote --symref --exit-code " https://github.com/$repo /es-theme-$theme .git" HEAD | grep -oP " .*/\K[^\t]+" )
57
+ [[ -z " $branch " ]] && branch=" master"
58
+ else
59
+ name+=" -$branch "
34
60
fi
35
- # Get the name of the default branch, fallback to 'master' if not found
36
- default_branch=$( runCmd git ls-remote --symref --exit-code " https://github.com/$repo /es-theme-$theme .git" HEAD | grep -oP " .*/\K[^\t]+" )
37
- [[ -z " $default_branch " ]] && default_branch=" master"
61
+
38
62
mkdir -p " /etc/emulationstation/themes"
39
- gitPullOrClone " /etc/emulationstation/themes/$theme " " https://github.com/$repo /es-theme-$theme .git" " $default_branch "
63
+ gitPullOrClone " /etc/emulationstation/themes/$name " " https://github.com/$repo /es-theme-$theme .git" " $branch "
40
64
}
41
65
42
66
function uninstall_theme_esthemes() {
@@ -47,7 +71,19 @@ function uninstall_theme_esthemes() {
47
71
}
48
72
49
73
function gui_esthemes() {
50
- local themes=(
74
+ local themes=()
75
+
76
+ local pixel_pos=" $( _has_pixel_pos_esthemes) "
77
+
78
+ if [[ " $pixel_pos " -eq 1 ]]; then
79
+ themes+=(
80
+ ' RetroPie carbon-2021'
81
+ ' RetroPie carbon-2021 centered'
82
+ ' RetroPie carbon-2021 nometa'
83
+ )
84
+ fi
85
+
86
+ local themes+=(
51
87
' RetroPie carbon'
52
88
' RetroPie carbon-centered'
53
89
' RetroPie carbon-nometa'
@@ -262,6 +298,10 @@ function gui_esthemes() {
262
298
)
263
299
while true ; do
264
300
local theme
301
+ local theme_dir
302
+ local branch
303
+ local name
304
+
265
305
local installed_themes=()
266
306
local repo
267
307
local options=()
@@ -284,13 +324,20 @@ function gui_esthemes() {
284
324
theme=($theme )
285
325
repo=" ${theme[0]} "
286
326
theme=" ${theme[1]} "
287
- if [[ -d " /etc/emulationstation/themes/$theme " ]]; then
327
+ branch=" ${theme[2]} "
328
+ name=" $repo /$theme "
329
+ theme_dir=" $theme "
330
+ if [[ -n " $branch " ]]; then
331
+ name+=" ($branch )"
332
+ theme_dir+=" -$branch "
333
+ fi
334
+ if [[ -d " /etc/emulationstation/themes/$theme_dir " ]]; then
288
335
status+=(" i" )
289
- options+=(" $i " " Update or Uninstall $repo / $theme (installed)" )
290
- installed_themes+=(" $theme $repo " )
336
+ options+=(" $i " " Update or Uninstall $name (installed)" )
337
+ installed_themes+=(" $theme $repo $branch " )
291
338
else
292
339
status+=(" n" )
293
- options+=(" $i " " Install $repo / $theme " )
340
+ options+=(" $i " " Install $name " )
294
341
fi
295
342
(( i++ ))
296
343
done
@@ -329,27 +376,34 @@ function gui_esthemes() {
329
376
U)
330
377
for theme in " ${installed_themes[@]} " ; do
331
378
theme=($theme )
332
- rp_callModule esthemes install_theme " ${theme[0]} " " ${theme[1]} "
379
+ rp_callModule esthemes install_theme " ${theme[0]} " " ${theme[1]} " " ${theme[2]} "
333
380
done
334
381
;;
335
382
* )
336
383
theme=(${themes[choice-1]} )
337
384
repo=" ${theme[0]} "
338
385
theme=" ${theme[1]} "
386
+ branch=" ${theme[2]} "
387
+ name=" $repo /$theme "
388
+ theme_dir=" $theme "
389
+ if [[ -n " $branch " ]]; then
390
+ name+=" ($branch )"
391
+ theme_dir+=" -$branch "
392
+ fi
339
393
if [[ " ${status[choice]} " == " i" ]]; then
340
- options=(1 " Update $repo / $theme " 2 " Uninstall $repo / $theme " )
341
- cmd=(dialog --backtitle " $__backtitle " --menu " Choose an option for theme" 12 40 06)
394
+ options=(1 " Update $name " 2 " Uninstall $name " )
395
+ cmd=(dialog --backtitle " $__backtitle " --menu " Choose an option for theme" 12 60 06)
342
396
local choice=$( " ${cmd[@]} " " ${options[@]} " 2>&1 > /dev/tty)
343
397
case " $choice " in
344
398
1)
345
- rp_callModule esthemes install_theme " $theme " " $repo "
399
+ rp_callModule esthemes install_theme " $theme " " $repo " " $branch "
346
400
;;
347
401
2)
348
- rp_callModule esthemes uninstall_theme " $theme "
402
+ rp_callModule esthemes uninstall_theme " $theme_dir "
349
403
;;
350
404
esac
351
405
else
352
- rp_callModule esthemes install_theme " $theme " " $repo "
406
+ rp_callModule esthemes install_theme " $theme " " $repo " " $branch "
353
407
fi
354
408
;;
355
409
esac
0 commit comments