Skip to content

Commit ca7206e

Browse files
authored
Merge pull request #190 from s1eve-mcdichae1/bgm123
bgm123.sh - simplify _get_vars function and calls
2 parents 7d9e830 + 20d25f0 commit ca7206e

File tree

1 file changed

+7
-37
lines changed

1 file changed

+7
-37
lines changed

scriptmodules/supplementary/bgm123.sh

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ function _get_vars_bgm123() {
2727
[init]="$md_inst/bgm_start.sh"
2828
[killscript]="$md_inst/bgm_stop.sh"
2929
[fadescript]="$md_inst/bgm_fade.sh"
30+
[share]="$datadir/bgm"
3031
)
3132

3233
local var
33-
for var in "$@"; do
34+
for var in "${!path[@]}"; do
3435
echo "local $var=${path[$var]}"
3536
done
3637
}
@@ -40,11 +41,7 @@ function depends_bgm123() {
4041
}
4142

4243
function install_bin_bgm123() {
43-
local vars=(
44-
'config'
45-
'menudir'
46-
)
47-
$(_get_vars_bgm123 "${vars[@]}")
44+
$(_get_vars_bgm123)
4845

4946
local file
5047
local scripts=(
@@ -66,18 +63,7 @@ function install_bin_bgm123() {
6663
}
6764

6865
function configure_bgm123() {
69-
local vars=(
70-
'autostart'
71-
'bashrc'
72-
'onstart'
73-
'onend'
74-
'config'
75-
'menudir'
76-
)
77-
$(_get_vars_bgm123 "${vars[@]}")
78-
79-
local share="$datadir/bgm"
80-
local file
66+
$(_get_vars_bgm123)
8167

8268
# find gamelist
8369
local gamelist="$menudir/gamelist.xml"
@@ -97,6 +83,7 @@ function configure_bgm123() {
9783
fi
9884

9985
# preserve original file versions
86+
local file
10087
for file in "$autostart" "$bashrc" "$onstart" "$onend"; do
10188
if [[ -f "$file" && ! -f "$file.old.$md_id" ]]; then
10289
cp -v "$file" "$file.old.$md_id"
@@ -141,17 +128,7 @@ function configure_bgm123() {
141128

142129
function toggle_bgm123() {
143130
local file
144-
local vars=(
145-
'autostart'
146-
'bashrc'
147-
'onstart'
148-
'onend'
149-
'config'
150-
'init'
151-
'killscript'
152-
'fadescript'
153-
)
154-
$(_get_vars_bgm123 "${vars[@]}")
131+
$(_get_vars_bgm123)
155132

156133
# attempt to remove any existing bgm config
157134
for file in "$autostart" "$bashrc" "$onstart" "$onend"; do
@@ -206,14 +183,7 @@ function enable_bgm123() {
206183
}
207184

208185
function gui_bgm123() {
209-
local vars=(
210-
'autostart'
211-
'config'
212-
'init'
213-
'killscript'
214-
'fadescript'
215-
)
216-
$(_get_vars_bgm123 "${vars[@]}")
186+
$(_get_vars_bgm123)
217187

218188
while true; do
219189
iniConfig "=" '"' "$config"

0 commit comments

Comments
 (0)