Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX-Linux] Snaps Issues Part 1 #3128

Merged
merged 12 commits into from
Nov 3, 2023
8 changes: 7 additions & 1 deletion .github/workflows/build-prs-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install modules.
run: yarn install --frozen-lockfile
- name: Build artifacts.
run: yarn dist:linux appimage --publish=never
run: yarn dist:linux appimage snap --publish=never
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
Expand All @@ -37,3 +37,9 @@ jobs:
name: linux-appimage
path: dist/Heroic-*.AppImage
retention-days: 14
- name: Upload Snap.
uses: actions/upload-artifact@v3
with:
name: linux-snap
path: dist/*.snap
retention-days: 14
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@
]
},
"snap": {
"allowNativeWayland": true,
"base": "core20",
"confinement": "strict",
"grade": "stable",
"category": "Games",
"synopsis": "An Open Source Launcher for GOG and Epic Games",
"description": "Heroic is an Open Source Games Launcher. Right now it supports launching games from the Epic Games Store using Legendary and GOG Games using our custom implementation with gogdl.",
"synopsis": "An Open Source Launcher for GOG, Amazon and Epic Games",
"description": "Heroic is an Open Source Games Launcher. Right now it supports launching games from the Epic Games Store using Legendary, Amazon Games using Nile and GOG Games using our custom implementations Nile and gogdl.",
"publish": {
"provider": "snapStore",
"channels": [
Expand Down
5 changes: 5 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@
"title": "Are you sure you want to quit?"
}
},
"snap": {
"checkbox": "Do not show this message again",
"message": "Some features are not available in the Snap version of the app for now and we are trying to fix it.{{newLine}}Current limitations are: {{newLine}}Heroic will not be able to find Proton from Steam or Wine from Lutris.{{newLine}}{{newLine}}Gamescope, GameMode and MangoHud will also not work since Heroic cannot have access to them.{{newLine}}{{newLine}}To have access to this feature please install Heroic as a Flatpak, DEB or from the AppImage.",
"title": "Heroic is running as a Snap"
},
"title": "Warning",
"wine-change": {
"message": "We could not find the selected wine version to launch this title ({{selectedWine}}). {{newline}} We found another one, do you want to continue launching using {{foundWine}} ?",
Expand Down
12 changes: 8 additions & 4 deletions src/backend/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,26 @@ const isSteamDeckGameMode = process.env.XDG_CURRENT_DESKTOP === 'gamescope'
const isCLIFullscreen = process.argv.includes('--fullscreen')
const isCLINoGui = process.argv.includes('--no-gui')
const isFlatpak = Boolean(env.FLATPAK_ID)
const isSnap = Boolean(env.SNAP)
const currentGameConfigVersion: GameConfigVersion = 'v0'
const currentGlobalConfigVersion: GlobalConfigVersion = 'v0'

const flatPakHome = env.XDG_DATA_HOME?.replace('/data', '') || homedir()
const userHome = homedir()
const userHome = isSnap ? env.SNAP_REAL_HOME! : homedir()
const configFolder = app.getPath('appData')
const appFolder = join(configFolder, 'heroic')
const legendaryConfigPath = join(appFolder, 'legendaryConfig', 'legendary')
const legendaryConfigPath = isSnap
? join(env.XDG_CONFIG_HOME!, 'legendary')
: join(appFolder, 'legendaryConfig', 'legendary')
const nileConfigPath = join(appFolder, 'nile_config', 'nile')
const configPath = join(appFolder, 'config.json')
const gamesConfigPath = join(appFolder, 'GamesConfig')
const toolsPath = join(appFolder, 'tools')
const heroicIconFolder = join(appFolder, 'icons')
const runtimePath = join(toolsPath, 'runtimes')
const userInfo = join(legendaryConfigPath, 'user.json')
const heroicInstallPath = join(homedir(), 'Games', 'Heroic')
const defaultWinePrefixDir = join(homedir(), 'Games', 'Heroic', 'Prefixes')
const heroicInstallPath = join(userHome, 'Games', 'Heroic')
const defaultWinePrefixDir = join(userHome, 'Games', 'Heroic', 'Prefixes')
const defaultWinePrefix = join(defaultWinePrefixDir, 'default')
const anticheatDataPath = join(appFolder, 'areweanticheatyet.json')
const imagesCachePath = join(appFolder, 'images-cache')
Expand Down Expand Up @@ -237,6 +240,7 @@ export {
iconLight,
installed,
isFlatpak,
isSnap,
isMac,
isWindows,
isLinux,
Expand Down
32 changes: 31 additions & 1 deletion src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ import {
wineprefixFAQ,
customThemesWikiLink,
createNecessaryFolders,
fixAsarPath
fixAsarPath,
isSnap
} from './constants'
import { handleProtocol } from './protocol'
import {
Expand Down Expand Up @@ -447,6 +448,35 @@ ipcMain.once('frontendReady', () => {
logInfo('Frontend Ready', LogPrefix.Backend)
handleProtocol([openUrlArgument, ...process.argv])

if (isSnap) {
const snapWarning: Electron.MessageBoxOptions = {
title: i18next.t('box.warning.snap.title', 'Heroic is running as a Snap'),
message: i18next.t('box.warning.snap.message', {
defaultValue:
'Some features are not available in the Snap version of the app for now and we are trying to fix it.{{newLine}}Current limitations are: {{newLine}}Heroic will not be able to find Proton from Steam or Wine from Lutris.{{newLine}}{{newLine}}Gamescope, GameMode and MangoHud will also not work since Heroic cannot have access to them.{{newLine}}{{newLine}}To have access to this feature please install Heroic as a Flatpak, DEB or from the AppImage.',
newLine: '\n'
}),
checkboxLabel: i18next.t('box.warning.snap.checkbox', {
defaultValue: 'Do not show this message again'
}),
checkboxChecked: false
}

const showSnapWarning = configStore.get('showSnapWarning', true)

if (showSnapWarning) {
dialog
.showMessageBox({
...snapWarning
})
.then((result) => {
if (result.checkboxChecked) {
configStore.set('showSnapWarning', false)
}
})
}
}

// skip the download queue if we are running in CLI mode
if (isCLINoGui) {
return
Expand Down
6 changes: 5 additions & 1 deletion src/backend/storeManagers/legendary/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,11 @@ export async function runRunnerCommand(
if (!options.env) {
options.env = {}
}
options.env.LEGENDARY_CONFIG_PATH = legendaryConfigPath

// if not on a SNAP environment, set the XDG_CONFIG_HOME to the same location as the config file
if (!process.env.SNAP) {
options.env.LEGENDARY_CONFIG_PATH = legendaryConfigPath
}

const commandParts = commandToArgsArray(command)

Expand Down
1 change: 1 addition & 0 deletions src/common/types/electron_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface StoreStructure {
'window-props': WindowProps
settings: AppSettings
skipVcRuntime: boolean
showSnapWarning: boolean
}
wineDownloaderInfoStore: {
'wine-releases': WineVersionInfo[]
Expand Down