Skip to content

Comments

Fix incomplete game path updates in batocera.conf#5

Merged
thehack904 merged 7 commits intomainfrom
copilot/fix-settings-configuration-issue
Feb 18, 2026
Merged

Fix incomplete game path updates in batocera.conf#5
thehack904 merged 7 commits intomainfrom
copilot/fix-settings-configuration-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

The random game selector was updating only 2 of 4 game path references in batocera.conf, causing the emulator to load incorrect games despite correct metadata being displayed.

Problem

batocera.conf contains 4 locations referencing the selected game:

  • -rom parameter (actual file emulator loads)
  • -systemname parameter (metadata/display)
  • global.bootgame.path (global setting)
  • System-specific settings: system["file.ext"].setting=value

Previous implementation only updated the last two, leaving -rom and game-specific settings pointing to stale games.

Changes

Extract and validate system context:

# Extract system name from boot command
system=$(grep "global.bootgame.cmd" /userdata/system/batocera.conf | grep -oP '\-system \K[^ ]+')

# Extract filename for game-specific settings
new_game_file=$(basename "$new_game")

Update all four locations:

# 1. Update -rom parameter
sed -i "s|\(-rom \)[^ ]*|\1${escaped_game}|" /userdata/system/batocera.conf

# 2. Update -systemname parameter
sed -i "s|\(-systemname \)[^ ]*|\1${escaped_game}|" /userdata/system/batocera.conf

# 3. Update global.bootgame.path
sed -i "s|^global\.bootgame\.path=.*|global.bootgame.path=${escaped_game}|" /userdata/system/batocera.conf

# 4. Update system-specific settings (e.g., mame["old.zip"].tdp → mame["new.zip"].tdp)
sed -i "s|^${escaped_system}\[\"[^\"]*\"\]|${escaped_system}[\"${escaped_filename}\"]|g" /userdata/system/batocera.conf

Add proper escaping:

  • Escape sed special characters (&, \, /) in file paths
  • Escape regex metacharacters (., [, *, ^, $) in system names
  • Validate system extraction with graceful fallback

Example

Before:

global.bootgame.cmd=... -rom /roms/mame/19xx.zip ... -systemname /roms/mame/btimem.zip
global.bootgame.path=/roms/mame/btimem.zip
mame["1941.zip"].tdp=100.000000

After:

global.bootgame.cmd=... -rom /roms/mame/btimem.zip ... -systemname /roms/mame/btimem.zip
global.bootgame.path=/roms/mame/btimem.zip
mame["btimem.zip"].tdp=100.000000
Original prompt

This section details on the original issue you should resolve

<issue_title>Not all settings are being configured properly</issue_title>
<issue_description>Initial /userdata/system/batocera.conf:
system.cpu.governor=schedutil
audio.profile=output:hdmi-stereo@alsa_card.pci-0000_00_1b.0
global.bootgame.cmd=emulatorlauncher %CONTROLLERSCONFIG% -system mame -rom /userdata/roms/mame/19xx.zip -gameinfoxml /tmp/game.xml -systemname /userdata/roms/mame/mrdo.zip
global.bootgame.path=/userdata/roms/mame/19xx.zip
mame["1941.zip"].tdp=100.000000
ScrollLoadMedias=0

after running random_game.sh:
system.cpu.governor=schedutil
audio.profile=output:hdmi-stereo@alsa_card.pci-0000_00_1b.0
global.bootgame.cmd=emulatorlauncher %CONTROLLERSCONFIG% -system mame -rom /userdata/roms/mame/19xx.zip -gameinfoxml /tmp/game.xml -systemname /userdata/roms/mame/galagamf.zip
global.bootgame.path=/userdata/roms/mame/19xx.zip
mame["1941.zip"].tdp=100.000000
ScrollLoadMedias=0

It only changed the game.xml line</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 17, 2026 21:57
Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix settings not being configured properly Fix: Update both global.bootgame.path and global.bootgame.cmd Feb 17, 2026
Copilot AI requested a review from thehack904 February 17, 2026 21:59
Copilot AI and others added 2 commits February 17, 2026 22:27
Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Copilot AI changed the title Fix: Update both global.bootgame.path and global.bootgame.cmd Fix: Update all game path references in batocera.conf Feb 17, 2026
Copilot AI and others added 2 commits February 17, 2026 23:41
Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Copilot AI changed the title Fix: Update all game path references in batocera.conf Fix incomplete game path updates in batocera.conf Feb 17, 2026
@thehack904 thehack904 marked this pull request as ready for review February 18, 2026 00:48
@thehack904 thehack904 merged commit afb51c1 into main Feb 18, 2026
1 check failed
@thehack904 thehack904 deleted the copilot/fix-settings-configuration-issue branch February 18, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not all settings are being configured properly

2 participants