Files
opencode.siil.arti.ee 740c6350fc system: restore the Setup menu with the 351Files file manager
The stock image ships /usr/bin/351Files, its gptokeyb mapping and
scripts/setup/file_manager.sh, but removes the setup system from
es_systems.cfg and deletes 13 of the 15 scripts its gamelist referenced.

- re-add the setup system (upstream definition, before ports)
- trim the setup gamelist to the two scripts that still exist:
  File Manager (351Files) and Copy USB roms to device
- add scripts/enable-setup-menu.sh for cards already flashed, since
  /storage/.config/emulationstation/es_systems.cfg overrides the image default
- build script installs system/es/{es_systems.cfg,gamelist.xml}
2026-11-18 08:52:50 +00:00

70 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
# Enable the "Setup" system (File Manager / 351Files, Copy USB ROMs) on a card
# that is already flashed with the patched SYSTEM.
#
# Why this is needed: EmulationStation prefers
# /storage/.config/emulationstation/es_systems.cfg
# over the image default in /usr/config/emulationstation. On existing cards that
# user copy was created at first boot and does not have the setup system.
#
# Run on the device (SSH):
# sh enable-setup-menu.sh
#
# Alternative: delete the override once and EmulationStation falls back to the
# patched image default:
# rm /storage/.config/emulationstation/es_systems.cfg
set -eu
CFG=/storage/.config/emulationstation/es_systems.cfg
if [ ! -f "$CFG" ]; then
echo "no $CFG - EmulationStation already uses the image default"
exit 0
fi
if grep -q '<name>setup</name>' "$CFG"; then
echo "setup system already present in $CFG"
exit 0
fi
BK="$CFG.bak.$(date +%s)"
cp -p "$CFG" "$BK"
echo "backup: $BK"
python3 - "$CFG" <<'PY'
import sys
path = sys.argv[1]
xml = open(path, encoding="utf-8").read()
block = '''\t<system>
\t\t<name>setup</name>
\t\t<fullname>Setup</fullname>
\t\t<manufacturer>EmuELEC</manufacturer>
\t\t<release>2017</release>
\t\t<hardware>Amlogic</hardware>
\t\t<path>/usr/bin/scripts/setup</path>
\t\t<extension>.sh .SH</extension>
\t\t<command>emuelecRunEmu.sh %ROM% -P%SYSTEM% --core=%CORE% --emulator=%EMULATOR% --controllers="%CONTROLLERSCONFIG%"</command>
\t\t<platform>setup</platform>
\t\t<theme>setup</theme>
\t</system>
'''
anchors = [
'\t<system>\n\t\t<name>ports</name>',
'\t<system>\r\n\t\t<name>ports</name>',
]
for a in anchors:
if a in xml:
xml = xml.replace(a, block + a, 1)
break
else:
raise SystemExit("could not find the ports system to anchor to")
open(path, "w", encoding="utf-8").write(xml)
print("inserted setup system before ports")
PY
echo "done. restart EmulationStation (systemd: systemctl restart emustation)"