Skip to content

Commit f7332f6

Browse files
committed
flatpak filesystem prefix
1 parent 47cae4a commit f7332f6

File tree

4 files changed

+75
-33
lines changed

4 files changed

+75
-33
lines changed

build/builder.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
# electron-builder.yml
2-
31
appId: io.gitlab.yphil.emulsion
42
productName: Emulsion
53
artifactName: "emulsion_${arch}.${ext}"
64
asar: true
75

8-
# Unpack the native binaries from the ASAR into this folder so they stay executable
96
asarUnpack:
107
- "bin/**"
118

@@ -17,7 +14,6 @@ files:
1714
- "!**/node_modules/**/{CHANGELOG.md,README.md,LICENSE,Makefile}"
1815
- "!build/**/*"
1916

20-
# Copy the 'bin' folder verbatim alongside the app
2117
extraResources:
2218
- from: "bin"
2319
to: "bin"

main.js

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,27 @@ ipcMain.handle('pick-image', async () => {
382382
const { canceled, filePaths } = await dialog.showOpenDialog({
383383
title: 'Select cover art',
384384
properties: ['openFile'],
385-
filters: [{ name: 'JPG', extensions: ['jpg'] }]
385+
filters: [
386+
{
387+
name: 'Image Files',
388+
extensions: ['jpg', 'jpeg', 'png', 'webp']
389+
},
390+
{
391+
name: 'JPEG Images',
392+
extensions: ['jpg', 'jpeg']
393+
},
394+
{
395+
name: 'PNG Images',
396+
extensions: ['png']
397+
},
398+
{
399+
name: 'WebP Images',
400+
extensions: ['webp']
401+
}
402+
]
386403
});
387404
return canceled ? null : filePaths[0];
388405
});
389-
390406
// copy to covers directory
391407
ipcMain.handle('save-cover', async (_event, src, dest) => {
392408
return new Promise(resolve => {
@@ -685,45 +701,67 @@ ipcMain.on('run-command', (event, data) => {
685701
date: new Date().toISOString()
686702
};
687703

688-
const command = `${emulator} ${emulatorArgs || ""} "${filePath}"`;
689-
704+
// --- recents handling unchanged ---
690705
const recentFilePath = getUserConfigFile('recently_played.json');
691706
let recents = [];
692707

693708
if (fsSync.existsSync(recentFilePath)) {
694709
try {
695-
const fileData = fsSync.readFileSync(recentFilePath, 'utf8');
696-
recents = JSON.parse(fileData);
697-
} catch (readErr) {
698-
console.error("Error reading recently_played.json:", readErr);
699-
recents = [];
710+
recents = JSON.parse(fsSync.readFileSync(recentFilePath, 'utf8'));
711+
} catch (err) {
712+
console.error("Error reading recently_played.json:", err);
700713
}
701714
}
702715

703-
// Check if an entry already exists with the same fileName.
704716
const existingIndex = recents.findIndex(entry => entry.fileName === fileName);
705-
706717
if (existingIndex >= 0) {
707-
recents[existingIndex] = {
708-
...recents[existingIndex],
709-
date: recentEntry.date
710-
};
718+
recents[existingIndex].date = recentEntry.date;
711719
} else {
712720
recents.push(recentEntry);
713721
}
714722

715723
try {
716-
fsSync.writeFileSync(recentFilePath, JSON.stringify(recents, null, 4), 'utf8');
717-
} catch (writeErr) {
718-
console.error("Error writing recently_played.json:", writeErr);
724+
fsSync.writeFileSync(recentFilePath, JSON.stringify(recents, null, 4));
725+
} catch (err) {
726+
console.error("Error writing recently_played.json:", err);
719727
}
720728

721-
const child = spawn(command, {
722-
shell: true,
729+
// --- command building (FIXED PART) ---
730+
731+
const romDir = path.dirname(filePath);
732+
733+
let cmd;
734+
let args = [];
735+
736+
const emulatorParts = emulator.split(/\s+/);
737+
738+
if (emulatorParts[0] === "flatpak" && emulatorParts[1] === "run") {
739+
cmd = "flatpak";
740+
741+
args = [
742+
"run",
743+
`--filesystem=${romDir}:ro`,
744+
...emulatorParts.slice(2) // app id + flatpak args
745+
];
746+
} else {
747+
cmd = emulatorParts[0];
748+
args = emulatorParts.slice(1);
749+
}
750+
751+
if (emulatorArgs) {
752+
args.push(...emulatorArgs.split(/\s+/));
753+
}
754+
755+
args.push(filePath);
756+
757+
console.log("cmd, args: ", cmd, args);
758+
759+
const child = spawn(cmd, args, {
723760
detached: true,
724761
stdio: 'ignore'
725762
});
726763

764+
child.unref();
727765
childProcesses.set(child.pid, child);
728766

729767
child.on('exit', () => {

package-lock.json

Lines changed: 16 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/platforms.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export const PLATFORMS = [
205205
emulators: [
206206
{ name: "Rosalie's Mupen GUI", flatpak: "com.github.Rosalie241.RMG", scoop: "games/rmg", url:"https://github.com/Rosalie241/RMG", args: "--nogui --fullscreen" },
207207
{ name: "Gopher64", flatpak: "io.github.gopher64.gopher64", scoop: null, url:"https://github.com/gopher64/gopher64", args: "-f" },
208-
{ name: "M64Py", flatpak: "net.sourceforge.m64py.M64Py", scoop: null, url:"https://m64py.sourceforge.net/", args: "--fullscreen" }
208+
{ name: "M64Py", flatpak: "net.sourceforge.m64py.M64Py", scoop: null, url:"https://m64py.sourceforge.net/", args: "" }
209209
]
210210
},
211211
{

0 commit comments

Comments
 (0)