Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/components/settings-components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,23 @@ let settingsList = [
'fa-file-alt',
() => emitInvoke('ShowDependencyStrings')
),
new SettingsRow(
'Other',
'Launch as Flatpak (Linux)',
'Launch Steam via flatpak',
async () => {
switch (settings.value.getContext().global.linuxUseFlatpak) {
case null:
return 'Automatic';
case true:
return 'Flatpak';
case false:
return 'Native';
}
},
'fa-exchange-alt',
() => emitInvoke('ToggleLinuxUseFlatpak')
),
];

watch(search, () => {
Expand Down
7 changes: 7 additions & 0 deletions src/pages/Manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ function setFunkyMode(value: boolean) {
settings.value.setFunkyMode(value);
}

function setLinuxUseFlatpak(value: boolean) {
settings.value.setLinuxUseFlatpak(value);
}

function browseDataFolder() {
LinkProvider.instance.openLink('file://' + PathResolver.ROOT);
}
Expand Down Expand Up @@ -508,6 +512,9 @@ async function handleSettingsCallbacks(invokedSetting: any) {
case "ToggleFunkyMode":
setFunkyMode(!settings.value.getContext().global.funkyModeEnabled);
break;
case "ToggleLinuxUseFlatpak":
setLinuxUseFlatpak(!settings.value.getContext().global.linuxUseFlatpak);
break;
case "SwitchTheme":
toggleDarkTheme();
document.documentElement.classList.toggle('html--dark', settings.value.getContext().global.darkTheme);
Expand Down
33 changes: 29 additions & 4 deletions src/r2mm/launching/runners/linux/SteamGameRunner_Linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,51 @@ export default class SteamGameRunner_Linux extends GameRunnerProvider {
if (args instanceof R2Error) {
return args
}
return this.start(game, args);
return this.start(game, args, profile.getProfilePath());
}

public async startVanilla(game: Game, profile: Profile): Promise<void | R2Error> {
const instructions = await GameInstructions.getInstructionsForGame(game, profile);
return this.start(game, instructions.vanillaParameters);
return this.start(game, instructions.vanillaParameters, null);
}

async start(game: Game, args: string): Promise<void | R2Error> {
async start(game: Game, args: string, profiledir: string | null): Promise<void | R2Error> {

const settings = await ManagerSettings.getSingleton(game);
const steamDir = await GameDirectoryResolverProvider.instance.getSteamDirectory();
if(steamDir instanceof R2Error) {
return steamDir;
}
let as_flatpak = settings.getContext().global.linuxUseFlatpak;
if (as_flatpak === null) {
// Assume that if the path contains the flatpak directory we must want to use flatpak
as_flatpak = steamDir.includes("/com.valvesoftware.Steam/");
}

if (as_flatpak && profiledir) {
// Ensure we have permission to read our config dir
let visible = true;
const check_cmd = `flatpak run --command='sh' com.valvesoftware.Steam -c 'ls "${profiledir}"'`;
await ChildProcess.exec(check_cmd, undefined, (err: Error) => {
if (err) {
visible = false;
}
});
if (!visible) {
throw new R2Error('Flatpak Permissions Error',
`The directory "${profiledir}" is not visible from within the Flatpak container`,
'`flatpak override com.valvesoftware.Steam --user --filesystem="${XDG_CONFIG_HOME:-$HOME/.config}/r2modmanPlus-local"` to grant access, then restart Steam.');
}
}

LoggerProvider.instance.Log(LogSeverity.INFO, `Steam folder is: ${steamDir}`);

try {
const cmd = `"${steamDir}/steam.sh" -applaunch ${game.activePlatform.storeIdentifier} ${args} ${settings.getContext().gameSpecific.launchParameters}`;
let cmd = `"${steamDir}/steam.sh" -applaunch ${game.activePlatform.storeIdentifier} ${args} ${settings.getContext().gameSpecific.launchParameters}`;
if (as_flatpak) {
cmd = `flatpak run com.valvesoftware.Steam ${cmd}`;
}

LoggerProvider.instance.Log(LogSeverity.INFO, `Running command: ${cmd}`);
await ChildProcess.exec(cmd);
} catch(err) {
Expand Down
5 changes: 5 additions & 0 deletions src/r2mm/manager/ManagerSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ export default class ManagerSettings {
await this.save();
}

public async setLinuxUseFlatpak(enabled: boolean) {
ManagerSettings.CONTEXT.global.linuxUseFlatpak = enabled;
await this.save();
}

public async expandCards() {
ManagerSettings.CONTEXT.global.expandedCards = true;
await this.save();
Expand Down
2 changes: 2 additions & 0 deletions src/r2mm/manager/SettingsDexieStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export default class SettingsDexieStore extends Dexie {
defaultStore: undefined,
gameSelectionViewMode: GameSelectionViewMode.CARD,
previewPanelWidth: 500,
linuxUseFlatpak: null,
},
gameSpecific: {
version: 2,
Expand Down Expand Up @@ -212,6 +213,7 @@ export interface ManagerSettingsInterfaceGlobal_V2 {
defaultStore: Platform | undefined;
gameSelectionViewMode: GameSelectionViewMode;
previewPanelWidth: number;
linuxUseFlatpak: boolean | null;
}

/**
Expand Down