Skip to content

[Ref/Feat] System Information #3027

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

Merged
merged 9 commits into from
Sep 13, 2023
Merged
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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"name": "heroic",
"version": "2.9.1",
"versionNames": {
"stable": "Boa Hancock",
"beta": "Caesar Clown"
},
"private": true,
"main": "build/electron/main.js",
"homepage": "./",
Expand Down Expand Up @@ -193,7 +197,6 @@
"short-uuid": "^4.2.2",
"simple-keyboard": "^3.5.33",
"steam-shortcut-editor": "^3.1.1",
"systeminformation": "^5.17.12",
"tslib": "^2.5.0",
"zod": "^3.21.4"
},
Expand Down
25 changes: 24 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,35 @@
"general": "General",
"log": "Log",
"other": "Other",
"sync": "Cloud Saves Sync"
"sync": "Cloud Saves Sync",
"systemInformation": "System Information"
},
"open-config-file": "Open Config File",
"reset-heroic": "Reset Heroic",
"saves": {
"warning": "Cloud Saves feature is in Beta, please backup your saves before syncing (in case something goes wrong)"
},
"systemInformation": {
"copyToClipboard": "Copy to clipboard",
"cpu": "CPU:",
"cpuDescription": "{{numOfCores}}x {{modelName}}",
"gogdlVersion": "Gogdl: {{gogdlVersion}}",
"gpu": "GPU:",
"gpuDriver": "Driver: {{driverVersion}}",
"gpuWithNumber": "GPU {{number}}:",
"heroicVersion": "Heroic: {{heroicVersion}}",
"legendaryVersion": "Legendary: {{legendaryVersion}}",
"memory": "Memory:",
"memoryStats": "{{percentUsed}}% used ({{usedGib}} / {{totalGib}}",
"nileVersion": "Nile: {{nileVersion}}",
"os": "Operating System:",
"osNameFlatpak": "{{osName}} (inside Flatpak)",
"osVersion": "Version {{versionNumber}}",
"showDetailed": "Show detailed system specifications",
"software": "Software:",
"steamDeck": "Steam Deck",
"systemModel": "System Model:",
"systemSpecifications": "System Specifications:"
}
},
"Settings": "Settings",
Expand Down
2 changes: 0 additions & 2 deletions src/backend/api/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ export const handleGoToScreen = (callback: any) => {
}
}

export const getOSInfo = async () => ipcRenderer.invoke('getOSInfo')

