Skip to content

Commit 864fafa

Browse files
Automatic preset importing
Thanks to @syntaxticsugr for helping with the preset detection regexes.
1 parent 4d742d1 commit 864fafa

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ It contains many useability enhancements and all the major fixes needed to run `
5858
but is usually not needed either.
5959
You can still combine `ViPER4Android` with other audio mods
6060
using [`Audio Modification Library`](https://github.com/Magisk-Modules-Repo/aml) if you want to.
61-
* **Automatic VDC and IRS import** \
62-
If you have [bought a VDC file](https://t.me/vdcservice) or downloaded an IRS file
63-
which now lays in your Download directory,
61+
* **Automatic VDC, IRS and preset import** \
62+
If you have [bought a VDC file](https://t.me/vdcservice)
63+
or downloaded an IRS file or preset,
6464
you don't have to copy it over manually.
6565
The installer automatically finds and copies them to the correct place
6666
for `ViPER4Android` to find them

magiskmodule/customize.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,27 @@ if $CUSTOM_IRS_FOUND; then
7575
done
7676
fi
7777

78+
presetCompatible() {
79+
local file="$1"
80+
grep -q '<int name="32775" value="[12]" />' < "$file" || return 1
81+
grep -q '<string name="65540;65541;65542">.*</string>' < "$file" || return 1
82+
return 0
83+
}
84+
85+
mkdir -p "$FOLDER"/Preset
86+
CUSTOM_PRESET_FILES=$(find $SDCARD -name '*.xml' -not -path "$SDCARD/Android/*")
87+
if [ -n "$CUSTOM_PRESET_FILES" ]; then
88+
ui_print "- Copying custom preset files"
89+
for file in $CUSTOM_PRESET_FILES; do
90+
! presetCompatible "$file" && continue
91+
ui_print " $file"
92+
cp -f "$file" "$FOLDER"/Preset
93+
done
94+
else
95+
ui_print "- Skipping preset copy"
96+
ui_print " custom preset files have not been found"
97+
fi
98+
7899
ui_print "- Patching system audio files"
79100
AUDIO_EFFECTS_FILES="$( \
80101
find -H \

0 commit comments

Comments
 (0)