export const handleShowDialog = (
onMessage: (
e: Electron.IpcRendererEvent,
Expand Down
8 changes: 6 additions & 2 deletions src/backend/api/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AppSettings, GameSettings } from 'common/types'
import { ipcRenderer } from 'electron'
import type { SystemInformation } from '../utils/systeminfo'

export const requestAppSettings = async () =>
ipcRenderer.invoke('requestSettings', 'default') as Promise<AppSettings>
Expand Down Expand Up @@ -42,5 +43,8 @@ export const getLogContent = async (args: {
defaultLast?: boolean
}) => ipcRenderer.invoke('getLogContent', args)

export const getNumOfGpus = async (): Promise<number> =>
ipcRenderer.invoke('getNumOfGpus')
export const systemInfo = {
get: async (cache?: boolean): Promise<SystemInformation> =>
ipcRenderer.invoke('getSystemInfo', cache),
copyToClipboard: (): void => ipcRenderer.send('copySystemInfoToClipboard')
}
6 changes: 3 additions & 3 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
constructAndUpdateRPC,
getSteamRuntime,
isEpicServiceOffline,
searchForExecutableOnPath,
quoteIfNecessary,
errorHandler,
removeQuoteIfNecessary,
Expand Down Expand Up @@ -64,6 +63,7 @@ import * as VDF from '@node-steam/vdf'
import { readFileSync } from 'fs'
import { LegendaryCommand } from './storeManagers/legendary/commands'
import { commandToArgsArray } from './storeManagers/legendary/library'
import { searchForExecutableOnPath } from './utils/os/path'

async function prepareLaunch(
gameSettings: GameSettings,
Expand Down Expand Up @@ -96,7 +96,7 @@ async function prepareLaunch(

// Figure out where MangoHud/GameMode are located, if they're enabled
let mangoHudCommand: string[] = []
let gameModeBin = ''
let gameModeBin: string | null = null
if (gameSettings.showMangohud) {
const mangoHudBin = await searchForExecutableOnPath('mangohud')
if (!mangoHudBin) {
Expand Down Expand Up @@ -173,7 +173,7 @@ async function prepareLaunch(
success: true,
rpcClient,
mangoHudCommand,
gameModeBin,
gameModeBin: gameModeBin ?? undefined,
steamRuntime,
offlineMode
}
Expand Down
16 changes: 9 additions & 7 deletions src/backend/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { showDialogBoxModalAuto } from '../dialog/dialog'
import { appendMessageToLogFile, getLongestPrefix } from './logfile'
import { backendEvents } from 'backend/backend_events'
import { GlobalConfig } from 'backend/config'
import { getGOGdlBin, getLegendaryBin, getSystemInfo } from 'backend/utils'
import { getGOGdlBin, getLegendaryBin } from 'backend/utils'
import { join } from 'path'
import { formatSystemInfo, getSystemInfo } from '../utils/systeminfo'

export enum LogPrefix {
General = '',
Expand Down Expand Up @@ -67,13 +68,14 @@ export function initLogger() {
}

// log important information: binaries, system specs
getSystemInfo().then((systemInfo) => {
if (systemInfo === '') return
logInfo(`\n\n${systemInfo}\n`, {
prefix: LogPrefix.Backend,
forceLog: true
getSystemInfo()
.then(formatSystemInfo)
.then((systemInfo) => {
logInfo(`\nSystem Information:\n${systemInfo}\n`, {
prefix: LogPrefix.Backend,
forceLog: true
})
})
})

logInfo(['Legendary location:', join(...Object.values(getLegendaryBin()))], {
prefix: LogPrefix.Legendary,
Expand Down
32 changes: 7 additions & 25 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ import {
clearCache,
execAsync,
isEpicServiceOffline,
getLegendaryVersion,
getGogdlVersion,
getSystemInfo,
handleExit,
openUrlOrFile,
resetHeroic,
Expand All @@ -70,8 +67,7 @@ import {
getCurrentChangelog,
checkWineBeforeLaunch,
removeFolder,
downloadDefaultWine,
getNileVersion
downloadDefaultWine
} from './utils'
import {
configStore,
Expand Down Expand Up @@ -126,7 +122,6 @@ import { notify, showDialogBoxModalAuto } from './dialog/dialog'
import { addRecentGame } from './recent_games/recent_games'
import { callAbortController } from './utils/aborthandler/aborthandler'
import { getDefaultSavePath } from './save_sync'
import si from 'systeminformation'
import { initTrayIcon } from './tray_icon/tray_icon'
import {
createMainWindow,
Expand Down Expand Up @@ -156,6 +151,7 @@ import {
getGameOverride,
getGameSdl
} from 'backend/storeManagers/legendary/library'
import { formatSystemInfo, getSystemInfo } from './utils/systeminfo'

app.commandLine?.appendSwitch('remote-debugging-port', '9222')

Expand Down Expand Up @@ -646,9 +642,6 @@ ipcMain.handle('getEpicGamesStatus', async () => isEpicServiceOffline())
ipcMain.handle('getMaxCpus', () => cpus().length)

ipcMain.handle('getHeroicVersion', app.getVersion)
ipcMain.handle('getLegendaryVersion', getLegendaryVersion)
ipcMain.handle('getGogdlVersion', getGogdlVersion)
ipcMain.handle('getNileVersion', getNileVersion)
ipcMain.handle('isFullscreen', () => isSteamDeckGameMode || isCLIFullscreen)
ipcMain.handle('isFlatpak', () => isFlatpak)
ipcMain.handle('getGameOverride', async () => getGameOverride())
Expand All @@ -658,11 +651,6 @@ ipcMain.handle('getPlatform', () => process.platform)

ipcMain.handle('showUpdateSetting', () => !isFlatpak)

ipcMain.handle('getNumOfGpus', async (): Promise<number> => {
const { controllers } = await si.graphics()
return controllers.length
})

ipcMain.handle('getLatestReleases', async () => {
const { checkForUpdatesOnStartup } = GlobalConfig.get().getSettings()
if (checkForUpdatesOnStartup) {
Expand Down Expand Up @@ -990,19 +978,13 @@ ipcMain.handle(
powerDisplayId = powerSaveBlocker.start('prevent-display-sleep')
}

const systemInfo = getSystemInfo()
const gameSettingsString = JSON.stringify(gameSettings, null, '\t')
const logFileLocation = getLogFileLocation(appName)

systemInfo.then((systemInfo) => {
if (systemInfo === '') return
appendFileSync(
logFileLocation,
'System Info:\n' + `${systemInfo}\n` + '\n'
)
})
const systemInfo = await getSystemInfo().then(formatSystemInfo)
writeFileSync(logFileLocation, 'System Info:\n' + `${systemInfo}\n` + '\n')

writeFileSync(
const gameSettingsString = JSON.stringify(gameSettings, null, '\t')
appendFileSync(
logFileLocation,
`Game Settings: ${gameSettingsString}\n` +
'\n' +
Expand Down Expand Up @@ -1688,7 +1670,7 @@ import './logger/ipc_handler'
import './wine/manager/ipc_handler'
import './shortcuts/ipc_handler'
import './anticheat/ipc_handler'
import 'backend/storeManagers/legendary/eos_overlay/ipc_handler'
import './storeManagers/legendary/eos_overlay/ipc_handler'
import './wine/runtimes/ipc_handler'
import './downloadmanager/ipc_handler'
import './utils/ipc_handler'
Expand Down
Loading